diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2021-01-25 00:51:56 +0100 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2021-01-25 00:52:32 +0100 |
commit | 30115b9ee3ba0bf14fa8b1add0b3fd51d6919fc0 (patch) | |
tree | dda4f5f6dffb27f1bdd08d5bd360ff2f5eff4efb /examples | |
parent | 18dd9908f17a0af378ded44075d266acf77c7730 (diff) | |
download | embedlog-30115b9ee3ba0bf14fa8b1add0b3fd51d6919fc0.tar.gz embedlog-30115b9ee3ba0bf14fa8b1add0b3fd51d6919fc0.tar.bz2 embedlog-30115b9ee3ba0bf14fa8b1add0b3fd51d6919fc0.zip |
examples/print-tty.c: allow print-tty to specify port
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/print-tty.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/examples/print-tty.c b/examples/print-tty.c index 193e6e7..50281de 100644 --- a/examples/print-tty.c +++ b/examples/print-tty.c @@ -14,14 +14,20 @@ #endif #ifdef EMBEDLOG_DEMO_LIBRARY -int el_demo_print_tty(void) +int el_demo_print_tty(int argc, const char *argv[]) #else -int main(void) +int main(int argc, const char *argv[]) #endif { /* first we nned to initialize logger to known state */ el_init(); + if (argc != 2) + { + el_print(ELF, "usage: %s <path-to-serial-device>", argv[0]); + return 1; + } + /* to use logger you need to enable at least one output, * without it logs will be printed to /dev/null. Here we set * output to serial device. */ @@ -32,13 +38,13 @@ int main(void) * configure which device we want to use and at what speed. * Transmission parameters are 8N1 by default. Baudrate should * be taken from termios (3). */ - if (el_option(EL_TTY_DEV, "/dev/ttyUSB1", B9600) != 0) + if (el_option(EL_TTY_DEV, argv[1], B9600) != 0) #else /* if termios is not available on your system, you can specify * 0 as baund rate, this will tell embedlog not to configure * serial port and use it as is - ie. it can be configured * at system startup or even during compile time */ - if (el_option(EL_TTY_DEV, "/dev/ttyUSB1", 0) != 0) + if (el_option(EL_TTY_DEV, argv[1], 0) != 0) #endif { perror("tty set failed"); |