managing termios for ser ports
I am trying to follow an example for simple serial port IO. ttyS0 for example.
I have a problem with the termios values particularly c_cflag and or cfsetispeed / cfsetospeed. For the funtion cfsetispeed for example, it refers to a value like B38400, which they say is defined as 38400, or, #define B38400 38400. But using the other method to set termios.c_cflag it's supposed to be an OR of varios controls, like ( CS8 | B38400 | CLOCAL | CREAD ) for instance. Here obvious B38400 = 38400 is obviously not compatible to this flag setting. The bits would conflict with others. In my termbits.h it says the following #define B38400 00000017 !!!! NOTE it does NOT say #define B38400 0x00000017 If I use cfsetispeed (with B38400) c_cflag is not changed ( using 38400 or 0x00000017 or B_38400 ). I cannot make the serial port work, even though the "open" returns a good fd. What is going on?? DavidHB |
B38400 not defined as 38400. It's 'something' that reflects the baudrate 38400. The value is 15 which matches your termbits.h (00000017 is an octal value, so 1*8 + 7 = 15). You can print the value with a simple printf.
I've posted an init routine that I usually use in this thread |
Wim,
Thanks for the clarification. It hadn't occured to me that it was octal, and some other references that I had seen indicated that B38400 defined directly to 38400(??) so I was left with a confusion. Hex ( or Octal ) made more sense to me. I'm not at my office today, but when I get back I'll take another look. Thanks for the in depth response. Dave |
All times are GMT -5. The time now is 07:30 PM. |