To: | |
---|---|
Subject: | Re: [ts-7000] Re: tcgetattr problem |
From: | "Don W. Carr" <> |
Date: | Sun, 15 Apr 2007 09:50:08 -0500 |
One quick comment. perror, takes a valid null terminated string, then uses that as part of the error message. It puts that string first, then appends a ':' and space, then the actual error message. So, the code you wrote could potentially crash the program on error.
Use something like this for perror: perror("Call to tcgetattr"); Now that I think about it, the structure will have the constants that are defined in a header file, which match to a baud rate, but are not the actual baud rate. Here is my code for setting, and this should solve the problem for you. You likely need a case statement if you want to print the baud rates, which would be the opposite of what I do below. switch (baud_rate) { case 0: rt_tio.c_cflag = B0; break; case 50: rt_tio.c_cflag = B50; break; case 75: rt_tio.c_cflag = B75; break; case 110: rt_tio.c_cflag = B110; break; case 134: rt_tio.c_cflag = B134; break; case 150: rt_tio.c_cflag = B150; break; case 200: rt_tio.c_cflag = B200; break; case 300: rt_tio.c_cflag = B300; break; case 600: rt_tio.c_cflag = B600; break; case 1200: rt_tio.c_cflag = B1200; break; case 1800: rt_tio.c_cflag = B1800; break; case 2400: rt_tio.c_cflag = B2400; break; case 4800: rt_tio.c_cflag = B4800; case 9600: rt_tio.c_cflag = B9600; break; case 19200: rt_tio.c_cflag = B19200; break; case 38400: rt_tio.c_cflag = B38400; break; case 57600: rt_tio.c_cflag = B57600; break; case 115200: rt_tio.c_cflag = B115200; break; case 230400: rt_tio.c_cflag = B230400; break; default: rt_tio.c_cflag = B9600; } I am packing to head for San Francisco, as we speak, so will not be able to reply again, but, I think this will do if for you!! Don. On 15 Apr 2007 07:11:44 -0700, Rob <> wrote:
|
<Prev in Thread] | Current Thread | [Next in Thread> |
---|---|---|
|
Previous by Date: | Re: [ts-7000] Error message : Directory not empty, Don W. Carr |
---|---|
Next by Date: | [ts-7000] Re: tcgetattr problem, charliem_1216 |
Previous by Thread: | [ts-7000] Re: tcgetattr problem, Rob |
Next by Thread: | [ts-7000] Re: tcgetattr problem, charliem_1216 |
Indexes: | [Date] [Thread] [Top] [All Lists] |
Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU