Search code examples
windows-7serial-portwindows-7-x64usbserialftdi

Does serial port buffer behave differently under Windows 7 x64 vs x32


After switching to Windows 7 x64 the weight indicator device connected to a serial port started to behave differently than in Windows 7 x32.

It seems that timing of read operations or read buffer behavior is little different.

I am monitoring the output on serial port COM2 with SerialWatcher and get different results:

Under x64 it shows:

 0029484       00 11<CR><LF>z0011807       00 11<CR><LF>
 0029489       00 11<CR><LF> 0029486       00 11<CR>
<LF> 0029485       00 11<CR><LF> 0029485      
 00 11<CR><LF> 0029486       00 11<CR><LF> 002948
5       00 11<CR><LF> 0029487       00 11<CR><LF>
 0029487       00 11<CR><LF> 0029488       00 11<CR><LF>
 0029486       00 11<CR><LF> 0029486       00 11<CR><LF>
 0029485       00 11<CR><LF> 0029486       00 11<CR><LF>

Under x32 it shows:

 0029910       20 11<CR><LF> 0029911       20 11<CR><LF>
 0029912       20 11<CR><LF> 0029913       20 11<CR><LF>
 0029910       20 11<CR><LF> 0029910       20 11<CR><LF>
 0029910       20 11<CR><LF> 0029911       20 11<CR><LF>
 0029911       20 11<CR><LF>z0012057       20 11<CR><LF>
 0029912       20 11<CR><LF> 0029910       20 11<CR><LF>
 0029912       20 11<CR><LF> 0029910       20 11<CR><LF>
 0029912       20 11<CR><LF> 0029911       20 11<CR><LF>
 0029909       20 11<CR><LF> 0029910       20 11<CR><LF>
 0029910       20 11<CR><LF> 0029909       20 11<CR><LF>

The size of incoming data chunks tends to be more irregular on Windows x64 with this particular weight indicator device.

I am aware that this can be easily fixed on application level with waiting for complete data to come to the read buffer and then process it correctly but this serial port data are being currently processed by a 3rd party application that I cannot modify.

I am using FTDI USB serial converter:

settings

Is there some system setting in Windows that could fix that? Also we have very similar problem with another weight indicator connected directly to COM port on motherboard. Thanks for any suggestions.


Solution

  • This is entirely normal, the amount of data you get in each call is timing sensitive. The faster the program runs, the fewer bytes it gets for each ReadFile() call. Getting 1 or 2 is normal, serial ports are slow.

    Devices often send extra bytes to help programs figure out when they got the complete response. This scale does as well, just keep collecting bytes/chars until you get \r\n. Don't be thrown off by extra line breaks added by a debugging tool. If you'd use, say, the .NET SerialPort class then you'd fix it simply by using its ReadLine() method.