zabealbe / can-cicd

Automate the managment of your CAN BUS
Other
5 stars 4 forks source link

Global field for network constants #35

Closed simoneruffini closed 3 years ago

simoneruffini commented 3 years ago

Add a field in the network.json where constants can be defined, e.g.:

constants:{
"error_mask_ecu_implausibility" :"2",
"error_mask_ecu_hal_err" : "1",
....
}

so that this constants can be used internally in the network.json and will be generated in the appropriate header-file. This constants as usual will be in the form of defines.

This is needed to encode error messages on canBUS, e.g.

message:{
      "name" : "error_ecu",
      "data":{
           "uint16":"error_bit_set"
      }
}

When this message will arrive, the receiver can encode the error message by doing:

if ((error_bit_set && error_mask_ecu_implausibility) != 0) { manage error}
else (error_bit_set && ...)
zabealbe commented 3 years ago

You should use enums for that, this feature is too specific for the scope of this project.

simoneruffini commented 3 years ago

No, because if I have two errors at the same time then I need to have every possible combination of error encoded in a specific enum. Let's say I have 8 possible errors, then I need to write 2^8 enum values to accomodate all possible outcomes and permutations.

zabealbe commented 3 years ago

I see. Unfortunately the scope of can cicd is not how to use the data you receive but rather make sure that you receive the correct data with the correct format, I don't see space for that in the project. As an alternative you can use the message's description to give hints on how to use a specific field.