Advertisement

Comport Hell

Started by September 29, 2003 06:08 PM
1 comment, last by Shannon Barber 21 years, 4 months ago
Ok, after countless hours of @#$@#$ around we finally realized that linux loves to setup /dev/ttySx as terminals and managed to convince it to do otherwise (so-called "raw" serial IO, aka Normal). We make a bunch of calls and fiddle a bunch of flags to setup "raw" mode. Is there a more direct way to say ''send these exact bytes out the com port?'' Is there a way to ask if there are any bytes are available to read? or how many? We want blocking sends, but want read to return right away with whatever is available. (Maybe we can do blocking IO, but set the read timeout to 0?) Any clues, hints, or suggestions are much appreciated.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I got to the bottom of one of my problems. But I still do not understand why it returns from sends immediately. I try to send ~3000 bytes at 9600baud, and it takes 300us to execute. The bytes all get there (eventually), but this is not how I expect blocking IO to work!


PS Don't ever do this:

char cmd[] = "start\x0d";int sent = write(fd, cmd, sizeof(cmd));  


'cause it'll send out the null at the end of the string (which looks a lot like a break to the other side).


[edited by - Magmai Kai Holmlor on September 30, 2003 7:22:42 PM]
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
I could be talking out of my ass here since i have not tried this, but you could just make it blocking both ways and use select(2) with a timeout of 0 to check if there is any data available.

This topic is closed to new replies.

Advertisement