473,699 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SerialPort hardware handshaking problem (not the usual one)

Hi

I am using SerialPort component to send raw binary files to a remote device
with RTS/CTS handshaking - the remote device has a small receive buffer and
is slow so needs to be hardware flow controlled to prevent the PC sending
too much data per second. Here is my attempt at setting the hardware
handshake operation:

serialPort1->Handshake = System::IO::Por ts::Handshake:: RequestToSend;
serialPort1->RtsEnable = true;

However the port outputs data at max rate with data loss at the receiving
end.

Using Hyperterminal with the appropriate settings on the same COM port works
perfectly so I assume its my code that is missing something - any help would
be appreciated.

I am using Visual Studio 2008 Express on WinXP and have TI UART chipset on
the COM port.

Cheers
Steve
Jun 27 '08 #1
6 4552
Hi,

Your application fills the UART Tx FIFO (16 bytes) much faster than your
fingers (HyperTerminal) . The communications driver only responds to
lowering CTS in filling the FIFO -- anthing already in the FIFO will be sent
regardless of CTS state.

So, what you have to do is to break your send data into "chunks" of less
than 16 bytes, and put an adjustable delay between sending each "chunk." I
suggest that you try (say), 8 bytes at a time, and start with a delay of
(say) 10 mS between each chunk. Reduce this delay until things fail (or
increase it), then you know what works and what doesn't. Add a little
"slop" for safety.

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, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Jun 27 '08 #2
A couple of things I should have mentioned, I am using the TI chipset UART
which does single byte hardware handshaking and I am using the Hyperterminal
send text file (which sends binary no bother also). Hyperterminal correctly
sends data at about continuous 8kBytes/s being the max receive capability of
the serial device (and with 100% integrity) but my SerialPort program
squirts data out at about 10.5kBytes/s being the max rate at 115200 baud. So
I am sure that the PC configuration is capable of doing this hardware
handshaking ok - just my VSC++.NET programming knowledge that is lacking...

Still looking for a SerialPort hardware handshake configuration.

Cheers
Steve

"Dick Grier" <dick_grierNOSP AM@.msn.comwrot e in message
news:#d******** ******@TK2MSFTN GP05.phx.gbl...
Hi,

Your application fills the UART Tx FIFO (16 bytes) much faster than your
fingers (HyperTerminal) . The communications driver only responds to
lowering CTS in filling the FIFO -- anthing already in the FIFO will be
sent regardless of CTS state.

So, what you have to do is to break your send data into "chunks" of less
than 16 bytes, and put an adjustable delay between sending each "chunk."
I suggest that you try (say), 8 bytes at a time, and start with a delay of
(say) 10 mS between each chunk. Reduce this delay until things fail (or
increase it), then you know what works and what doesn't. Add a little
"slop" for safety.

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, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Jun 27 '08 #3
Ach this is a stupid non-issue after all

The serial driver seems to get itself into state where hyperterminal still
functions but my .NET app doesnt - reboot PC solves problem - hardware
handshaking works all round. Still confused why the port gets into this
state but when it does all I need do is reboot...

"Steve Mowbray" <st***********@ hotmail.comwrot e in message
news:26******** *************** ***********@mic rosoft.com...
A couple of things I should have mentioned, I am using the TI chipset UART
which does single byte hardware handshaking and I am using the
Hyperterminal send text file (which sends binary no bother also).
Hyperterminal correctly sends data at about continuous 8kBytes/s being the
max receive capability of the serial device (and with 100% integrity) but
my SerialPort program squirts data out at about 10.5kBytes/s being the max
rate at 115200 baud. So I am sure that the PC configuration is capable of
doing this hardware handshaking ok - just my VSC++.NET programming
knowledge that is lacking...

Still looking for a SerialPort hardware handshake configuration.

Cheers
Steve

"Dick Grier" <dick_grierNOSP AM@.msn.comwrot e in message
news:#d******** ******@TK2MSFTN GP05.phx.gbl...
>Hi,

Your application fills the UART Tx FIFO (16 bytes) much faster than your
fingers (HyperTerminal) . The communications driver only responds to
lowering CTS in filling the FIFO -- anthing already in the FIFO will be
sent regardless of CTS state.

So, what you have to do is to break your send data into "chunks" of less
than 16 bytes, and put an adjustable delay between sending each "chunk."
I suggest that you try (say), 8 bytes at a time, and start with a delay
of (say) 10 mS between each chunk. Reduce this delay until things fail
(or increase it), then you know what works and what doesn't. Add a
little "slop" for safety.

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, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Jun 27 '08 #4
Hi,

I have no real idea. The serial driver use is identical. HyperTerminal
uses a different API to access that driver than the serial port. Still, I
have my doubts about the implementation of the driver itself. Manufacturers
are do not always implement all features of the hardware (though, someone
like Quatech or other responsible manufacturer should).

If I were to guess, I'd speculate that, somehow, the standard serial driver
is being used when you have trouble, and the specialized one is being used
after reboot. What might cause such a thing is beyond my ken.

Still, character pacing should work. I've found it to be necessary with a
number of devices, and (at the end of the day), the performance is about as
good as if everything else worked "as designed," instead of "as
experienced."

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, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Jun 27 '08 #5
aye - who knows - getting too used to these Win32 driver peculiarities
unfortunately.

