Close

Serial Protocol Design

A project log for Stubby the (Teaching) Hexapod

100% open source robot platform with accessability and affordability in mind: teaching children of all ages about robots & programming

the-big-oneThe Big One 08/29/2014 at 15:480 Comments

Below is the initial design document for the serial protocol (see protocol.txt for the latest version, as this will likely change over time).


Protocol Info

Message Structure (bi-directional):

SegmentLength
Frame Start1 byte (0x7e)
Length1 byte
Command1 byte
Payload0 - 254 bytes
Checksum1 byte

Commands:

There are four logical message types:

Message types 1 and 2 comprise the majority of communication. Message types 3 and 4 imply an event-driven programming model. Initially, we do not want to do this as it adds complexity to the new programmer, however we do not want to preclude this from being added at a later date.

Commands have a variable payload. A description of payloads is below.  Portions in [square brackets] are optional.

CommandDirectionPayload
SendAcknowledgeStubby -> PCCommand being ack'd (1 byte)
SendCompleteStubby -> PCCommand completed (1 byte)
RequestMovePC -> StubbyDistance (2 btyes), Angle (4 bytes), [Speed (1 byte)]
RequestTurnPC -> StubbyAngle (4 bytes), [Speed (1 byte)]
RequestTranslatePC -> StubbyAxis (1 byte), Distance (1 byte)
RequestRotatePC -> StubbyAxis (1 byte), Angle (4 bytes)
RequestDistancePC -> StubbyNull
SendDistanceStubby -> PCDistance (2 bytes)
RequestOpticalPC -> StubbyNull
SendOpticalStubby -> PC1 byte / sensor (TODO: How many sensors?)
RequestBatteryPC -> StubbyNull
SendBatteryStubby -> PC1 byte
RequestDebugPC -> StubbyNull
SendDebugStubby -> PCVariable depending on message, max 254 bytes
RequestSetLEDPC -> Stubby3 bytes (RGB Value)

Discussions