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:53:37 +0100 |
commit | 55b33aad02cfecd75e0629b4268c943037b4a54a (patch) | |
tree | d2f145e6887368c71ac6788c3ffa4681e5695552 | |
parent | 6ba7b2373c0d8576e37c0f8956aecdea7fd81ff2 (diff) | |
download | embedlog-55b33aad02cfecd75e0629b4268c943037b4a54a.tar.gz embedlog-55b33aad02cfecd75e0629b4268c943037b4a54a.tar.bz2 embedlog-55b33aad02cfecd75e0629b4268c943037b4a54a.zip |
examples/print-tty.c: allow print-tty to specify port
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-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"); |