Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Update parser to quick-convert node ids to hex from dec
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitri-mcguckin committed May 11, 2021
1 parent c20adcb commit 4518e49
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions canopen_monitor/parse/eds.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ def __len__(self) -> int:
def convert_value(value: str) -> Union[int, str]:
# Turn number-like objects into numbers
if (value != ''):
if (all(c in string.digits for c in value)):
return int(value, 10)
elif (all(c in string.hexdigits for c in value)):
if (all(c in string.hexdigits for c in value)):
return int(value, 16)
elif (all(c in string.digits for c in value)):
return int(value, 10)
else:
return value

Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7750,4 +7750,4 @@
ParameterValue=
PDOMapping=0
"""
"""
2 changes: 1 addition & 1 deletion tests/spec_eds_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_get_node_id(self):
"""
DCF Parsing set node id attribute
"""
self.assertEqual(10,
self.assertEqual(0x10,
self.eds.node_id,
"Error parsing node id")

Expand Down

0 comments on commit 4518e49

Please sign in to comment.