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?
已解决! 转到解答。
Here is some code that converts hex strings to its binary form. A little bit of modifications and you would have what you need.
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?
Typecast the U8 array to a U16 array. Done.
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?)?
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.

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!
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!