ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

no output from string subset

20 bytes are read from VISA read:
a.png

 

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

b.png

 

Does anyone know how to fix this? Thanks!

0 Kudos
Message 1 of 13
(5,139 Views)

Why 25and4? make it 10 and 2 it should work.

 

With Regards

Miraz
Kudos is better option to thank somebody on this forum
------------------------------------------------------------------------------
0 Kudos
Message 2 of 13
(5,132 Views)

The code should work fine.

Try using 'Highlight Execution' and see where the data is going missing.

 

String Subset

 

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.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


Message 3 of 13
(5,124 Views)
Hi,
Yes that's a problem. When I use String controller as input, the String Subset works fine.
But when using VISA read buffer as input, there is no output
0 Kudos
Message 4 of 13
(5,119 Views)

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.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 5 of 13
(5,112 Views)

think convert to byte array is better.

 

0 Kudos
Message 6 of 13
(5,103 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 13
(5,086 Views)

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.

With Regards

Miraz
Kudos is better option to thank somebody on this forum
------------------------------------------------------------------------------
Message 8 of 13
(5,080 Views)

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!

c.png

0 Kudos
Message 9 of 13
(5,063 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 13
(5,057 Views)