With commit 33a9249571 ("slcand: daemonise only once setup is complete")
the daemonize syscall is moved behind serial tty setup.
This patch moves the missing assignment of the loop variable slcand_running
to get it into the code context of the while() loop.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Delay the daemon() call until the interface has been configured. This
simplifies scripts that wish to use the new interface immediately.
Signed-off-by: Mans Rullgard <mans@mansr.com>
listen-only option (-l) has been added to slcan-attach in oct 2015.
It is now replicated in slcand
Signed-off-by: interlocuteur <gallard@mmic.net>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Including <sys/ioctl.h> and <net/if.h> is not sufficient
to musl to find SIOCSIFNAME, so <linux/sockios.h> must be
included too.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
The line discipline number is provided in include/linux/tty.h.
Use that instead of a #define in each program.
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Some places used exit(1) and others used exit(EXIT_FAILURE).
Be consistent and use exit(EXIT_FAILURE) for all of these instances.
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
slcand has #defines for EXIT_FAILURE and EXIT_SUCCESS but this is
unnecessary since they are already provided by stdlib.h. Remove them.
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
The examples in the usage of slcand use a 'ttyslcan0' device which
is an uncommon name. Use a more common ttyUSB0 name which is seen
with CANUSB devices. Also, add an example showing that /dev/ttyUSB0
can be use as well.
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Linux build compiles without errors, but Android build
complains about undefined routines and macros.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Replace daemonize() routine with daemone() system call, because of
conflicting licenses. daemonize() routine was derived from under
GNU Free Documentation License licensed code. This license is
incompatible with GPL-2+.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Add option '-t' to specify flow control type. Two types are
supported: 'hw' - RTS/CTS and 'sw' - XON/XOFF.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
The dummyFile pointer was only needed to redirect stdxxx streams but it's
content was never used. Re-use the pFile pointer for this reason which is
unused at that point to silent the compiler warning about the set and unused
dummyFile variable.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Fixed coding style inspired by Linux checkpatch.pl
Additionally removed a comment in the write() result check in the 'if (speed)'
statement to make sure the write() is not optimized away as the executed code
was empty.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
slcand takes settings known from slcan_attach to configure CAN
interface, like open/close channel, set bitrate etc (Oliver Hartkopp).
In addition -S option sets UART's baudrate (Yegor Yefremov).
This way slcand combines three autilities in one: old slcand,
slcan_attach and stty.
Example: slcand -o -s8 -S 3000000 ttyUSB0
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
- add missing sys/socket.h: on some systems (like Android)
have SOCK_RAW definition directly in sys/socket.h
- use sys/wait.h instead if wait.h
- include termios.h explicitly (Android)
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
The buffers to build the pathnames had been malloc'ed and never been free'd.
This patch removes the malloc stuff entirely.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
netdevice name to the given tty (by renaming the created netdevice).
Signed-off-by: Robert Haddon <robert.haddon@cirrascale.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>