News

Friday, October 24, 2014

Linux - select() call not returning when I expect

Thursday, October 23, 2014
I have a C++ application that is reading data from a serial port but I'm seeing some weird behavior with regards to the amount of time it takes to complete a select call. I'm trying to read some data from another device which is streaming out 5 kB blocks at 115200 baud, the device streams out a total of 200 kB total during an entire transaction. The actual read calls grab 512 bytes at a time. When grabbing the 5 kB blocks the first select call takes ~475ms then the subsequent ones take 48ms. So it looks like select is only unblocking once all the data reaches the port. Since 475ms at 115200 baud gets me about 5 kB. Then the 48ms gets me about 512 bytes which is the size of the UART buffer on my device. What's strange is that when grabbing the last 3-4 blocks the first select call returns in 48ms which is what I'd expect it to do in the first place. From what I gather it looks like select is blocking until the device is finished writing all data over UART since it's only the initial one in each block that's effected. Is select supposed to return once there's any data to read on the device? Or are there some other conditions it's looking for? Is there any way I can configure my serial port to return from select once there is data available on the handle? ...

More @

No comments:

Blog Archive