08-08-2005 09:02 AM
08-08-2005 09:53 AM
In binary representation, each number between 0 and 255 (a byte) gets a character assigned to it. You can send these characters as a string through the serial port. The conversion from numbers to a string is shown in the attached image. These VIs can be found in the String, Numeric and Array palletes.
One important point is that numbers consisting of more than one byte have a specific order in which the bytes are split (In this case, the low byte is first). You can use the Split Number VI from the Advanced>>Data Manipulation palette to get the high and low bytes.
Also, please don't save images as bitmaps. If you saved it as a GIF or JPG, it would taken no more than a few KB.
08-08-2005 12:49 PM
Thanks, tst
I have more questions about binary operation.
I was told there is no a termination character in binary opeartion.
1. How identify the instrument the termination of a command?
2. What is the size of the buffer I've read in this case?, I mean "5 5 0 3 13" for the replied message from the instrument.
3. In order to identify the meaning of the replied message, should I use "String to Byte array"?
-> In this case, it need to use some CASE routine to match the numerical value to the meaningful status of the instrument.
-> Is there some convenient or simple idea for these complicated cases?
Thank you for your attention again.
Lee
*)How to remove my question I posted incorrectly?.
08-08-2005 01:53 PM
I'm not sure, but if you have an opening character, followed by the length of the message, you can read a single byte and once it arrives, read the next one to know how many are left.
1. How identify the instrument the termination of a command?
2. What is the size of the buffer I've read in this case?, I mean "5 5 0 3 13" for the replied message from the instrument.
The size is 5 bytes (the second number) because 13 is also a single character. It's important to remember that 5 is the number 5 (ASCII value 5) and not the character "5" (ASCII value 53 decimal).
3. In order to identify the meaning of the replied message, should I use "String to Byte array"?
Yes. Then, like you said, you will need to use the data to decide how to proceed. The decision should be made based on the protocol. For example, if the opening number is always 5, you have to wait until receiving it before continuing. If you want to verify the command, you need to do the checksum on the data you received and if it doesn't match the sent checksum, ignore it.
*)How to remove my question I posted incorrectly?.
There is no need to.
08-08-2005 06:00 PM
Very thank you, tst.
I will post if I have more problem.
Thank again.
Lee