[Mono-list] SerialPort doesn't work
Adrián Bulnes
mono at urriellu.net
Sun May 31 12:38:12 EDT 2009
I've tried the example from http://www.mono-project.com/HowToSystemIOPorts
with and without modification. I've also tried other examples from other
websites, but nothing works. I didn't try to send data (right now I can't
test it) but I tried to receive data and it just doesn't receive anything.
I'm not using the DataReceived event (I tried too, but obviously doesn't
work). I have the right permissions. I can receive data from the same device
when using other native programs, such as gtkterm. I'm in the uucp group.
Running my tests as root doesn't receive anything either.
I tried Read() and ReadByte(). None of the receive anything. If I
set "ReadTimeout" I always get a TimeoutException. If I don't set a timeout,
it keeps waiting forever.
I can get the list of available serial ports using SerialPort.GetPortNames().
I'm setting the port name properly, because when I intentionally put it
wrong, It throws the correct exception.
I tried both closing and not closing the port before opening it.
I tried calling the SerialPort constructor without parameters and then setting
them one by one before calling Open(). I also tried putting all parameters
when calling the constructor.
Mono is accessing the device, it's properly shown when I
do "lsof /dev/my_serial_port".
I can read the BaudRate, DataBits, StopBits, Parity and PortName properly.
Everything seems to work fine, but nothing is received.
I'm using a USB-serial converter, based on an FT232 chip, which works fine
with other programs and even doing "cat /dev/ttyUSB0" (well, not always, but
I think it's a configuration problem, nothing to do with this), but I can't
receive anything with C#+Mono+linux.
What else can I try? Could it be a Mono bug?
Thank you very much
More information about the Mono-list
mailing list