473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

serialport read buffer

Hello,

I added a serial-USB converter to my laptop, it appear as USB serial
port COM4, and I wrote an application to read 78k data from this port.
In my VC++ express code, I defined ReadBufferSize = 78k, and
ReceivedBytesThreashold = 78k so that I can get the whole data with
one ReadExisting() method when DataReceived event fires.

However, everytime the readbuffer only received 4096 bytes, but when I
test the same code with real serial port COM1, it received full 78k
data. There is no buffer configuration in driver of USB converter, and
it's impossible the converter has 4k limitation, this is confirmed
when I use hypertermial to capture the data, I got full 78k data too.

There must be something I don't know in .net or serialport class. Can
anyone tell me where I am wrong?

Thanks a lot!

Apr 22 '07 #1
4 4599

<ch******@yahoo.comwrote in message
news:11*********************@l77g2000hsb.googlegro ups.com...
Hello,

I added a serial-USB converter to my laptop, it appear as USB serial
port COM4, and I wrote an application to read 78k data from this port.
In my VC++ express code, I defined ReadBufferSize = 78k, and
ReceivedBytesThreashold = 78k so that I can get the whole data with
one ReadExisting() method when DataReceived event fires.

However, everytime the readbuffer only received 4096 bytes, but when I
test the same code with real serial port COM1, it received full 78k
data. There is no buffer configuration in driver of USB converter, and
it's impossible the converter has 4k limitation, this is confirmed
when I use hypertermial to capture the data, I got full 78k data too.
How does this prove the converter has no 4k limitation? Hyperterminal will
immediately call ReadFile again each time any data is received, until of
course the whole block is eventually received.

Have you used sysinternals (now part of Microsoft TechNet) portmon to
discover the actual call sequence?
>
There must be something I don't know in .net or serialport class. Can
anyone tell me where I am wrong?
I suspect BeginRead/EndRead would "work" more often. What happens is that
as soon as the PC becomes aware that data is received (one USB frame worth),
the DataReceived event fires. But you should always handle partial reads,
and issue a new read for the remaining data.
>
Thanks a lot!

May 3 '07 #2
I use these converters all the time, and as Ben surmised, the drivers (for
the ones I use, at least) are limited to 4096 bytes at a time. You'll have to
make multiple calls to read all 78 K.

"ch******@yahoo.com" wrote:
Hello,

I added a serial-USB converter to my laptop, it appear as USB serial
port COM4, and I wrote an application to read 78k data from this port.
In my VC++ express code, I defined ReadBufferSize = 78k, and
ReceivedBytesThreashold = 78k so that I can get the whole data with
one ReadExisting() method when DataReceived event fires.

However, everytime the readbuffer only received 4096 bytes, but when I
test the same code with real serial port COM1, it received full 78k
data. There is no buffer configuration in driver of USB converter, and
it's impossible the converter has 4k limitation, this is confirmed
when I use hypertermial to capture the data, I got full 78k data too.

There must be something I don't know in .net or serialport class. Can
anyone tell me where I am wrong?

Thanks a lot!

May 4 '07 #3
I was looking for confirmation of this 4096 byte limitation I'm having using
writefile on an open serial port connected to a bluetooth dongle and I saw
these posts .
Unfortunately turning the single write into multiple 4k writes introduces
some performance problems on the device I'm communicating with - there is a
big hit getting the i/o going . My tests show this isn't much of an issue if
the other device is a PC but not so with my bluetooth dip module . Sigh.
Also I will make note of the fact that you don't get an error , just a
reduced number of bytes written to signal you to the fact the behavior is
different than native serial port I/O .
Sigh.
"ch******@yahoo.com" wrote:
Hello,

I added a serial-USB converter to my laptop, it appear as USB serial
port COM4, and I wrote an application to read 78k data from this port.
In my VC++ express code, I defined ReadBufferSize = 78k, and
ReceivedBytesThreashold = 78k so that I can get the whole data with
one ReadExisting() method when DataReceived event fires.

