Can't read from USB device in C# on Mono

Mono 2.6.3 MonoDevelop 2.2 openSUSE 11.2

I'm trying to read from a CP2102 USB device.  The program works when running in Windows but not when on Linux.  The comport.DataReceived event does not fire.  

I'm using /dev/ttyUSB0 as the comport.portName value which is the only ttyUSB value that shows up in my dir list.  Is that the correct value to be using?

crw-rw----  1 root dialout 188,   0 2010-04-10 11:45 ttyUSB0

lsusb shows:
Bus 004 Device 003: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x Composite Device

I looked in yast's hardware information and under USB it shows the CP2102 (/dev/ttyUSB0), Drivers Active:Yes so I assume the drivers are in place.  Here's the code I'm using:


            comport = new SerialPort();
            comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
            comport.BaudRate = 128000;
            comport.DataBits = 8;
            comport.StopBits = StopBits.One;
            comport.Parity = Parity.None;
            comport.Handshake = Handshake.None;
            comport.ReadTimeout = 500;
            comport.WriteTimeout = 500;
            comport.PortName = "/dev/ttyUSB0";
            comport.Open();
            comport.DtrEnable = true;


...

        private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            getPortData();  // Never gets fired
        }

Can anyone tell me what might be stopping the DataReceived event from firing?

Thanks,

sr
StarDusterIIAsked:
Who is Participating?
 
StarDusterIIAuthor Commented:
As I said in my first post, the program is working in WIndows so I don't really need the reference for writing to a USB device.  What I was looking for was why it wan't working in Mono on Linux... which I found myself.

Apparently, the DataReceived event hasn't been implemented in the Mono .Net runtime.  So, I had to set up a thread to continually check BytesToRead.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.