53int slip_config_verbose = 0;
54int slip_config_flowcontrol = 0;
55int slip_config_timestamp = 0;
56const char *slip_config_siodev = NULL;
57const char *slip_config_host = NULL;
58const char *slip_config_port = NULL;
59uint16_t slip_config_basedelay = 0;
62#define BAUDRATE B115200
64speed_t slip_config_b_rate = BAUDRATE;
66#define BAUDRATE_PRIO CONTIKI_VERBOSE_PRIO + 20
69 "example parameters: -L -v=2 -s /dev/ttyUSB1 fd00::1/64\n\n");
71 "\nVerbosity level:\n"
73 " 1 Encapsulated SLIP debug messages (default)\n"
74 " 2 Printable strings after they are received\n"
75 " 3 Printable strings and SLIP packet notifications\n"
76 " 4 All printable characters as they are received\n"
77 " 5 All SLIP packets in hex\n");
80baudrate_callback(
const char *optarg)
82 int baudrate = atoi(optarg);
87 slip_config_b_rate = B9600;
90 slip_config_b_rate = B19200;
93 slip_config_b_rate = B38400;
96 slip_config_b_rate = B57600;
99 slip_config_b_rate = B115200;
103 slip_config_b_rate = B921600;
107 fprintf(stderr,
"unknown baudrate %s", optarg);
115 "baudrate (9600,19200,38400,57600,115200,921600)"
117 "baudrate (9600,19200,38400,57600,115200)"
119 " (default 115200)\n");
121 {
"H", no_argument, &slip_config_flowcontrol, 1 }, NULL,
122 "hardware CTS/RTS flow control (default disabled)\n");
124 {
"L", no_argument, &slip_config_timestamp, 1 }, NULL,
125 "log output format (adds time stamps)\n");
127device_callback(
const char *optarg)
129 slip_config_siodev = optarg;
132CONTIKI_OPTION(BAUDRATE_PRIO + 3, {
"s", required_argument, NULL, 0 },
133 device_callback,
"serial device\n");
135host_callback(
const char *optarg)
137 slip_config_host = optarg;
140CONTIKI_OPTION(BAUDRATE_PRIO + 4, {
"a", required_argument, NULL, 0 },
141 host_callback,
"connect via TCP to server at <value>\n");
143port_callback(
const char *optarg)
145 slip_config_port = optarg;
148CONTIKI_OPTION(BAUDRATE_PRIO + 5, {
"p", required_argument, NULL, 0 },
149 port_callback,
"connect via TCP to server on port <value>\n");
151delay_callback(
const char *optarg)
153 slip_config_basedelay = optarg ? atoi(optarg) : 10;
154 if(slip_config_basedelay < 0 ||
155 (slip_config_basedelay == 0 && optarg && optarg[0] !=
'0')) {
156 fprintf(stderr,
"Delay '%s' could not be parsed as a number\n", optarg);
162CONTIKI_OPTION(BAUDRATE_PRIO + 6, {
"d", optional_argument, NULL, 0 },
164 "minimum delay between outgoing SLIP packets (default 10)\n"
165 "\t\tActual delay is basedelay * (#6LowPAN fragments)"
169slip_config_handle_arguments(
int argc,
char **argv)
174 tun6_net_set_prefix(argv[1]);
180verbose_callback(
const char *optarg)
182 slip_config_verbose = optarg ? atoi(optarg) : 3;
183 if(slip_config_verbose < 0 || slip_config_verbose > 5 ||
184 (slip_config_verbose == 0 && optarg && optarg[0] !=
'0')) {
185 fprintf(stderr,
"Verbose level '%s' not between 0 and 5\n", optarg);
190CONTIKI_OPTION(CONTIKI_VERBOSE_PRIO, {
"v", optional_argument, NULL, 0 },
191 verbose_callback,
"verbosity level (0-5)\n");
195 {
"v0", no_argument, &slip_config_verbose, 0 }, NULL, NULL);
197 {
"v1", no_argument, &slip_config_verbose, 1 }, NULL, NULL);
199 {
"v2", no_argument, &slip_config_verbose, 2 }, NULL, NULL);
201 {
"v3", no_argument, &slip_config_verbose, 3 }, NULL, NULL);
203 {
"v4", no_argument, &slip_config_verbose, 4 }, NULL, NULL);
205 {
"v5", no_argument, &slip_config_verbose, 5 }, NULL, NULL);
#define CONTIKI_EXTRA_HELP(prio, msg)
Set extra usage help shown at the end of –help.
#define CONTIKI_OPTION(prio,...)
Add a command line option when the compilation unit is present.
#define CONTIKI_USAGE(prio, msg)
Set the usage string shown for –help.