LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Operating system causes loss of data during writing to file continuously

Within a while loop I read data from serial port (9,5KByte/sec, bluetooth dongle via serial port protocol) and writes them to a file (text-file) continuously. The operating system interrupts the while loop periodically which causes a loss of data. If I read data from serial port without saving them no data get lost.
E.g. on my PC the OS (W2K) wakes up a second hard disk exactly once per hour which freezes the data saving process to the 'saving' hard disk (and therefore also the while loop, data reading) for about 5-6 sec. On a Laptop the OS (XP, one single hard disk) interrupts the data saving process every 10 minutes for about 1 sec. during the first hour and not any longer afterwards.
I have al
so tried to use the 'deny read/write' option of the 'Open File.vi' to prevent other file sweeping applications (backup, anti-virus, Fast Find) to open the file simultaneously which could temporarily deny you write access to the file - no success.
BTW, this concerns also the compiled version of my LV7.1-program.
Any suggestions?

Thanks,
Tobi
0 Kudos
Message 1 of 2
(2,218 Views)
Use two loops, one for reading the serial data and a separate one for writng to the file. The first loop reads the serial port and writes the data to a queue. The second one reads the queue and writes to the file. Put a delay in each loop, perhaps zero milliseconds in the serial loop and 10 ms in the file loop (try various values). This causes the LV scheduler to share CPU time between the two loops.

Now the serial loop will acquire the data and store it in the queue which also serves as a buffer. If the file loop gets blocked by the OS, the data just stacks up in the queue.

Lynn
0 Kudos
Message 2 of 2
(2,218 Views)