08-28-2017 10:56 AM - edited 08-30-2017 04:15 PM
Hello,
I'm going to state my issue in brief way. I receive data from Serial port by trapping number of characters ended with termination character. I expect 6 values arriving at different time intervals. I then transfer those 6 parameters using channel wires to another consumer loop for computation. So the producer loop sends data at different time intervals (upon data arrival).
My problem comes when I want to plot constant value on a chart (like zeros) until I receive incoming data. As I mentioned, I can not move plot to Producer loop as it will wait (hangs) for reception of incoming data at any time and won't move from current iteration until termination character is received.
So, just to simplify the issue, I created a simple example with no serial data reception which a sine is sent every 5 seconds while plot on consumer should plot zero every 100 ms until receiving new data. Could channel wires be configured in a way to allow loop of consumer to move on until new data arrives?
The difficulty is consumer loop should be faster than producer loop and hence a constant value is plotted until data arrives and sent from producer.
Solved! Go to Solution.
08-30-2017 09:39 PM
Since you're using a timed loop for the consumer loop you could probably wire a 0 timeout on the channel reader. Check the valid flag to see if you read any valid data and if not, plot a 0.
08-31-2017 05:46 AM
Thanks Jeff for your valuable response. I came by your presentation yesterday and applied your pattern. So you saved me twice
05-15-2020 12:48 PM
Good