TutoProto Protocol

This artificially made-up binary protocol is created specifically for use in IO Ninja tutorials. This protocol is, on the one hand, very simple and thus suitable for a tutorial, and on the other hand, follows the same principles as most real-world binary protocols. We’ll call our protocol TutoProto – a tutorial protocol.

As for the underlying transport, let’s assume TutoProto can work over TCP or Serial.

Commands & reply parameters

Let’s define TutoProto commands and their parameters.

enum TutoProtoCommand: uint8_t {
    GetVersion,
    Read,
    Write,
}
Command Command parameters Reply parameters
GetVersion none TutoProtoVersion
Read TutoProtoRange data
Write TutoProtoRange followed by data none

Finally, here are the definitions of the command/reply-specific structures:

struct TutoProtoVersion {
    [ displayName = "Major" ]
    uint8_t m_major;

    [ displayName = "Minor" ]
    uint8_t m_minor;

    [ displayName = "Patch" ]
    uint8_t m_patch;
}

struct TutoProtoRange {
    [
        displayName = "Offset",
        formatSpec = "0x%04X"
    ]
    bigendian uint32_t m_offset;

    [ displayName = "Length" ]
    bigendian uint16_t m_length;
}

struct TutoProtoError {
    [ displayName = "Error" ]
    bigendian uint32_t m_error;
}