FreeCalypso > hg > fc-rfcal-tools
diff cmu200/main.c @ 37:498b90f6e224
fc-cmu200d: added command line options
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 01:58:06 +0000 |
parents | 6d7079a81e8b |
children | 3ec82dc1dbda |
line wrap: on
line diff
--- a/cmu200/main.c Fri May 26 16:00:06 2017 +0000 +++ b/cmu200/main.c Sat May 27 01:58:06 2017 +0000 @@ -4,30 +4,45 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> int target_fd; -static char default_socket_pathname[] = "/tmp/fc_rftest_socket"; - -char *bind_socket_pathname; +char *bind_socket_pathname = "/tmp/fc_rftest_socket"; +char *cmu200_tx_name = "TX"; +int cmu200_rf_port = 2; main(argc, argv) char **argv; { - if (argc < 3 || argc > 4) { - fprintf(stderr, - "usage: %s serial-port baud [socket-pathname]\n", - argv[0]); - exit(1); - } - open_target_serial(argv[1], argv[2]); + extern char *optarg; + extern int optind; + int c; + + while ((c = getopt(argc, argv, "1at:")) != EOF) + switch (c) { + case '1': + cmu200_rf_port = 1; + continue; + case 'a': + cmu200_tx_name = "AUXT"; + continue; + case 't': + bind_socket_pathname = optarg; + continue; + default: +usage: fprintf(stderr, + "usage: %s [options] serial-port baud\n", + argv[0]); + exit(1); + } + if (argc - optind != 2) + goto usage; + + open_target_serial(argv[optind], argv[optind+1]); set_serial_nonblock(0); setlinebuf(stdout); /* to allow logging with tee */ init_cmu200(); - if (argc > 3) - bind_socket_pathname = argv[3]; - else - bind_socket_pathname = default_socket_pathname; create_listener_socket(); for (;;) { get_socket_connection();