LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

AscII to Hexadecimal HELP

    I am reading in bytes from a UDP reader and the output of this is a representation of ASCII values in string. I wanted to conver these values into a Hexadecimal so I can get an accurate value from the Hedadecimal String to Number VI. Does anyone know how to do that?Smiley Indifferent
0 Kudos
Message 1 of 8
(9,290 Views)
Hi NewBeeOne,
each ASCII sign is one byte. You can use the "Join Numbers" function to build your number or the "Type Cast" function to convert it.

Hope it helps.
Mike


Message Edited by MikeS81 on 06-28-2008 07:13 PM
0 Kudos
Message 2 of 8
(9,286 Views)
Hi NewBeeOne,
as I understood your question, you receive Bytes, which represent ASCII- Values and want to concatenate them so that the VI "Hexadecimal String to Number" can convert them to a number.
You can use "Byte Array to String" from the String/Array Conversion palette, as shown below.



Greets, Dave


Message Edited by daveTW on 06-28-2008 07:21 PM
Greets, Dave
0 Kudos
Message 3 of 8
(9,279 Views)

Is this what you are trying to do?  -> see image below

The trick it to right click the indicator (array in this case) and select Display Format and choose Hexadecimal.

RayR



I just saw Dave's reply and posted example..

I may have misunderstood the question.. 😮



Message Edited by JoeLabView on 06-28-2008 01:31 PM
0 Kudos
Message 4 of 8
(9,274 Views)
Thanks for all the help I attached an example of what I am trying to do here. And the ASCII characters that are in the string need to be split first so I split them and when I actually have a string with the ASCII Characters that I need I want to get thier value. In this example I get C3ÿ; which is 179.12199 decimal value and the value that I want however when I use the type cast I get 67? So I though by converting the ASCII Into Hexadecimal I could use the Hexadecimal string to number VI and it would give me the value I was looking for. Sorry I am very very new to labview so there probably is a really easy way to do this but I just dont know how.
0 Kudos
Message 5 of 8
(9,269 Views)
Delete the inner loop and just typecat the full string. For type, wire an array of U32 and you will get an U32 array with the desired data. 🙂
0 Kudos
Message 6 of 8
(9,243 Views)
 
 
 
 
Here's is a primitive draft how to continuusly read U32 data from UDP and append it to an evergrowing array of U32 until an error occurs.
 
 
(This is just a crude draft to shows the mechanics, so modify as needed. Tpyically you don't want to grow arrays forever because of memory issues).
 
Also have a look at the UDP examples that ship with LabVIEW.
 
Some notes:
 
NEVER attach bitmap graphics (*.bmp) and renaming it to *.jpg does NOT convert it to anything else. Your simple image is well over 1MB while a more efficient format could do the same in a few kilobytes (gif, png). There is a reason that the forum does not allow bmp attachments, so don't circumvent this. My image above is 7kB, less that 1% of yours! 😄
 
You main loop does not need any wait, because the loop rate depends on the udp timeout and the rate of arrival of packets. (However you need to check for error and stop the loop if an error happens, else the loop will spin at infinite rate creating the sam error over and over again.
 
You need to learn the difference between a plain string displayed in hex format and a hex formatted string, consisting of the ASCII characters 0..F.



Message Edited by altenbach on 06-28-2008 12:05 PM

Message 7 of 8
(9,227 Views)
Thanks for your help that got me to where I needed.
0 Kudos
Message 8 of 8
(9,216 Views)