04-29-2012 08:12 PM
Close but not maybe not close enough.
1).
In my code, the producer takes the data directly from the port and queues it, the only checking it does is for errors.
Your code does some protocol checking before passing it to a consumer loop. This string parsing may create overhead.
The drawback of my method is that you need controls to start/stop the Serial routine.
2). I can't tell, is your comms reading code in the same .VI as the consumer loop.
It is important that they are in different priorities.
In my case, I used a timed structure, but it is equaly valid to use a sub.vi with the execution priority changed to something higher than your consumer, I would recommend "Highest".
3). Why are you trying to read 4096 bytes? The normal practice is to pass the bytes at port value into the visa read.
[This may be a clever way to read more bytes if they arrived after the bytes at port request, But I cannot predict the functionality, it is possible that it is waiting for the buffer to be full before getting the data. Perhaps it is overflowing here, suggest that you halve it to 2048 and see if this helps. It is bad practice to let a buffer be full.]