Accessing a half-duplex serial port with POSIX

I am encouraged to read and write on a half duplex serial connection using POSIX calls (more specifically, write in C on Linux 2.6.x). I have a little trouble finding details about this particular model (most of the pages focus on full duplex), and when I get small reading anomalies I wanted to check if I might be doing something wrong.

With a half duplex serial connection, I can read or write. This is not a problem since there is no unsolicited incoming data on the line - the only time any packets are sent to me (to read) is when I have requested them in advance.

So what my code is doing is to write () to the port whenever something needs to be sent. If this data leads to an answer (something I know ahead of time), I just read (). I have no special functions, but maybe I need it? And is this approach correct? That is, write when the line is free?

+1


source to share


1 answer


I would read the original Linux kernel documentation, maybe a text file about the serial driver; if not, you can read the actual driver code to see what it does (it's not as scary as it sounds, I promise!)



0


source







All Articles