07-23-2017 06:28 AM
I am trying to read an array of string using the code as attached. I have an error with "scan from string" block every time I run the program. you can find sample of my data to be sent by my hardware to Labview as below
D10112.31D10212.31D10312.31D10412.31D10512.31D10612.31D10712.31\r\n
07-23-2017 10:56 AM - edited 07-23-2017 11:01 AM
@Zahran88 wrote:
I am trying to read an array of string using the code as attached. I have an error with "scan from string" block every time I run the program. you can find sample of my data to be sent by my hardware to Labview as below
D10112.31D10212.31D10312.31D10412.31D10512.31D10612.31D10712.31\r\n
Your code depends on the whole message being read at once, which I can guarantee you isn't happening the way you set up the serial read. I wish NI would deprecate the example that uses Bytes at Port, because you are their latest victim. You have termination characters, so make use of them by specifying that in your serial port setup! And then get rid of the Bytes at Port. Since you can only specify a single character to be the termination character, I would use the linefeed as the termination character so you read the entire message and then use Trim Whitespace to get rid of the carriage return. Make sure that bytes to read is bigger than the biggest message you'll ever see. LabVIEW is smart enough to only allocate what it needs.
07-23-2017 08:43 PM
Just get rid of the Bytes At Port and replace it was a constant. After counting you bytes, I would use 100. The idea is that the VISA Read will stop reading when the number of bytes you specify are read or a termination character is read, whichever comes first. So you tell the VISA Read to read more than a full message and let the termination character end the read. This way you always get the full message. The default settings from the Configure Serial already match what you want.
07-24-2017 01:00 AM
I think this one will not working with me (I tried before) as the number of data changing from time to time so I need something smart to do it without error massages !
07-24-2017 01:13 AM
@Zahran88 wrote:
I think this one will not working with me (I tried before) as the number of data changing from time to time so I need something smart to do it without error massages !
I have no idea what you just said. What didn't work for you? Apparently what you tried before isn't the same or it would have worked. The way I and cross had explained it, it *is* smart enough to do without errors. As we both said, just set Bytes to Read to something bigger than the biggest message you'll ever see.
Other than that, I can't help any further until you show us that other thing that didn't work.
07-24-2017 01:19 AM
Thanks a lot for your assistance but your answer is not clear for me! could you please show me how can I solve the problem without changing data format ?
07-24-2017 01:25 AM - edited 07-24-2017 01:27 AM
Hi Zahran,
could you please show me how can I solve the problem without changing data format ?
As long as you don't attach cour VI we cannot edit and show the code…
Two steps:
- delete the BytesAtPort property node
- wire a "100" constant to the "bytes to read" input of VISARead…
One more suggestion:
Right click your thermometer/gauge indicators and show their numerical display. Then delete those additional indicators you use for the very same purpose…
07-24-2017 01:28 AM
As long as you don't attach cour VI we cannot edit and show the code…
I attached it. kindly refer to my first post attachment
07-24-2017 01:31 AM
07-24-2017 01:40 AM
I attached it really beleive me any way I attached it again here