Reputation: 2241
OS is Ubuntu 10.04 32-bit.
All these years I've unknowingly assumed that input and output baudrates were symmetrical, in == out. I just noticed, however, that the Linux termios structure contains fields for the input and output baudrate. And there are "in" and "out" versions of the buadrate setter/getter -- cfsetospeed/cfsetispeed, cfgetospeed/cfsgetispeed Are they actually separate controls and I can talk and listen at different speeds? Would I ever want to?
What little I could find on google says setting the input speed to 0 will tell the input speed to match the output speed. Correct? If I set the output speed to, say 9600, then set the input speed to zero, input speed should be 9600. What happens if I then change the output speed to 19200? Will input speed also change to 19200?
Sorry for the somewhat easier questions where I should just go try it. My serial-attached hardware is in an unknown state and I am unsure how it is behaving.
Upvotes: 1
Views: 330
Reputation: 283624
Not all serial ports support configuring these separately, but the termios API does give you separate controls to support the ones that do.
Cases where you'd want asymmetric rates will be completely obvious (the manual for the device you're talking to lists different rates for input and output, and you need both simultaneously).
There's no good reason to use the "zero means input and output are the same". Just set them the same explicitly, then you never have to worry about corner cases.
Upvotes: 1