However, everytime the readbuffer only received 4096 bytes, but when I
test the same code with real serial port COM1, it received full 78k
data. There is no buffer configuration in driver of USB converter, and
it's impossible the converter has 4k limitation, this is confirmed
when I use hypertermial to capture the data, I got full 78k data too.

There must be something I don't know in .net or serialport class. Can
anyone tell me where I am wrong?

Thanks a lot!

Jun 2 '07 #4

"chaz" <ch**@newsgroup.nospamwrote in message
news:DF**********************************@microsof t.com...
>I was looking for confirmation of this 4096 byte limitation I'm having
using
writefile on an open serial port connected to a bluetooth dongle and I saw
these posts .
Unfortunately turning the single write into multiple 4k writes introduces
some performance problems on the device I'm communicating with - there is
a
big hit getting the i/o going . My tests show this isn't much of an issue
if
the other device is a PC but not so with my bluetooth dip module . Sigh.
I would suggest getting a USB bluetooth dongle and take out the serial
conversion entirely. The maximum rate of bluetooth is much higher than
async serial typically reaches.
Also I will make note of the fact that you don't get an error , just a
reduced number of bytes written to signal you to the fact the behavior is
different than native serial port I/O .
That's true, and while it's more common dealing with sockets, any time you
do I/O you should be prepared that only part of your data was accepted and
you need to call again with the rest.
Sigh.
"ch******@yahoo.com" wrote:
>Hello,

I added a serial-USB converter to my laptop, it appear as USB serial
port COM4, and I wrote an application to read 78k data from this port.
In my VC++ express code, I defined ReadBufferSize = 78k, and
ReceivedBytesThreashold = 78k so that I can get the whole data with
one ReadExisting() method when DataReceived event fires.

However, everytime the readbuffer only received 4096 bytes, but when I
test the same code with real serial port COM1, it received full 78k
data. There is no buffer configuration in driver of USB converter, and
it's impossible the converter has 4k limitation, this is confirmed
when I use hypertermial to capture the data, I got full 78k data too.

There must be something I don't know in .net or serialport class. Can
anyone tell me where I am wrong?

Thanks a lot!


Jun 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: DraguVaso | last post by:
Hi, I'm experimenting with the Serial Port in VB.NET 2005. Although it isn't that easy to get any feedback from my COM-port as I thought it would be... How can I read all the Data that the...
2
by: Jan | last post by:
Hello there, I've got a strange problem using the readline method in vb2005 for reading the serial port. If I use the readchar method I can receive one character from serialport. This is the...
4
by: Ben Kim | last post by:
Hello all, Does anyone have an example on how to implement the new SerialPort Class in VB.NET? I have been able to create the class, send (.WriteLine) to the port and Read from the port but...
2
by: DJohnson | last post by:
Hello everyone, Please forgive me for my ignorance or lack of understanding on the following technology, as I am by no means an expert in serial IO. I am writing an application that communicates...
4
by: =?Utf-8?B?S3Jpc3RvZmZlciBQZXJzc29u?= | last post by:
Does anyone know if it's possible to get the Win32 handle to the serial port used under the hood in System.IO.SerialPort? The reason I want it is so I'd be able to make changes the DCB struct. I...
0
by: grappeggia | last post by:
Hi everybody, I`m doing a project in which a microcontroller realises an A/D conversion of 8 channels and send then to the computer using the USB, over one serialport interface. On the PC, I`m...
1
by: =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?= | last post by:
Hi, I communicate with a device using the .NET 2.0 serial port class. I am notified when some data are received by the event. If I read the buffer there is still the "old" data + the new data....
1
by: Pubs | last post by:
Hi, I am using the serial and I have a problem with the timeout. I am defining my array to fixed length and call the read function. I assumed that the function will not return data until it...
8
by: Kevin.M.Jonas | last post by:
I have the following method that handles the data received event: private void _port_DataReceived(object sender, SerialDataReceivedEventArgs e) { string data = _port.ReadExisting();...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.