Skip to main content

Parser Folder

components/driving_board/parser


Message Handling

This page: structure of message encoding andin future message type detection parser contains logic for encoding protobuf messages.parser.c

 The encoding logic includes:

copy_motor_to_pb(): 

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

front_left, back_leftmiddle_left, front_rightback_left, middle_rightfront_right, back_rightmiddle_right, steering_front_leftback_right, steering_back_leftsteering_front_left, steering_front_rightsteering_back_left, steering_back_rightsteering_front_right, steering_back_right,

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


message_add_envelope():

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