CAN Autogeneration

Autogeneration:

https://docs.google.com/presentation/d/1UMpzzeudqqTlWG8cGt13OJEFQuXuK2h_pIQ3Khgf23Q/edit#slide=id.g122d6843553_0_4

 

Backend Implementation:

https://docs.google.com/presentation/d/1YdunABJWzBkTDpxPe_msvbJ8aNUg6d6yUXG5NnosrkI/edit#slide=id.g11d6e2701ee_0_209

 

 

CAN message definitions (YAML):

all CAN message definitions are within the /libraries/codegen/boards folder, where each controller board YAML defines all messages that originates from that controller board.

The message definition schema is as follows.

---   Messages:     <message name>:       id: <message id>       target:         <target controller board>: watchdog: 0 <target controller board>: watchdog: 0       signals:         <signal name>:           length: 8         <signal name>:           length: 16 critical: boolean, optional

The message id must be unique across all can messages, see https://uwmidsun.atlassian.net/l/cp/bK9KYZHR for a list of existing and available ids.

The signal lengths must be a multiple of 8, and the total length for a message cannot exceed 64. The signal lengths can be mismatched within a message.

The critical field specifies if a message is critical to car operation. Consult your local firmware lead before using this field

The watchdog field does things. # TODO(Jarvis) doc this

 

Autogen

As part of the scons build process, we autogenerate the following files that defines the CAN message structure and provide the interface to interact with CAN message data.

build/<platform>/obj/projects/<project> └─ can ├─ inc │ ├─ can_codegen.h │ ├─ can_<project>_filters.h │ ├─ can_<project>_getters.h │ ├─ can_<project>_rx_structs.h │ ├─ can_<project>_setters.h │ └─ can_<project>_tx_structs.h └─ src ├─ can_<project>_rx_all.c └─ can_<project>_tx_all.c

Specifically of interest are can_<project>_getters.h and can_<project>_setters.h which defines the getters and setters that allow your code to get received message data and update outgoing message data.

The setters and getters are in the format

get_<message name>_<signal name> set_<message name>_<signal name>