10-28-2014 03:16 AM
20 bytes are read from VISA read:
and I want to take the value 00BF, so I used String Subset, with offset=25, length=4. but there is no output at substring
Does anyone know how to fix this? Thanks!
10-28-2014 03:30 AM
Why 25and4? make it 10 and 2 it should work.
10-28-2014 03:34 AM - edited 10-28-2014 03:39 AM
The code should work fine.
Try using 'Highlight Execution' and see where the data is going missing.
Edited1: Tell us about, how the string indicator (Read buffer) is configured, is it Normal or Hex.
Edited2: Also include the 'String Length' functionfor debugging purpose.
10-28-2014 03:38 AM
10-28-2014 03:41 AM
I think the problem is in the way the string is configured (check my previous edited reply).
Also, as mentioned already, debug using the String Length function.
10-28-2014 03:48 AM
think convert to byte array is better.
10-28-2014 04:10 AM
Hi QH_Dai,
why should this be better?
- There's no difference in taking an array subset or a string subset…
- The main problems stays: Cantata has to learn how it's data is represented! There's a difference in "normal" and "hex" string display - and so the byte offset and length differs when we want to have a certain subset…
10-28-2014 04:13 AM
Sorry, I thought you are taking HEX string, if that is normal string then 25 and 4 should work. For HEX string 10 and 2 should work.
10-28-2014 05:10 AM
Hi everyone,
I've got another question.
after getting the String subset, I want to convert the hex string to decimal number. I used the Hex String to Number function, but the output is 0. Does anyone know how to do this? Thanks very much!
10-28-2014 05:21 AM - edited 10-28-2014 05:22 AM
Hi Cantata,
you still don't get how your data is presented. You need to convert your string either by
- typecasting that string subset to U16…
- converting that string subset to byte array, indexing the two bytes and JOINing them to U16…