tags:

views:

70

answers:

3

I currently have an embedded device connected to a PC through a serial port. I am having trouble with receiving data on the PC. When I use my PCI serial port card I am able to receive data right away (no delays). When I use my USB-To-Serial plug or the motherboards built in serial port I have to delay reading data (40ms for 32byte packets).

The only difference I can find between the hardware is the UART. The PCI card uses a 16650 and the plug/motherboard uses a standard 16550A. The PCI card is set to interrupt at 28 bytes and the plug is set to interrupt at 14 bytes.

I am connected at 56700 Baud (if this helps).

The delay becomes the majority of the duty cycle and really increases transfer time. (10min transfer vs 1 hour transfer).

Does anyone have an explanation for why I have to use a delay with the plug/motherboard? Can anyone suggest a possible solution to minimizing or removing this delay?

A: 

You'll probably find that different USB-Serial converters produce different results. We've found that the FTDI ones work well for talking with embedded devices. Some converters seem to buffer the data for a long time and/or fragment it.

I've never seen a problem with a motherboard connection - not sure what is going on there! Can you change the interrupt point for the motherboard serial port?

peter_mcc
Seconded on the serial/USB converters. I've seen many that work all day for ascii data but corrupt binary data at high (115,200) bit rates.
Nathon
The USB-Serial converter I am using is the Trendnet TU-S9 that uses a Prolific chip. The PCI card is a Sunix brand.
Matthew Alley
+1  A: 

Linux has an ASYNC_LOW_LATENCY flag for the serial driver that may help. Whatever driver you're using may have something similar.

However, latency shouldn't make a difference on a bulk transfer. It should add 40 ms at the very start of the transfer and that's it, which is why drivers don't worry about it in the first place. I would recommend refactoring your transfer protocol to use a sliding window protocol, with a window size of around 100 packets, if you are doing 32-byte packets at that baud rate and latency. In other words, you only want to stop transmitting if you haven't received an ACK for the packet you sent 100 packets ago.

Karl Bielefeldt
I increased the packet size from 32-bytes to 256-bytes and I only needed to increase the delay from 40ms to 65ms. This brought my communication time down from 1 hour to 14 minutes.
Matthew Alley
A: 

I have a serial to usb converter. When I hook it up to my breakout box and create a loopback I am able to send / receive at close to 1Mbps without problems. The serial port sends binary data that may be translated into ascii data.

Using .Net I set my software to fire an event on every byte (ReceivedBytesThreshold=1), though that doesn't mean it will.

dbasnett