LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search and Replace String not working properly

So I am actually receiving the numeric value 3215851520, then using a type cast to convert it to a string which results in the "¿®  " or BFAE 0000 in hex.

 

So basically I am searching for 3215851520 in the full incoming string. However, when the robot sends it, it comes as the "¿®  "..

0 Kudos
Message 11 of 23
(1,657 Views)

In your input string it is BFAE2020 and searching for BFAE0000, hence you are not getting.

Thanks
uday
0 Kudos
Message 12 of 23
(1,655 Views)

Space characters are hex 20.

Null characters are hex 00.

 

They are not the same character.

0 Kudos
Message 13 of 23
(1,651 Views)

Udka,

 

Yes I see that now... Not sure why it's like that because I am sending the decimal number "44735" as a Unsigned 4 byte integer. LV converts this among the other stuff to a string, and you get the weird characters.

 

I am then searching for the number 44735 that gets converted using byte and word swaps. The output number from those swaps is "3215851520". (see attached)  That number is taken and converted to a string and you get the "¿®  " from the type cast conversion...

0 Kudos
Message 14 of 23
(1,647 Views)

Raven,

 

How is it that when I receive the string as a number 44735 it is "BFAE 2020 " but when I convert in LV the 44735 number it becomes "BFAE 0000 "?

0 Kudos
Message 15 of 23
(1,645 Views)

I don't know.  Where are you converting from integers to strings in your sending code?  LabVIEW isn't doing that.  Your story is missing a piece of the puzzle.  This started out with a question about search and replace string not working the way you thought it was.

 

Not the story has evolved into something about sending data, but you haven't shown any other parts of your code.

0 Kudos
Message 16 of 23
(1,637 Views)

Ok let me try to start over to try to clear up the confusion lol..

 

I am receiving a bunch of stuff from a robot (ASCII, Unsigned bytes, etc.). LV receives all of this and converts it to a string using a custom built "Extract Polymorphic" VI. The format from the robot is like this:   \nl * Sync MsgLength Msg ID, "Msg text". This long string is then parsed into sections to try to take out the Sync number (44735), the length of the string from the robot, and the message number (Msg ID, which in my case is 205). All 3 of these (Sync, MsgLength, and Msg ID) get sent from the robot as Unsigned 4 byte integers. When LV takes those and converts them, you get the weird characters. So basically, I am trying to see if I received the sync number, and display the text of Msg Text, the Msg ID number, and the length of the string. I originally was just asking about the Search and Replace portion because that was where my error was, I wasn't getting the proper sync number out which resulted in the offset past replacement being incorrect which affected everything else...

Whew, sorry for the essay answer. Attached is my "String Parsing" VI and my Endian converter VI, I guess I should have just showed that at first...

 

Thanks for the help and your patience with me!

SM

0 Kudos
Message 17 of 23
(1,627 Views)

How is the data being sent from the robot to the PC?  That part is still missing.  Is it serial?  TCP/IP?  WIFI?  wireless radio signal?

 

I'm wonder if the transmission protocol is doing some replacement of your 00 bytes to a space.

0 Kudos
Message 18 of 23
(1,612 Views)

Sorry, TCP/IP and sockets

0 Kudos
Message 19 of 23
(1,608 Views)

Hi SteMob,

 

I have to agree with RavensFan: your message contains spaces (ASCII 32) where you expect null bytes (ASCII 00).

Please make sure your sender and the transmission channel is working as expected. Once you receive the correct byte array you can do the parsing…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 20 of 23
(1,605 Views)