[Mono-dev] Unable To Read Using SerialPort Class
adam1piano at gmail.com
Sat Oct 4 14:57:49 EDT 2008
I'm currently trying to use the System.IO.Ports.SerialPort class to
communicate with a microcontroller, however I can't seem to read from the
port in any way in OS X. After much searching it looks like the DataReceived
event is not functional in Mono yet and that the suggested method is to poll
the port using the ReadByte function, but no matter which read method I try
(I've tried Read, ReadByte, and ReadExisting, as well as the DataReceived
event), I always end up getting timeout exceptions.
I'm checking the BytesToRead value before issuing a read and it's returning
expected values for what the controller is outputting, I just can't seem to
retrieve the data from the buffer.
I'm attempting the read with the following code:
byte bytes=new byte[byteCount];
I am sure that the port is reading (if I use a serial terminal I can see the
data), and the port is readable if I compile the code in Visual Studio in
Windows - I haven't tried Mono in Windows yet.
Any help you can give is much appreciated. Thanks.
View this message in context: http://www.nabble.com/Unable-To-Read-Using-SerialPort-Class-tp19815631p19815631.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list