SerialPort problem - part 3

S

Simon

Hello All,

I have finally found the cause to my problems. SerialPort will fire data
received event only when 0x1B character is received. Than all received data
together with this 0x1B character will be displayed.

How can I convince SerialPort to fire event on any character and not only on
0x1B character?

Thank you for your help,

Simon


PS: I have tested a number of .NET terminal samples and there is no sample
that would work. On the other hand HyperTerminal and all other Windows
terminal applications work (I get character by character).
 
S

Steven Cheng[MSFT]

Hi Simon,

As for the serial port programming you mentioned, are you using the .NET
2.0 SerialPort class?

Per the document, this event is not garanteed to raise on every byte
received:

=========
The DataReceived event is not gauranteed to be raised for every byte
received. Use the BytesToRead property to determine how much data is left
to be read in the buffer.
===========

#SerialPort..::.DataReceived Event
http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.datarece
ived.aspx

For your scenario, maybe you should consider use a background thread to
always check the received buffer length and determine whether to read or
not.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
 
S

Simon

Hello Steven,

I am using the .NET 2.0 and I am running Vista 64 bit.

It is strange because:
- I have tested the same sample on Windows XP and is running
- only 0x1B character would generate event

I have tried the sample from MSDN NETSerialComm and it is working. On the
other hand this library is big and not so straightforward as SerialPort
class that is a part of .NET library (no events, and implemented all sort of
controls that are usually not needed). My suggestion would be that Microsoft
should provide equivalent class that will be similar to SerialPort class and
will work.

I have already implemented separate thread and program is working. But this
is not good enough, because sometimes you also need to track time when
character is received (and there is some delay inside this thread).

Best regards

Simon
 
S

Steven Cheng[MSFT]

Thanks for your reply Simon,

Yes, I can understand your concern. As the existing SerialPort class is the
first one added in .net framework, it much has many things to improve. As
always, we appreciate your feedback and welcome to submit them to the
product feedback center:

#Visual Studio and .NET Framework
http://connect.microsoft.com/feedback/default.aspx?SiteID=210

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: "Simon" <[email protected]>
Subject: Re: SerialPort problem - part 3
Date: Thu, 14 Feb 2008 21:03:21 +0100
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top