07-05-2018 12:09 AM
Hi GerdW
@GerdW wrote:
Hi sr,
you can "split" the string at each "\r\n" delimiter: use SpreadsheetStringToArray with a LF as delimiter.
Now you can convert each separated string element to numeric. When an error occurs while conversion you have a found a letter, use it to put the next numeric value in the right place!
Remove already converted string subsets from your concatenated string to avoid conversion of the very same values again and again…
Thanks GerdW for the response. That would be true if it was a single string comprising all the sensors readings with their respective alphabets. Actually, i am receiving one reading at one time. that is; A , then line feed then the floating point number; then line feed , then B , line feed , and a floating point number and so on. So what would be the solution in this case?
Thanks
07-05-2018 12:12 AM
@crossrulz wrote:
@sr_murd wrote:
Why do you put a linefeed (LF, or CR, or both) between your values? Why not use a space or tab char and only ONE linefeed after the E value?
This is because the measurements are coming from another device in this manner.
Since you can change what is being sent over this serial port, you can remove those extra characters. Personally, I would get rid of the A, B, C, etc. Just have your values with a tab between them and end the message with a Line Feed (\n). This will make things, by far, the simplest to handle.
The reason for having the alphabets is to differentiate the sensors readings at the receiving end, otherwise there is no way to tell which floating point number corresponds to which sensor and the order gets changed depending on the start of the labview program.
07-05-2018 01:20 AM
07-05-2018 06:26 AM
@sr_murd wrote:
@crossrulz wrote:
@sr_murd wrote:
Why do you put a linefeed (LF, or CR, or both) between your values? Why not use a space or tab char and only ONE linefeed after the E value?
This is because the measurements are coming from another device in this manner.
Since you can change what is being sent over this serial port, you can remove those extra characters. Personally, I would get rid of the A, B, C, etc. Just have your values with a tab between them and end the message with a Line Feed (\n). This will make things, by far, the simplest to handle.
The reason for having the alphabets is to differentiate the sensors readings at the receiving end, otherwise there is no way to tell which floating point number corresponds to which sensor and the order gets changed depending on the start of the labview program.
Again, not if you format your data correctly. If you have just your values delimited by a tab and you have the line feeds removed, you get all of your data in a single read and it is fairly safe to assume from there the order of the data is constant.
07-05-2018 09:21 PM
Hi GerdW
I am sorry to bother you again, but as you said using Spreadsheet stringto array , and using linefeed as delimiter, i could not get an output of that block in the array indicator. pls check the my read loop and suggest, thank you very much
07-05-2018 09:26 PM
You keep forcing your code to have \r\n between every value and every set of values and are not following the advice you are given. What instrument is sending the data? It seems to be something you are able to control.
Put a tab between the individual values in the group. Put a linefeed at the end of each group. Then Write to Spreadsheet Array will work exactly like you need it to.
07-05-2018 09:31 PM
@RavensFan wrote:
You keep forcing your code to have \r\n between every value and every set of values and are not following the advice you are given. What instrument is sending the data? It seems to be something you are able to control.
Put a tab between the individual values in the group. Put a linefeed at the end of each group. Then Write to Spreadsheet Array will work exactly like you need it to.
Sir,
these are Udp.write() messages sent from remote device (Arduino wireless device) and being displayed in serial port on local computer. they are being sent in this way as one by one sensor readings which have \r\n between them; (im trying to pack them and send them all in one string as you mentioned) ; but is there anyway to get these values segregated ?
07-05-2018 09:55 PM
Rewrite the Arduino. If the text language is like other text languages such as BASIC, there is a Print and a PrintLN. When you to a print to the serial port, it sends out that data, if you do a PrintLN, it sends out the data and ends it with a linefeed.
So you could do a
Print (val A)
Print chr$(9) ' tab character
Print (val B)
Print chr$(9) ' tab
......
PrintLN (val E)
You put a tab between values and a linefeed at the end. Don't put linefeeds between every value.
07-05-2018 11:02 PM
@RavensFan wrote:
Rewrite the Arduino. If the text language is like other text languages such as BASIC, there is a Print and a PrintLN. When you to a print to the serial port, it sends out that data, if you do a PrintLN, it sends out the data and ends it with a linefeed.
So you could do a
Print (val A)
Print chr$(9) ' tab character
Print (val B)
Print chr$(9) ' tab
......
PrintLN (val E)
You put a tab between values and a linefeed at the end. Don't put linefeeds between every value.
Thanks dear, im nearly there. i have concatenated on the sending side with tab delimted values and receiving as one string as attached in image of read buffer; trying to separate them, if you can please advise on that
07-06-2018 01:07 AM - edited 07-06-2018 01:08 AM
Hi sr,
oh boy: did you take the basic LabVIEW lessons? They are offered for free!
Why do you think you need an array constant for a five-dimensional array? You surely need a one-dimensional array holding 5 values/elements after string conversion…
Solution:
- set the array constant to just 1D!
- change the format string to "%f"!
- Delete the delimiter char constant: SpreadsheetStringToArray already uses the Tab by default!
(Reading the help for LabVIEW functions might be a good idea, don't you think?)