My application might not work across the board on every PC - but I already
guessed that since I was relying on the TI chipset feature of RTS working
per byte rather than per 16 byte burst although I was hoping that modern
motherboards would have improved UART chipsets and hoping even more that
decent USB-serial convertors will do the same trick. BTW the connected
serial device is slow and only has a 1 byte receive buffer hence the
difficulties.

Thanks for your suggestions - I might fall back on the software rate control
method you mentioned if I run into more trouble.
Cheers
Steve
"Dick Grier" <dick_grierNOSP AM@.msn.comwrot e in message
news:uT******** ******@TK2MSFTN GP05.phx.gbl...
Hi,

I have no real idea. The serial driver use is identical. HyperTerminal
uses a different API to access that driver than the serial port. Still, I
have my doubts about the implementation of the driver itself.
Manufacturers are do not always implement all features of the hardware
(though, someone like Quatech or other responsible manufacturer should).

If I were to guess, I'd speculate that, somehow, the standard serial
driver is being used when you have trouble, and the specialized one is
being used after reboot. What might cause such a thing is beyond my ken.

Still, character pacing should work. I've found it to be necessary with a
number of devices, and (at the end of the day), the performance is about
as good as if everything else worked "as designed," instead of "as
experienced."

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, Revised March
2006.
See www.hardandsoftware.net for details and contact information.

Jun 27 '08 #6
Hi,

It is quite unlikely that manufacturers will use the more expensive UARTs in
their designs. The require a specialized serial driver, and cost is
EVERYTHING. 99.9% of all users would never notice.

BTW, about 40% of computers, these days, are notebook-class. Thus, they use
USB serial adapters. The serial port "end," (AFAIK) does not support
byte-by-byte handshaking, and the FIFOs iin the Virtual Serial Port
(software UART) tend to be about 98 bytes.

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, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Jun 27 '08 #7

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

Similar topics

0
3326
by: Carlo Filippini | last post by:
Hi I am trying to control my mobile from my WinXP machine. The mobile is connected through USB which is mapped on COM 5. With Hyperterminal everything looks good. But when I try: --------------------------------------------------------------- use Win32::SerialPort qw( :STAT 0.19 ); $ob = new Win32::SerialPort ('COM5') || die "Can't open COM5: $^E\n";
0
8491
by: Joshua Moore | last post by:
I'm trying to convert from a lot of invoked code to c# 2.0 SerialPort code. I can't find a way to set fOutxCtsFlow to true (maybe CTSEnable?) and fRtsControl = RTS_CONTROL_HANDSHAKE (RtsEnable?). Also, do I need to set the handshaking? Below is the old and attempted new (that continually gets a timeout error on read. I upped the read timeout, but it's way too long NOT for it to be a handshaking or other issue than the readtimeout...
3
1784
by: Eric | last post by:
Hi, In my application for PDA I use the serialport class to send data to a navigation computer of VDO Dayton. Everything works fine as long as it is connected to the nav-computer. When the nav-computer is not connected to the PDA, the program hangs. No exceptionerrors, no serialports error events, nothing. Even if I set the WriteTimeOut property to 500, I still don't get any messages.
0
1390
by: Audio_Developer | last post by:
Hello, I have a problem with the SerialPort Control under VC# Express 2005. In my application I have to read data from an external device through RS 232. The process is built on a software-based handshaking which depends on the device. The process has been implemented by me and works but unfortunately only the first time. All data are donwloaded successfully as required.
0
969
by: Jason James | last post by:
Hi, I am trying to write a VB.Net app using .net v2 which has its own serial port control. All is going OK but the embedded device that I am trying to communicate uses XON/XOFF handshaking. The control has a property for handshaking that supports XON/XOFF. Does anyone know if the control will handle all the flow control for XON/XOFF or do I need to control things by looking for the XON(17) and XOFF(19) in the DataReceived method of...
0
947
by: nmsreddi | last post by:
Hi Friends I am using c#2005 ,for serial communication i think the control in toolbox (serialport ) is not needed for sending and reeiving data through rs232 just io.ports name space enough. my dout is exactly what for the serialportcontrol is given particularly is any one using that control please give some information regarding that
1
404
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi Everyone, How can I set the serial port Timeout to Off using C# (please see the following)? Thanks. Baud: 9600 Parity: None Data Bits: 8 Stop Bits: 2 Timeout: ON //I want this to be Off
3
10551
by: arjan321 | last post by:
Hello all, I have a strange problem with the .NET serialPort class. When I write some data to the serialport, not all the data is immediately send: every once in a while, only ~50 characters of the 64 characters I'm sending gets send. Then, when I do a write() again, the data gets send. This is unacceptable behavior for my program.
2
3799
by: Sam T | last post by:
Delving into SCPI commands and DTR/DSR communications. I have worked my problem down to some nuance. I am using C# Express 08 on Win XPSP2. My code does this: { create, set, and open serialport; // nothing fancy SP.WriteLine("APPL?"); SP.DtrEnable = true; somestring = SP.ReadExisting(); }
0
9184
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9042
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7759
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5878
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4634
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2357
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.