LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite byte array

Solved!
Go to solution

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.

0 Kudos
Message 1 of 20
(4,499 Views)

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".

0 Kudos
Message 2 of 20
(4,486 Views)

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

0 Kudos
Message 3 of 20
(4,455 Views)

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

0 Kudos
Message 4 of 20
(4,449 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 20
(4,429 Views)
Thanks for the repays so far everyone!!

I'm communicating with a power supply unit which sends out a very basic stream of data (consisting of mainly flags). It's a burst of data which occurs at 10 second intervals consisting of one start bit, one stop bit and a varie data length between.. Usually 8 bits. It's all in house protocol which has been used for years
0 Kudos
Message 6 of 20
(4,420 Views)

Please ignore my spelling... it was early.

 

replies*

 

varying*

0 Kudos
Message 7 of 20
(4,409 Views)

Okay this seems to be displaying as i would like, but i can't stop the program!!

 

help please. 

 

thanks,

 

Richard.

0 Kudos
Message 8 of 20
(4,404 Views)

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

0 Kudos
Message 9 of 20
(4,397 Views)

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?

0 Kudos
Message 10 of 20
(4,390 Views)