Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Ascii to decimal numbers

Hi,

 

I will try and post my question again and try and explain better

 

I am having trouble to get the correct integer values from the serial read string that i receive. E.g. If I send 093 (type in hype terminal) I get 48,57,51 as array elements. I have used the string to byte array function to convert the string I read from the serial port. The values are the ascii equivalents. How can I get 0,9,3 back? I need these as the program further performs a length and crc check which go wrong as  0 is now taken as 48.

 

Tthe serial port is reading from a gamma meter. The gamma meter sends its data in a kind of BCD format (where the each byte is 0-255).

 

E.g. The packet received has the length field of the data which is 2 bytes long (byte 2 and 3). For me to get the value of the length I have to do the following

 

length = data(2)*256 + data(3)  -- where data is the array of the data read from the serial port.

 

Using the string to byte array gives the ascii equivalents. Therefore if the value received was 5 then labview would give me 53 and 53*256 would be completely off.

 

Hope this clarifies. The overall scenario is that i am trying to convert matlab code into labview so that the gamma meter could be used with the clients system which runs labview.

I have also attached the matlab file as a txt file but you can change the extension to a .m file.

 

regards

Harshil 

0 Kudos
Message 1 of 3
(3,294 Views)
0 Kudos
Message 2 of 3
(3,284 Views)
Second Duplicate post: http://forums.ni.com/ni/board/message?board.id=280&message.id=5846
Beejal S
NI UK & Ireland
0 Kudos
Message 3 of 3
(3,267 Views)