Skip to content

Commit

Permalink
Change to using upper-case hex
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinse committed May 15, 2024
1 parent 617b53c commit a40a663
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions canopen/objectdictionary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def __init__(self, name: str, index: int):
self.names = {}

def __repr__(self) -> str:
return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04x}>"
return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04X}>"

def __getitem__(self, subindex: Union[int, str]) -> "ODVariable":
item = self.names.get(subindex) or self.subindices.get(subindex)
Expand Down Expand Up @@ -239,7 +239,7 @@ def __init__(self, name: str, index: int):
self.names = {}

def __repr__(self) -> str:
return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04x}>"
return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04X}>"

def __getitem__(self, subindex: Union[int, str]) -> "ODVariable":
var = self.names.get(subindex) or self.subindices.get(subindex)
Expand Down Expand Up @@ -337,8 +337,8 @@ def __init__(self, name: str, index: int, subindex: int = 0):
self.pdo_mappable = False

def __repr__(self) -> str:
suffix = f":{self.subindex:02x}" if isinstance(self.parent, (ODRecord, ODArray)) else ""
return f"<{type(self).__qualname__} {self.qualname!r} at 0x{self.index:04x}{suffix}>"
suffix = f":{self.subindex:02X}" if isinstance(self.parent, (ODRecord, ODArray)) else ""
return f"<{type(self).__qualname__} {self.qualname!r} at 0x{self.index:04X}{suffix}>"

@property
def qualname(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion canopen/pdo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def __init__(self, pdo_node, com_record, map_array):
self._task = None

def __repr__(self) -> str:
return f"<{type(self).__qualname__} {self.name!r} at COB-ID 0x{self.cob_id}>"
return f"<{type(self).__qualname__} {self.name!r} at COB-ID 0x{self.cob_id:X}>"

def __getitem_by_index(self, value):
valid_values = []
Expand Down
4 changes: 2 additions & 2 deletions canopen/sdo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __init__(self, sdo_node: SdoBase, od: ObjectDictionary):
self.od = od

def __repr__(self) -> str:
return f"<{type(self).__qualname__} {self.od.name!r} at 0x{self.od.index:04x}>"
return f"<{type(self).__qualname__} {self.od.name!r} at 0x{self.od.index:04X}>"

def __getitem__(self, subindex: Union[int, str]) -> "SdoVariable":
return SdoVariable(self.sdo_node, self.od[subindex])
Expand All @@ -122,7 +122,7 @@ def __init__(self, sdo_node: SdoBase, od: ObjectDictionary):
self.od = od

def __repr__(self) -> str:
return f"<{type(self).__qualname__} {self.od.name!r} at 0x{self.od.index:04x}>"
return f"<{type(self).__qualname__} {self.od.name!r} at 0x{self.od.index:04X}>"

def __getitem__(self, subindex: Union[int, str]) -> "SdoVariable":
return SdoVariable(self.sdo_node, self.od[subindex])
Expand Down
4 changes: 2 additions & 2 deletions canopen/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def __init__(self, od: objectdictionary.ODVariable):
self.subindex = od.subindex

def __repr__(self) -> str:
suffix = f":{self.subindex:02x}" if isinstance(self.od.parent,
suffix = f":{self.subindex:02X}" if isinstance(self.od.parent,
(objectdictionary.ODRecord, objectdictionary.ODArray)
) else ""
return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04x}{suffix}>"
return f"<{type(self).__qualname__} {self.name!r} at 0x{self.index:04X}{suffix}>"

def get_data(self) -> bytes:
raise NotImplementedError("Variable is not readable")
Expand Down

0 comments on commit a40a663

Please sign in to comment.