From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I increment a value that is part of a string?

I am trying to send a command to the comm port and then read data from the comm port.  I need to get 256 bytes at a time, incrementing the string I am sending after each section of data.
 
For example:  I send the string QD 20000<CR>00     Where  <CR> is a carriage return. 
 
The device interprets this as 5144 2032 0000 0000 0D00 00
 
I need to then send the next command, which is QD 20010<CR>00   or 5144 2032 0000 0100 0D00
 
followed by QD 20020<CR>00, etc.
 
I am splitting up the string, then concatenating it after incrementing the one bit, but when I do this instead of incrementing by 1, it jumps to 31, then 32, etc.
 
Any suggestions would be appreciated.
Message 1 of 6
(3,731 Views)
Try this in 7.0 format. It uses format into string.
0 Kudos
Message 2 of 6
(3,724 Views)
Thanks for the help.   I think I was over complicating the problem.  Your solution kept it nice and simple.
0 Kudos
Message 3 of 6
(3,701 Views)

After looking through the data, the example you have provided doesn't work as I thought it would.

I believe the reason for this is that when the string is being sent in the example, it is sending the 20000  as decimal, and the device is interpreting it as "3230 3030 30" and the increments as "3230 3031 30, 3230 3032 30, 3230 3033 30, etc".

I need to be able to send " 3200 0000 00, 3200 0001 00, 3200 0002 00, etc".

 

Any other suggestions?

0 Kudos
Message 4 of 6
(3,690 Views)


BigBoda a écrit:

... 

Any other suggestions?



Yes. Don't mix ASCII and Hex when you give your command format.
Instead of  QD 20000<CR>00 you should have used, for clarity, QD 2\00\00\00\00\0D\00 where \xx is the character of hex value xx.
To cast the 32bit value into a 4byte string (*not* formatted to decimal) use the function Flatten to String.



LabVIEW, C'est LabVIEW

Message 5 of 6
(3,680 Views)

Thanks,  the flatten to string function worked perfect.

0 Kudos
Message 6 of 6
(3,655 Views)