04-16-2009 08:14 AM
Hi,
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
04-16-2009 09:08 AM
04-16-2009 09:13 AM
Hi,
Thanks for the reply,
I did think of that but what stopped me was i would end up having different digits which i shall have to join to make a number. e.g if the length is 2 bytes long representing the number 12, then I would hhave to join the 1 and 2 together to get the right length. Is there any way to do it directly?
regards
Harshil
04-16-2009 09:26 AM