Trishaa 0 Newbie Poster

Hi,
I have data streaming in through a com port, 3 bytes at 25ms interval with a change in CTS signifying the start of data sequence.
Using the OnComm() event and checking for CommEvent 3 and InBufferCount > 0, I am able to receive the data and store it in 3 Arrays. I am using a timer which fires every 30 ms to graph the data I have in the Arrays in realtime.

My problem is that I notice a random corruption of data in the buffers (visually looking at the plot) when I am using the timer. However, if I acquire the data first without enabling the Timer and then graph it from the Arrays there is no corruption of the data.

I did this by collecting values for a certain time period using OnComm() and then writing it to a file. I then restart the program with changes to fill the Arrays with the previously acquired data from the file and then plot it using the timer. Why is this corruption happening when the timer runs along with mscomm. How do I make mscomm event of the highest priority so that the Data integrity is maintained.

How can I maintain the integrity of the data and also graph it close to real time? Should I use Mscomm in polled mode.?
Thanks for helping me

Regards, Trisha

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.