Hexapod Project - sending a packet of data
in
Integration and Hardware
•
3 years ago
Could anyone assist with the following please?
(i've added links to a page containing technical info/pdfs)
The hexEngine is capable of control via "
Packet Interface Protocol"
The HexEngine can be connected to my mac via bluetooth or serial cable.
I'm trying to establish communication with a (ehem) simple "wake" command which should look like this:
0x7e, 0x01, 0x2b, 0xd4
I've adapted a serial test sketch to try and send the command, but so far have had zero luck.
In theory, if i can establish communications i can then look at locomotion control via an iPhone and TouchOSC, and face tracking with opencv - webcam mounted to the hexapod with commands telling it to move to keep a tracked face centred on screen…
Here's the code i've been trying to establish comms:
- import processing.serial.*;
- // The serial port:
- Serial myPort;
- byte[] pip = {0x7e, 0x01, 0x2b, -44} ;
- // List all the available serial ports:
- println(Serial.list());
- println(hex(pip[0]));
- println(hex(pip[1]));
- println(hex(pip[2]));
- println(hex(pip[3]));
- myPort = new Serial(this, Serial.list()[4], 115200);
- // Send
- for (int i=0; i< 4; i=i+1){
- myPort.write(hex(pip[i]));
- println(hex(pip[i]));
- }
- myPort.stop();
- exit();
Here's a snippet from the info pdf:
Packet Format
The packet interface commands are sent in packets of data, each packet must conform to the
following protocol:
[Header Byte],[Packet Count],[n Bytes of Data.....],[Check Sum]
Header Byte = 0x7e
Packet Count = Data bytes excluding Header Byte, Packet Count & Check Sum
Check Sum = 0xff – (8 bit sum of all data bytes)
PIP Modes 0 & 1
There are two PIP modes defined by the “PIP” command in the HexEngine configuration menu
In mode 0, packets are sent as above, as long as the data is not too segmented, this protocol
will usually suffice for most applications, also in mode 1, data packets are a fixed length which
makes packet reception coding easier.
Any help would be much appreciated.
1