Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SerialPort Empty Transmissions

Status
Not open for further replies.

CodingHero

Programmer
Oct 26, 2009
1
US
I'm using the SerialPort class to help simplify communications between a PC GUI and an external embedded device I'm working on. My main form is subscribed to the data receive event (SerialDataReceived) of the SerialPort class so I can process messages asynchronously. I've noticed that I occasionally get a "zero length packet" even though I've set a minimum receive threshold of two bytes. Setup code is as follows:
Code:
mySerialPort = new SerialPort("COM1", 115200, Parity.None, 8, StopBits.One);
mySerialPort.DataReceived += new SerialDataReceivedEventHandler(mySerialPort_DataReceived);
mySerialPort.ReceivedBytesThreshold = 2;

I suppose this isn't an out-and-out problem, as I can just examine the BytesToRead property of the SerialPort and discard a zero length message, but does anyone know what would cause this to occur?

As some added information, my embedded device is actually connected via USB, but identifies as a virtual COM port using the usbser.sys driver that ships with Windows XP. Perhaps it's just a bug with that but I haven't seen anything searching Google to confirm or deny that.

Thanks in advance for any help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top