views:

303

answers:

2

I've done a good deal of RS232 work using the .Net 2.0 serialport class. I've never had trouble with it, until today.

I'm communicating with a piece of company hardware that uses the RS485 protocol. I'm using an RS232 to RS485 converter device from B & B electronics.

I can send data just fine, and see it received on the other side. However, my data_received event NEVER fires, and even using BytesToRead I never see anything coming back.

ReadExisting comes up empty as well.

We fired up 232Analyzer, and I can send AND receive packets with that application. I'm assuming this has something to do with the .Net 2.0 serial class.

Any thoughts at all?

+1  A: 

The serial port code in 2.0 and 3.5 is known to be pretty flakey.

Cast around and you'll find a few known issues - perhaps this one matches your symptoms?

Jason Williams
+3  A: 

It turns out (after hours of researching and trying) that setting this:

.DtrEnable = True

did the trick. I've never had to use the DTR properties before, but whether it's an issue with this one device I'm working with, or something else I'm missing - that did it.

I thought this might save someone else a headache down the road.

Ducain
You may need ".RtsEnable = True" as well.
Austin Salonen
It is quite possible that the device did need to see DTR enabled. DTR (Data Terminal Ready) is often used for this purpose, as it informs any connected device that, well, it is ready! I wouldn't be surprised if the device itself is turning on the complemtary line to DTR, namely DSR (Data Set Ready) to inform what it is connected to that it itself is ready.
Andy