SerialPort Buffer woes...

G

Guest

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 to a custom hardware device
that requires a 4 byte message to be sent every 500ms to keep it alive.

I have used VB6 to create a prototype application that works fine (using the
MSComm activex control) to send the 4 bytes of data at a 500ms timer interval.

when trying to port it into VS2005 C# leveraging the SerialPort Class, usign
all of the same port properties, it does not work..

so what I did is get a port sniffer and ran it on the vb6 app and notice
that the data is sent at regular intervals(500ms), when running it with the
VS2005 C# version it seems to buffer all writes then release them all at
once(I thought it may be because of the write buffer)so I tried changing the
Write Buffer to be smaller, no luck.

I think what I need to do is perform async writes(to get the non buffered
output) will that get rid of the lag? and is that even possible with the
SerialPort Class?
I notice a flush() method in the base stream property, but it does not seem
to do anything to help it..

I have searched all over the net for samples, and dont find anything that
addresses this effect.

any Suggestions or samples (to provide realtime/non-buffered output to the
serial port) would be greatly apreciated...going on 2 days now...arg
 
D

Dick Grier

Hi,

You don't say, specifically, how you are pacing the data to be sent. Did
you use a Timer control? This is the easy way, and (AFAIK) it will work
fine.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004.
See www.hardandsoftware.net for details and contact information.
 
L

Lloyd Dupont

What kind of stream do you use?
That might be the problem!

Anyway Flush() is the function which would force sending data if they are
buffered, so that should really fix your problem, that's weird...
To better understand what's going on use the Reflector tool from:
http://www.aisto.com/roeder/dotnet/


--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
 

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