[Mono-dev] SerialPort auto-inserts carriage return

mikaelwikman mail at mikaelwikman.se
Sat Sep 13 04:36:08 EDT 2008


Im using a System.IO.Ports.SerialPort to communicate with an embedded system
currently being developed where i work. The ES uses a binary protocol, so
the data is not ascii and do not use newlines.

The strange thing is this; For every byte with the value 10 (linefeed) an
extra byte with value 13 (carriage return) is inserted into the stream im
reading from, totally messes up the protocol.

So: <10> becomes <13><10>, and also <13><10> becomes <13><13><10>.

I'm running Linux, the code has not been tested using .NET

Some of my code:

            SerialPort serialB = new SerialPort()

            serialB.BaudRate = 115200;
            serialB.DtrEnable = true;
            serialB.PortName = "/dev/ttyUSB0";
            serialB.ReadTimeout = 5;

            byte[] data = new byte[serialB.BytesToRead];
            serialB.Read(data, 0, serialB.BytesToRead);

I'm thinking this is either a bug or there is some setting which turns this
off. Appreciate any help, thanks!
View this message in context: http://www.nabble.com/SerialPort-auto-inserts-carriage-return-tp19468589p19468589.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list