Hi all,
A while ago I did some code to talk to comms ports. It appeared to work fine, except I discovered that my receive functions locks up if no data is being sent from an rs232 device?
Basically I use open,read and write function. The problem is the read function which hangs if no data is being sent. So I can't even error.
I set up the port with an open (and all the rest of the baud rate stuff)
Code:
(*comlist)->id = open((*comlist)->portname, O_RDWR | O_NOCTTY | O_NDELAY);
I've also tried adding a non block but this has no effect
Code:
(*comlist)->id = open((*comlist)->portname, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
I read with
Code:
read(port->id, readletter, 1)
This just hangs on read unless I connect a device which is sending data.
Is there a way to make read return if nothing is there? I thought I would get a -1 returned but this does not appear to be the case. Thanks