From owner-p4-projects@FreeBSD.ORG Fri May 12 23:30:17 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1B91116A66F; Fri, 12 May 2006 23:30:17 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4E14116A66A for ; Fri, 12 May 2006 23:30:15 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 00EBA43D48 for ; Fri, 12 May 2006 23:30:15 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k4CNUEUP004214 for ; Fri, 12 May 2006 23:30:14 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k4CNUE5B004211 for perforce@freebsd.org; Fri, 12 May 2006 23:30:14 GMT (envelope-from marcel@freebsd.org) Date: Fri, 12 May 2006 23:30:14 GMT Message-Id: <200605122330.k4CNUE5B004211@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Cc: Subject: PERFORCE change 97037 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 May 2006 23:30:21 -0000 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: