Skip to main content

Parser Folder

components/driving_board/parser


This page: structure of message encoding in parser.c

The encoding logic includes:


copy_motor_to_pb():

Copies each motor from internal MotorDiagnostic struct into protobuf MotorInformation.


DBMDiagnosticsEncode():

Encodes full diagnostics data into a protobuf message.

This function: Initializes the protobuf message Copies board state Copies all 10 motors into the protobuf structure Calls pb_message_encode to serialize data

The diagnostics message contains 10 motors:

front_left, middle_left, back_left, front_right, middle_right, back_right, steering_front_left, steering_back_left, steering_front_right, steering_back_right,

Each motor is copied using a loop into the protobuf message.


message_add_envelope():

This method wraps a protobuf message into a PBEnvelope using the same pb_message_encode function.

It: Takes a populated protobuf message (e.g. DrivingBoardDiagnostics) Initializes a PBEnvelope Sets the correct oneof field (e.g. drive_diag) Calls pb_message_encode on the envelope struct Returns encoded envelope buffer and length