2 * PCAN-LIN, RS-232 to CAN/LIN converter control application
4 * This program is free software; you can distribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; version 2 of
9 * Copyright: (c) 2012 Czech Technical University in Prague
10 * Authors: Rostislav Lisovy <lisovy@gmail.cz>
14 Used prefixes explanation:
15 pcl_ -- PCAN-LIN (hw) related functions
16 sll_ -- sllin (tty lin implementation) related functions
17 linc_ -- LIN config general functions
28 #include "linc_parse_xml.h"
29 #include "pcl_config.h"
30 #include "lin_config.h"
33 void linc_explain(int argc, char *argv[])
35 fprintf(stderr, "Usage: %s [OPTIONS] <SERIAL_INTERFACE>\n", argv[0]);
36 fprintf(stderr, "\n");
37 fprintf(stderr, "'pcan_lin_config' Is used for configuring PEAK PCAN-LIN device.\n");
38 fprintf(stderr, " When invoked without any OPTIONS, it configures PCAN-LIN device\n");
39 fprintf(stderr, " with configuration obtained from '"PCL_DEFAULT_CONFIG"' file (if it exists).\n");
40 fprintf(stderr, " The PCAN-LIN module enables CAN, LIN and serial participants to communicate.\n");
41 fprintf(stderr, "\n");
42 fprintf(stderr, "Options:\n");
43 fprintf(stderr, " -r Execute only Reset of a device\n");
44 fprintf(stderr, " -f Flash the active configuration\n");
45 fprintf(stderr, " -c <FILE> Path to XML configuration file\n");
46 fprintf(stderr, "\n");
47 fprintf(stderr, "Examples:\n");
48 fprintf(stderr, " %s /dev/ttyS0 (Configure the device with the configuration from '"PCL_DEFAULT_CONFIG"')\n",
50 fprintf(stderr, " %s -r /dev/ttyS0 (Reset the device)\n", argv[0]);
53 int main(int argc, char *argv[])
58 char *filename = NULL;
60 while ((opt = getopt(argc, argv, "rfc:")) != -1) {
63 flags |= RESET_DEVICE_fl;
66 flags |= FLASH_CONF_fl;
72 linc_explain(argc, argv);
77 /* Expected argument after options */
79 linc_explain(argc, argv);
83 linc_lin_state.dev = strdup(argv[optind]);
85 ret = linc_parse_configuration(filename, &linc_lin_state);
87 printf("Configuration file %s parsed correctly\n", filename);
89 pcl_config(&linc_lin_state, flags);