473,397 Members | 1,969 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,397 software developers and data experts.

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::Ports::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 4528
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_grierNOSPAM@.msn.comwrote in message
news:#d**************@TK2MSFTNGP05.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.comwrote in message
news:26**********************************@microsof t.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_grierNOSPAM@.msn.comwrote in message
news:#d**************@TK2MSFTNGP05.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_grierNOSPAM@.msn.comwrote in message
news:uT**************@TK2MSFTNGP05.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
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:...
0
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?). ...
3
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...
0
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...
0
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. ...
0
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....
1
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...
3
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...
2
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;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.