07-27-2016 10:11 AM
Hi All,
Please see me attached code, where i am receiving serial data, converting it into a byte array and will be using a state machine to process it.
I am writing the data into an array and also displaying it via a string indicator. In order for the data to remain on the screen, I have used a feedback node. However, this means the data is appended everytime it is sent (at 10 second intervals). How can i get the data to remain on the screen when sent, and then be over written once new data is received, both in the indicator and the array??
Thanks,
Richard.
Solved! Go to Solution.
07-27-2016 10:35 AM
First, don't use bytes at port. You have enabled a termination character of a line feed, so rely on that. Just read a large number of bytes.
Second, in your code, put the concatenation and building of an array in a case structure. If the number of bytes read is zero, do nothing. If >0, then do the concatenation.
Third, check spelling. "Received" not "recieved".
07-27-2016 12:25 PM
Hi,
Thanks very much for your reply..
I dont fully understand the theory behind placing the concat strings + building array in a case structure? What will this achieve ?
Thanks,
Richard
07-27-2016 12:42 PM
Did you understand the bit about reading, say, 1000 characters? If you (a) specify Enable Termination Character (which you did), (b) specify the correct termination character for your device, and (c) have a "reasonable" Timeout (which you do), then if your expected VISA "message" is less than 1000 characters, you will "pause" in the VISA Read until the entire however-many-characters have been read, or no Termination Character was received (and nothing is returned).
Assume you got a legitimate String (read the Help to see how to tell if this is so). If so, you have ... a String. You can put it in a String indicator (no need for a feedback loop), and can use String to Byte Array to convert the entire String to Bytes. You'll then loop, waiting for the next VISA read to complete.
Bob Schor
07-27-2016 08:35 PM
Let's take a step back before we progress any further down this rabbit hole. What are you trying to communicate with and what is the protocol of the messages being sent back and forth? This does make a huge difference in how you should approach the problem.
07-28-2016 12:06 AM
07-28-2016 01:58 AM
Please ignore my spelling... it was early.
replies*
varying*
07-28-2016 02:29 AM
Okay this seems to be displaying as i would like, but i can't stop the program!!
help please.
thanks,
Richard.
07-28-2016 05:51 AM
Anyone konw how to get round this? I have tried a few more methods but cannot get ther result I need. As stated, the data is now being displayed as i would like i.e. updating each time it is sent. However, I cannot stop the loop as it seems to be stuck in the read state ?
once again help appreciated
07-28-2016 08:42 AM
Not sure what you are talking about here. There is no "read state". You have a while loop. Inside of that it does the reading. The way to stop the while loop is to press the stop button like you have it wired up.
So where are you stuck?