Skip to content

CSAFE Command Format

Mike Bottini edited this page Jun 7, 2021 · 3 revisions

This is better-explained in the specification that comes with Concept2's SDK, but I feel like breaking it down Barney-style.

All commands to the device must be formatted inside a CSAFE Frame. Each Frame contains a single command. You can send multiple Frames inside a single buffer, but we'll get to that later. In turn, the PM5 will send as many Frames back as you sent.

Standard Frames

A Standard Frame contains the following bytes:

  • A Standard Frame Start Flag, 0xf1.
  • One or more Command frames, which contain the following:
    • A Command, which is a single byte.
    • A Data Frame, if any. The Data Frame contains a single byte denoting the number of bytes that will follow, followed by the Data bytes.
  • A Checksum, which is the bitwise XOR accumulation of the Command frames.
  • A Stop Flag, 0xf2.

Extended Frames

An Extended Frame contains the following bytes:

  • An Extended Frame Start Flag, 0xf0.
  • The Destination Address, which is a single byte.
  • The Source Address, which is a single byte.
  • Command frames, as in the Standard Frame.
  • A Checksum, accumulating the Destination, Source, and Command Frames.
  • A Stop Flag, 0xf2.

All of the examples in the Concept2 documentation seem to be in Extended Frame form, despite the fact that... we don't really need Extended Frames, seeing as how we're only transmitting to a single machine. This library only uses Standard Frames.

Response Frames

A Standard Response Frame contains the following bytes:

  • A Standard Frame Start Flag, 0xf1.
  • A status byte, which seems to be 0x1 or 0x81 if it's good. I haven't seen a bad status yet.
  • One or more Command Response frames, which contain the following:
    • A Command, which is a single byte.
    • A Data Frame. The Data Frame contains a single byte denoting the number of bytes that will follow, followed by the Data bytes.
  • A Checksum, which is the bitwise XOR accumulation of the Command Response frames.
  • A Stop Flag, 0xf2.

An Extended Response Frame contains the following bytes:

  • An Extended Frame Start Flag, 0xf0.
  • The Destination Address, which is a single byte.
  • The Source Address, which is a single byte.
  • Command Response frames, as in the Standard Frame.
  • A Checksum, accumulating the Destination, Source, and Command Response Frames.
  • A Stop Flag, 0xf2.

Examples

(TODO)

Clone this wiki locally