473,407 Members | 2,629 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,407 software developers and data experts.

SerialPort Class too slow & CPU Hog?

Does anyone out there happen to have experience using VC# (or any .NET
really) to control the serial port for demanding use? My ultimate
goal would be to stream an arbitrarily large size (MB+) file out over
the serial port with zero down time at speeds ranging from 9600 to
480600 baud.

While using the SerialPort Control, I cannot come up with an
implimentation that doesn't A) hog the CPU at 100% and B) is able to
continually fill the TX buffer before it empties itself.

If anyone has done this, or even come close, I'd be very appreciative
of your help and suggestions. Thanks!

- Kevin
Dec 6 '07 #1
2 2605

"Kevin" <ke********@gmail.comwrote in message
news:89**********************************@n20g2000 hsh.googlegroups.com...
Does anyone out there happen to have experience using VC# (or any .NET
really) to control the serial port for demanding use? My ultimate
goal would be to stream an arbitrarily large size (MB+) file out over
the serial port with zero down time at speeds ranging from 9600 to
480600 baud.

While using the SerialPort Control, I cannot come up with an
implimentation that doesn't A) hog the CPU at 100% and B) is able to
continually fill the TX buffer before it empties itself.

If anyone has done this, or even come close, I'd be very appreciative
of your help and suggestions. Thanks!
I'm not doing large data transfer like that, but I'm managing ~8 UARTs
connected over USB with little or no CPU used at rates from 9600-115200
each. I found other problems with the BCL SerialPort class, so I wrote the
serial comm code against the Win32 API using overlapped I/O with ReadFileEx
and WriteFileEx.

Using OVERLAPPED operations, each write should complete when the data is
transferred completely into the kernel buffers (possibly into the UART FIFO)
and you can then post the next write operation. But that's complicated and
not easy to accomplish with p/invoke, I used C++/CLI to integrate .NET and
Win32.

Have you tried just dedicating a thread to a blocking write operation?
Something along the lines of always submitting a 16k chunk should work
really well, and be very CPU efficient.
>
- Kevin

Dec 6 '07 #2
<qoute>
Have you tried just dedicating a thread to a blocking write
operation?
</quote>

I tried a little while back, but it didn't work. After your
suggestion, I re-evaluated my approach, found I wasn't really doing
the processing in the dedicated thread. After fixing it, I think its
working and the dedicated thread did the trick! Thanks a bunch,

- Kevin
On Dec 6, 12:11 pm, "Ben Voigt [C++ MVP]" <r...@nospam.nospamwrote:
"Kevin" <kevinwo...@gmail.comwrote in message

news:89**********************************@n20g2000 hsh.googlegroups.com...
Does anyone out there happen to have experience using VC# (or any .NET
really) to control the serial port for demanding use? My ultimate
goal would be to stream an arbitrarily large size (MB+) file out over
the serial port with zero down time at speeds ranging from 9600 to
480600 baud.
While using the SerialPort Control, I cannot come up with an
implimentation that doesn't A) hog the CPU at 100% and B) is able to
continually fill the TX buffer before it empties itself.
If anyone has done this, or even come close, I'd be very appreciative
of your help and suggestions. Thanks!

I'm not doing large data transfer like that, but I'm managing ~8 UARTs
connected over USB with little or no CPU used at rates from 9600-115200
each. I found other problems with the BCL SerialPort class, so I wrote the
serial comm code against the Win32 API using overlapped I/O with ReadFileEx
and WriteFileEx.

Using OVERLAPPED operations, each write should complete when the data is
transferred completely into the kernel buffers (possibly into the UART FIFO)
and you can then post the next write operation. But that's complicated and
not easy to accomplish with p/invoke, I used C++/CLI to integrate .NET and
Win32.

Have you tried just dedicating a thread to a blocking write operation?
Something along the lines of always submitting a 16k chunk should work
really well, and be very CPU efficient.


- Kevin- Hide quoted text -

- Show quoted text -
Dec 7 '07 #3

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

Similar topics

4
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...
1
by: Richie Carey | last post by:
Here's my problem. I'm using Visual C# 2005 Express for a small project that requires simple AT modem commands to be sent to an external serial device. The device requires 2400 baud, no parity,...
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...
5
by: herbert | last post by:
back in 1978 (!) the VAX/VMS serial line driver offered everything a developer needs to develop protocols of all kinds: - read x bytes - read to end of line - read to special character - read...
2
by: Jay | last post by:
Extracted from the C# example in http://msdn2.microsoft.com/en-us/library/s14dyf47.aspx... public static void Main() { string name; string message; StringComparer stringComparer =...
0
by: nmsreddi | last post by:
Hi friends I am working on serialport in c# ,i am using C#2005 i have successfully done the serial communication with GSM modem and able to send and receive data , the main problem ,the serial...
2
by: Kevin | last post by:
Does anyone out there happen to have experience using VC# (or any .NET really) to control the serial port for demanding use? My ultimate goal would be to stream an arbitrarily large size (MB+)...
10
by: sklett | last post by:
I'm trying to send some printer commands (ZPLII) to an attached USB printer using the SerialPort component. I didn't get very far at all. In fact I haven't gotten anywhere. The first problem I...
0
by: cronusf | last post by:
I set up two virtual COM ports 3 and 4 using com0com. I tried to test it with the following program. However, the DataReceived event handlers never get called. Can anyone with SerialPort class...
9
by: jensa | last post by:
Hi, I am currently writing a simple form application in C# that uses the SerialPort class (C# 3.5). But I have put my head in the wall several times to solve a simple problem. I have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.