-
-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EncodeError: signal required for encoding when passing a partial dictionnary to Message.encode() #663
Comments
Set |
Thanks for your answer,
My guess is that the values have not been initialized by default (how to do so?) and so the |
cantools does not provide default values for signals. The closest thing it has are the initial values, but they are conceptually slightly different (If I understood this correctly). If you want to use these as default values, you can do so using db_msg = db.get_message_by_name("MyMessage")
msg_data = {}
for signal in db_msg.signals:
if signal.initial is not None:
msg_data[signal.name] = signal.initial
# set the values which you actually want to send
raw_data = db.encode_message(db_msg.name, msg_data) |
Hello!
Great work with this library!
I have a simple question. I would expect to be able to write the following:
This would be handy to shorten notation by defaulting values and manipulate variables as in
data = message.encode( {key:val} )
However, it seems one has to specify the entire dictionary:
or else we get a
cantools.database.errors.EncodeError: The signal "AverageRadius" is required for encoding.
Is there a way to bypass such limitation without having to build an entire dictionnary with defaulted values ?
Best wishes,
The text was updated successfully, but these errors were encountered: