Skip to content

Communication Protocol

Sebastian Sarbora edited this page Feb 13, 2015 · 7 revisions

Protocol

The protocol has the following requirements:

  • motor commands
  • configuration commands for peripherals
  • raw sensor data
  • computed sensor data
  • Peripheral control commands (Lights, claws, etc)
  • semi-autonomous commands
  • emergency alerts (leak in hull, pressure to high, overheating, etc.)

Format

Each packet will have have a header, and then the data.

Transmitted Packet
TCP
Neptune Header
Neptune data
TCP

Header

Field Type Purpose
Packet Type unsigned byte Essentially an enumeration for the types described above
Priority unsigned byte How quickly should the receiver be handling this
Sequence unsigned byte potentially necessary for order is we use udp instead of tcp

Control Packets

Speed Motor - set a specific motor to a speed and direction.
Field Type Purpose
Motor ID unsigned byte The specific motor to run
Direction bool true=forward false=reverse
Speed float The raw speed to set (0.0-1.0)
Duration int How many cycles to stay at the speed
Position Motor - move a motor to a specific position; most useful for servo's and steppers.
Field Type Purpose
Motor ID unsigned byte The motor to run
Degree float Amount of rotation, can be in degree's or Radians depending on motor config. Can be more than a full rotation for multiple rotations, and negative for reverse.
Speed float the raw speed to set (0.0-1.0)
Relay control - turn a peripheral on or off, such as lights, claws, and valves.
Field Type Purpose
Relay ID unsigned byte
Enable bool
Request Peripheral Status - requests a property from a peripheral, such as a motors speed, a lights status, or a sensor value.
Field Type Purpose
Peripheral type unsigned byte motor, light, servo, claw, limit switch
Peripheral ID unsigned byte which specific one
Property ID unsigned byte enabled, speed, position, triggered

Data Packets

Sensor data
Field Type Purpose
Sensor Type int
Sensor ID int
Data char*
Computed Data
Field Type Purpose
Data Type int
Data char*
Peripheral Status
Field Type Purpose
Peripheral type unsigned byte motor, light, servo, claw, limit switch
Peripheral ID unsigned byte
Property ID unsigned byte enabled, speed, position, triggered
Data char* responsibility of the other side to parse into a struct
Alerts
Field Type Purpose
Alert Type int Error, interrupt, hardware malfunction?
Threat Level int how serious is it?
Subsystem int Is it software, motors, main board, power?
ID int Specific part of the subsystem (motor ID, sensor ID, IC, etc)

Emulator

The device emulator will essentially be a c++ program that connects to the host application and sends and receives data via tcp over the device protocol. It will most likely not include camera functionality, but should be able to emulate all of the other functions. It could also potentially be used as a unit testing platform.