Skip to content
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

Check for ValueError exception when reading PDOMapping entrys from ED… #386

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions canopen/objectdictionary/eds.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,10 @@ def build_variable(eds, section, node_id, index, subindex=0):
logger.warning("%s has an unknown or unsupported data type (%X)", name, var.data_type)
# Assume DOMAIN to force application to interpret the byte data
var.data_type = datatypes.DOMAIN

var.pdo_mappable = bool(int(eds.get(section, "PDOMapping", fallback="0"), 0))

pdo_mappable_string = eds.get(section, "PDOMapping", fallback="0")
if pdo_mappable_string != "":
var.pdo_mappable = bool(int(pdo_mappable_string, 0))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is still possible to have invalid input.

Maybe something like this?

var.pdo_mappable = eds.get(section, "PDOMapping", fallback="0") not in ("", "0")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want the invalid input to throw an exception so real errors are caught, though I guess it's a question whether PDOMapping= is valid input or not?

I no longer have access to the EDS files that were causing the issue so I don't have anything to test against.
If I have time I'll try and poke around to see if I can find any other files that exhibit this issue.

it does make me wonder if the handling of invalid input on the other entries should also throw an error?


if eds.has_option(section, "LowLimit"):
try:
Expand Down