10-05-2018 08:23 AM
Dear ,
I am getting from slave device a ASCII string as below representing hex values
I would like to use the scan from string vi to extract the hex value and group them by word and build a 16 bit arrays.
like Data1= 0817 Data2=0000 ...and last Data= 0040.
I have no idea which attribute to use for the scan for from string vi.
I have tried this but no success.
Any help?
Solved! Go to Solution.
10-05-2018 08:53 AM
Here is some code that converts hex strings to its binary form. A little bit of modifications and you would have what you need.
10-05-2018 09:39 AM
Hi Mark,
Thanks for this idea, the problem I would to get rid of the 9 ASCII character SPI1DATA= which %9.s and just group by 16 bits word rather than byte. sO I would like to have U16 bit array with 0817,0000,0000,...,0040 .
Any idea how to get this?
10-05-2018 09:57 AM
Typecast the U8 array to a U16 array. Done.
10-05-2018 10:29 AM
It would be so much more helpful if you could attach a simplified VI (containing correct default data in the control) instead of pictures.
Is the value of the string before the equal sign fixed or variable?
Is the hex formatted string after the equal sign of constant length?
Are there any delimiters that are not shown (e.g. a LF at the end?)?
10-05-2018 10:57 AM - edited 10-05-2018 10:58 AM
I would use Match Pattern to detect the '=' and then use a FOR loop to convert the rest of the data into the 16-bit numbers.
10-08-2018 03:19 AM
Hi,
>>>>Is the value of the string before the equal sign fixed or variable?
it is an ASCII text protocol which is fixed
>>>>Is the hex formatted string after the equal sign of constant length?
The lenght may vary
>>>>Are there any delimiters that are not shown (e.g. a LF at the end?)?
No delimiter
I will post the vi that I have made
thanks for your answer!
10-08-2018 03:22 AM
Hi,
This is what exactly I want. I have also used the typecast plus a delete element array.vi to ignore the first byte of data which are fixed values.
In attachement my working vi.
Thanks for your help!