2

I'm reading from a COM port at a high speed (3,686,400 b/sec). In order to accomplish this I have to read with 512-byte blocks and significantly increase my timeout (to 1000) so that I'll get a whole block each time and not pieces of it even though I'm reading synchronously.

The problem: after a few minutes of running and plotting the results just fine, I'm getting corrupted information. Meaning I still don't get the info at the pace I want it to be, but significantly delayed.

This specifically happens when I'm loading more on the software like running a recording thread that writes the data to a file. The resulting file is a much shorter file than expected, even though not corrupted (its like I'm getting the beginning of the transmitted data and not all of it).

I know its not the sending device since reloading the PC application while the device still sends data reinitialized the whole thing.

If it matters, I'm using windows 7, Intel core i3, 64-bit. Writing in C code in CVI. Reading COM port using Windows API.

Any suggestions?

Thank you

Carey Gregory
  • 6,836
  • 2
  • 26
  • 47
BioSP
  • 518
  • 4
  • 15
  • It sounds like you're so close to performance limits that a second thread is causing you to miss a block of data. I would try boosting your read thread's priority. – Carey Gregory May 19 '13 at 20:01
  • Thank you Carey. I will try to run it on other computers, to see if this indeed a performance limit problem. – BioSP May 20 '13 at 06:43
  • Trying to run a serial port at that speed in a commodity PC without a realtime RTOS seems unreasonable. Seriously, if you need that kind of data rate you should be using USB, ethernet, SPI, etc. – TJD May 20 '13 at 15:18
  • Yes, I understand there are faster ways to communicate, but this i what I've got, and I need to get this as optimal as I can. – BioSP May 23 '13 at 14:14
  • You can get a USB to serial converter, I don't know if they perform better for reading from serial, but it might be worth a try. – Perkins May 23 '13 at 20:06
  • @Perkins what will be the difference regarding computer interface? Isn't it still requires reading from a comport? Or are there other methods to read from serial? – BioSP May 25 '13 at 22:10
  • I am not certain about the windows API with regards to it, but I think it will show up as a standard com device. From a hardware point of view, the speed the interface can manage is higher, so you shouldn't run into problems with the computer being too slow to keep up with the device on the end. – Perkins May 27 '13 at 23:19
  • That's an interesting thought, I will give it a try. Thanks. – BioSP May 28 '13 at 20:36

0 Answers0