#include #include #include #include #include #include #include #include "util.h" #include "keypad.h" static int usage (const char *name) { fprintf (stderr, "Usage:\n"); fprintf (stderr, "%s -p device [ -b baud ] [ -d debug ] [ -l log_file ]\n", name); fprintf (stderr, "\n"); return -1; } int main (int argc, char *argv[]) { unsigned opt; const char *port = NULL; const char *log = NULL; int debug = 0; unsigned baud = 9600; int fd; while ((opt = getopt (argc, argv, "h:p:z:dl:")) != -1) { switch (opt) { case 'p': port = optarg; break; case 'b': baud = atoi (optarg); break; case 'd': debug++; break; case 'l': log = optarg; break; default: /* '?' */ return usage (argv[0]); } } if (!port) return (usage (argv[0])); fd = open_tty (port, baud); set_blocking (fd); if (fd < 0) { perror ("open tcp port"); return -1; } return gd_keypad (fd, log, debug); }