Author Topic: Virtual Com Port Garbage Characters  (Read 10960 times)

blockard

  • Member
  • ***
  • Posts: 2
Virtual Com Port Garbage Characters
« on: May 11, 2011, 12:16:15 pm »
Hi-
I'm new to the forum, and I've been trying to work with a virtual com port using the standard Windows driver (USBser.sys).  I'm using home-grown hardware at our company that takes an existing serial stream(at 115200) and converts it to USB.  The problem I am running into is that my data stream will get extra Null characters in it when reading from the vcp on the PC side.  We have a USB analyzer, and the USB data stream from the device to the PC does not have the extra null characters.

Connecting to the same serial device through a Digi serial port expansion card (www.digi.com) works w/o issue.

So my two questions are:
1)Has anyone else run into this or heard about it?
2)I've seen several people outside of these forums complain about the quality of USBser.sys, but other than the KB article listed on http://www.lvr.com/serport.htm#usb_virtual_com_ports , I have not seen any actual problems listed.  Are there any other known issues with USBser.sys??

A side note:
I've tried an off the shelf FTDI solution, and it had issues as well.  It seemed to have dropped characters, even though hardware handshake was turned on.  I tried several different settings in the FTDI driver, but was not able to resolve the dropped character issue.

Thanks in Advance-
Brad

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Virtual Com Port Garbage Characters
« Reply #1 on: May 14, 2011, 12:04:47 pm »
The data is transferring correctly, but the driver is inserting null characters?

For the FTDI chip, see this if you haven't yet:

http://www.ftdichip.com/Support/Documents/AppNotes/AN232B-04_DataLatencyFlow.pdf

Jan

blockard

  • Member
  • ***
  • Posts: 2
Re: Virtual Com Port Garbage Characters
« Reply #2 on: August 05, 2011, 11:24:57 am »
We ended up finding out that our lower level serial driver that was sitting on top of the Virtual Com port was waking up from WaitCommEvent() even though we had set the Comm Mask to only wake up when new characters where in the RX buffer.  We weren't double checking that there were actually new bytes.  I still think WaitCommEvent() shouldn't be waking the thread up until new data arrives, but that's an issue we can "fix".  Once that has been fixed we now are having the problem where occasionally single byte transfers aren't showing up in the RX buffer, until another byte is transferred.  We have verified that the byte is travelling across the USB interface, but it doesn't seem to show up when reading the port until after another byte is transferred.  I'm beginning to wonder if the WaitCommEvent isn't waking up like it should.

I think this all may be related to the issue with WaitCommEvent, does anyone know of any troubles when setting up a Com event that only wakes on Receiving new characters?  We are currently only waiting on EV_RXCHAR, are there other events we should be waiting on?

The low level driver seems to work fine when using actual physical serial ports, we only seem to have these issues when we use the USB virtual com port.

Here's a little snippet of how the com port is being setup for reference:

sprintf(temp, "\\\\.\\COM%d", port);

idComDev = CreateFile(temp, GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);

if (idComDev != (HANDLE)-1)
{
   SetCommMask(idComDev, EV_RXCHAR);
    ...
}
And this is how we wait on it:
dwEvtMask = 0;
dwRVal = WaitCommEvent(idComDev, &dwEvtMask, NULL);

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Virtual Com Port Garbage Characters
« Reply #3 on: August 05, 2011, 01:17:48 pm »
You might find this of interest:

http://www.cygnal.org/ubb/Forum9/HTML/001884.html

Jan