Fixed Makefiles to compile test-apps and can-utils again.

Added new commandline parameter (linediscipline value) to slcan_attach.
pull/7/head
Oliver Hartkopp 2007-03-05 21:58:28 +00:00
parent 79cc51a867
commit 60b77912ab
2 changed files with 17 additions and 5 deletions

View File

@ -41,7 +41,9 @@
# Send feedback to <socketcan-users@lists.berlios.de> # Send feedback to <socketcan-users@lists.berlios.de>
CFLAGS = -O2 -Wall -Wno-parentheses -I../kernel/2.6/include \ CFLAGS = -O2 -Wall -Wno-parentheses -I../kernel/2.6/include \
-fno-strict-aliasing -fno-strict-aliasing \
-DPF_CAN=29 \
-DAF_CAN=PF_CAN
PROGRAMS = candump cansniffer cansend canplayer cangen\ PROGRAMS = candump cansniffer cansend canplayer cangen\
log2long log2asc asc2log slcan_attach log2long log2asc asc2log slcan_attach

View File

@ -52,25 +52,33 @@
#include <unistd.h> #include <unistd.h>
#include <getopt.h> #include <getopt.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/tty.h> /* thanks for cleanup since 2.6.21 */
//#include <asm/termios.h> /* ldiscs for each arch up to 2.6.20 */
#ifndef N_SLCAN
#define N_SLCAN 16 /* bad hack until it's not inside the Kernel */ #define N_SLCAN 16 /* bad hack until it's not inside the Kernel */
#endif
void usage(char *name) void usage(char *name)
{ {
fprintf(stderr, "Usage: %s [-d] tty\n", name); fprintf(stderr, "Usage: %s [-d] [-l ldisc] tty\n", name);
exit(1); exit(1);
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int fd; int fd;
int ldisc; int ldisc = N_SLCAN; /* default */
int detach = 0; int detach = 0;
char *tty; char *tty;
int opt; int opt;
while ((opt = getopt(argc, argv, "d")) != -1) { while ((opt = getopt(argc, argv, "l:d")) != -1) {
switch (opt) { switch (opt) {
case 'l':
ldisc = atoi(optarg);
break;
case 'd': case 'd':
detach = 1; detach = 1;
break; break;
@ -90,7 +98,9 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
ldisc = detach ? N_TTY : N_SLCAN; if (detach)
ldisc = N_TTY;
if (ioctl (fd, TIOCSETD, &ldisc) < 0) { if (ioctl (fd, TIOCSETD, &ldisc) < 0) {
perror("ioctl"); perror("ioctl");
exit(1); exit(1);