You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, we use Python in order to generate the runtime code we are using to parse messages bit by bit.
Instead, we can take the heavy lifting string manipulation off of python and switch to proc macros. The new flow would have derive proc macros on structs. My current thoughts would be each CANMsg is a struct containing the various attributes from the YAML. These derive macros would add a trait to the struct that convets CANMsg to a list of MQTT packets as the current function lookup table does.
I recommend first writing the macro then using it to achieve correct syntax that matches or exceeds the python generated rust. Then make that macro work on structs. Then add those structs to a phf list. Then python generate the structs and phf list, and it should work like a charm.
The new flow:
YAML is edited
Python generates a definitions file which converts CANMsg --> CANMsg Struct in a giant phf map. The map has type <u16, impl calypso_derive::NetEncoder> Each instance is matched to its ID, such that key is CAN ID and value is the instance of the struct.
On compile time, rust adds a trait NetEncoder to each struct, adding a function called fetch_net which takes in the CANMsg data and passes back the net info similar to normal.
At runtime when calypso gets a message, it looks the message up by ID using the phf map, then calls net_encode on the struct, getting the data.
The encoder flow:
YAML is edited
Python generates a definitions file which converts EncodableCANMsg --> EncodableCANMsg struct in a giant phf map with the type <String, calypso_derive::CanEncoder>. It adds these to both lists??
TODO: how does encodableCANmsg work?
The text was updated successfully, but these errors were encountered:
Right now, we use Python in order to generate the runtime code we are using to parse messages bit by bit.
Instead, we can take the heavy lifting string manipulation off of python and switch to proc macros. The new flow would have derive proc macros on structs. My current thoughts would be each CANMsg is a struct containing the various attributes from the YAML. These derive macros would add a trait to the struct that convets CANMsg to a list of MQTT packets as the current function lookup table does.
I recommend first writing the macro then using it to achieve correct syntax that matches or exceeds the python generated rust. Then make that macro work on structs. Then add those structs to a phf list. Then python generate the structs and phf list, and it should work like a charm.
The new flow:
phf
map. The map has type <u16, impl calypso_derive::NetEncoder> Each instance is matched to its ID, such that key is CAN ID and value is the instance of the struct.fetch_net
which takes in the CANMsg data and passes back the net info similar to normal.The encoder flow:
The text was updated successfully, but these errors were encountered: