Serial port timeout and file transfer data corruption

I have developed a UART driver on Win XP using WDF. I use the following timeouts for my UART driver.

ReadIntervalTimeout = 100;
ReadTotalTimeoutConstant = 100;
ReadTotalTimeoutMultiplier = 0;
WriteTotalTimeoutConstant = 0;
WriteTotalTimeoutMultiplier = 0;

My driver has two parts a Transmit and a recieve part. The transmit part runs in an i7 Quad code desktop and the
recieve part runs in an Pentium D machine.I am using FTDI USB-ser convertor.

When i transmit a file at 460800 baud, 8 bits, Even, 1 stop bit, No Hardware flow ctrl. I can transfer a 5 MB file and the file is recieved without any corruption. When i increase the baud rate to 961200 baud and try the same test, the recieved file is corrupt(i.e. few bytes are missing in the recieved file).

Even if i increase the ReadIntervalTimeout timeout and ReadTotalTimeoutConstant to 500 ms, the corruption happens at 961200 baud.

If i reverse the setup i.e. RX part on i7 machine and the TX part on Pentium D machine. The same logic transfers the file and is recieved without any problems.

I am trying to understand. how to choose a time out value that can work on a variety of machines.I cannot have a large timeout of 1 second as it will degrade the data transfer performance of my driver.

Regards,
Raja

A serial link is not considered ‘reliable’ and traditionally has required
some sort of framing, error detection, and recovery protocol be layered on
it to achieve reliable communication.

You may well indeed find a set of values that works once. Or most of the
time for your particular setup. But if the system load changes or different
systems are used then you are right back to failed operation and/or reduced
performance.

I suggest you go have a look at some [very old!] serial line protocols like
Z-Modem if you really are trying to perform ‘file transfers’ or the async
framing layer of PPP or [my favorite] DDCMP for inspiration on how to
perform framing, error detection, error recovery, and even transparency on
serial links.

Good Luck,
Dave Cattley

No x- or y-modem for you? Jeez, I used to remember all of the protocols that my Hayes 2400 baud modem supported (on my Atari 520ST :stuck_out_tongue: )

d

debt from my phone


From: David R. Cattley
Sent: 6/11/2012 4:38 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Serial port timeout and file transfer data corruption

A serial link is not considered ‘reliable’ and traditionally has required
some sort of framing, error detection, and recovery protocol be layered on
it to achieve reliable communication.

You may well indeed find a set of values that works once. Or most of the
time for your particular setup. But if the system load changes or different
systems are used then you are right back to failed operation and/or reduced
performance.

I suggest you go have a look at some [very old!] serial line protocols like
Z-Modem if you really are trying to perform ‘file transfers’ or the async
framing layer of PPP or [my favorite] DDCMP for inspiration on how to
perform framing, error detection, error recovery, and even transparency on
serial links.

Good Luck,
Dave Cattley


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Oh sure. X/Y/Z, kermit, MNC (did that become V.42?) throw them all in.
that problem has been solved (and re-solved) at least a dozen times :slight_smile: Cheers,Dave Cattley From: xxxxx@microsoft.com
To: xxxxx@lists.osr.com
Subject: RE: [ntdev] Serial port timeout and file transfer data corruption
Date: Mon, 11 Jun 2012 14:34:11 +0000

No x- or y-modem for you? Jeez, I used to remember all of the protocols that my Hayes 2400 baud modem supported (on my Atari 520ST :stuck_out_tongue: )

d

debt from my phone

From:
David R. Cattley

Sent:
6/11/2012 4:38 AM

To:
Windows System Software Devs Interest List

Subject:
RE: [ntdev] Serial port timeout and file transfer data corruption

A serial link is not considered ‘reliable’ and traditionally has required

some sort of framing, error detection, and recovery protocol be layered on

it to achieve reliable communication.

You may well indeed find a set of values that works once. Or most of the

time for your particular setup. But if the system load changes or different

systems are used then you are right back to failed operation and/or reduced

performance.

I suggest you go have a look at some [very old!] serial line protocols like

Z-Modem if you really are trying to perform ‘file transfers’ or the async

framing layer of PPP or [my favorite] DDCMP for inspiration on how to

perform framing, error detection, error recovery, and even transparency on

serial links.

Good Luck,

Dave Cattley


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:

http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:

http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Raja K wrote:

I am trying to understand. how to choose a time out value
that can work on a variety of machines.I cannot have a large
timeout of 1 second as it will degrade the data transfer
performance of my driver.

Why does the correctness of the file transfer depend on the timeout values at all? That’s the real question.

I would just set the interval and multiplier timeouts to MAXDWORD and the total timeout to some number like 1000. Then just read continually from the port with ReadFile(). Then you’re guaranteed to get everything as soon it arrives.