Date: Fri, 12 May 2006 23:30:14 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 97037 for review Message-ID: <200605122330.k4CNUE5B004211@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=97037 Change 97037 by marcel@marcel_nfs on 2006/05/12 23:29:24 Allow setting the line speed on the command line and bail out if tcsetattr() fails. Affected files ... .. //depot/projects/uart/dev/uart/uarttest.c#6 edit Differences ... ==== //depot/projects/uart/dev/uart/uarttest.c#6 (text+ko) ==== @@ -155,9 +155,11 @@ { char buf[PATH_MAX]; struct termios t0, t1; + speed_t sp; int ch; - while ((ch = getopt(argc, argv, "clt")) != -1) { + sp = 9600; /* Any speed that we expect to work for all UARTs */ + while ((ch = getopt(argc, argv, "cls:t")) != -1) { switch (ch) { case 'c': /* DCE mode */ sethow(AS_DCE); @@ -165,6 +167,9 @@ case 'l': /* Loopback mode */ sethow(AS_LOOP); break; + case 's': /* Line speed */ + sp = atoi(optarg); + break; case 't': /* DTE mode */ sethow(AS_DTE); break; @@ -198,7 +203,7 @@ tcgetattr(fd, &t0); t1 = t0; cfmakeraw(&t1); - cfsetspeed(&t1, B115200); + cfsetspeed(&t1, sp); switch (how) { case AS_DCE: t1.c_cflag |= CRTS_IFLOW; @@ -210,7 +215,10 @@ t1.c_cflag |= CCTS_OFLOW | CRTS_IFLOW; break; } - tcsetattr(fd, TCSAFLUSH|TCSANOW, &t1); + if (tcsetattr(fd, TCSAFLUSH|TCSANOW, &t1) == -1) + err(EX_IOERR, "cannot set line attributes"); + + printf("Line speed is %u baud\n", sp); switch (how) { case AS_DCE:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605122330.k4CNUE5B004211>