Skip to main content
Version: v2

Command Handling

Command handshake​

A changed cmd_seq identifies every new command. Changing payload data or cmd_id alone does not create a request.

  1. Write all payload fields.
  2. Write cmd_id.
  3. Increment cmd_seq once. Wrap-around from 65535 to 0 is valid.
  4. Wait for ack_seq == cmd_seq.
  5. Wait for last_req_seq == cmd_seq.
  6. Evaluate last_req_status.

Interpret the result using last_req_status Values. The PLC need not observe every intermediate status: a command can finish before the next PLC scan. After reading the final result, the PLC may write cmd_id = NONE without incrementing cmd_seq.

Keep one request outstanding at a time and hold its command and payload unchanged until the matching final result. After connecting or restarting the PLC program, read ack_seq before choosing the next sequence; a reused sequence does not start a new request. On a timeout or connection loss, check the Robot and result state before deciding whether to send a new request. Do not automatically repeat a motion command.

DONE reports completion of the command handler. A started Flow or movement may still be active; use the published state and feedback to follow it.

SET_BRAKES example​

  1. Write robco_core_out.flags.brakes_closed.
  2. Write SET_BRAKES to robco_core_out.command.cmd_id, using the value in cmd_id Values.
  3. Increment robco_core_out.command.cmd_seq.
  4. Apply the command handshake above.

All commands use this mechanism.