Skip to content

Refactor to protobuf - #406

Draft
tolauwae wants to merge 12 commits into
mainfrom
nanopb
Draft

Refactor to protobuf#406
tolauwae wants to merge 12 commits into
mainfrom
nanopb

Conversation

@tolauwae

@tolauwae tolauwae commented Aug 18, 2026

Copy link
Copy Markdown
Member

Refactors the existing debugger API using a protobuf scheme. The new scheme his optimized for low message size.

protobuf scheme

Protobuf defines two message type enums:

  • Command: Frontend -> WARDuino
  • Notification: WARDuino -> frontend

For instance:

enum Command {
  COMMAND_RUN = 0;                 // no payload
  COMMAND_HALT = 1;                // no payload
  //...
}

Payloads are defined in protobuf as messages. For instance:

message CodeLocation {
    uint32 module_index = 1;
    uint32 program_counter = 2;
}

message Breakpoint {
    CodeLocation location = 1;
}

Debug messages are not fully encoded by protobuf, only these payload.
This means that debug messages are of this form:

[type: uint8][payload length: varint][protobuf payload]

This allows for minimal message size. Sending message looks like this:

write_byte(COMMAND_CONTINUE_FOR);
write_length(payload_size);
pb_encode(&stream, ContinueFor_fields, &message);

Which results in this message on the wire:

┌────────────┬────────────┬───────────────────────────────┐
│ type       │ length     │ encoded ContinueFor (payload) │
│ 22         │ 2          │ 08 05                         │
└────────────┴────────────┴───────────────────────────────┘

ABI improvements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants