Download 3-Space Sensor Embedded User`s Manual
Transcript
User's Manual 4.2 Protocol Packet Format(USB and Serial) 4.2.1 Binary Packet Format The binary packet size can be three or more bytes long, depending upon the nature of the command being sent to the controller. Each packet consists of an initial “start of packet” byte, followed by a “command value” specifier byte, followed by zero or more “command data” bytes, and terminated by a packet “checksum value” byte. Each binary packet is at least 3 bytes in length and is formatted as shown in figure 1 247(0xF7) First Byte – Start of Packet Command Second Byte – Command Value Selected from the command chart Command Data … Command Data } Command Data Zero or more bytes representing parameters to the command being called. See the command chart for details. Last Byte – Packet Checksum Sum of all other bytes except the first. Checksum Figure 1 - Typical Binary Command Packet Format Binary Return Values: When a 3 Space Sensor command is called in binary mode, any data it returns will also be in binary format. For example, if a floating point number is returned, it will be returned as its 4 byte binary representation. For information on the floating point format, go here: http://en.wikipedia.org/wiki/Single_precision_floatingpoint_format Also keep in mind that integer and floating point values coming from the sensor are stored in big-endian format. The Checksum Value: The checksum is computed as an arithmetic summation of all of the characters in the packet (except the checksum value itself) modulus 256. This gives a resulting checksum in the range 0 to 255. The checksum for binary packets is transmitted as a single 8-bit byte value. 21