Skip to content

Commit

Permalink
minor renames and comment improvements
Browse files Browse the repository at this point in the history
thanks to [at]kayoub5 for the suggestions.

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Florian Jost <[email protected]>
  • Loading branch information
andlaus committed Dec 7, 2023
1 parent 00c69ef commit e645995
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions odxtools/diaglayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,15 @@ def get_comparam(

return cps[0]

def get_can_mtu(self, protocol: Optional[Union[str, "DiagLayer"]] = None) -> Optional[int]:
"""Return the maximum size of CAN frames that can be
def get_max_can_payload_size(self,
protocol: Optional[Union[str,
"DiagLayer"]] = None) -> Optional[int]:
"""Return the maximum size of a CAN frame payload that can be
transmitted in bytes.
For classic CAN busses, this is basically always 8. CAN-FD can
send up to 64 bytes per frame.
"""
com_param = self.get_comparam("CP_CANFDTxMaxDataLength", protocol=protocol)
if com_param is None:
Expand All @@ -672,23 +675,23 @@ def get_can_mtu(self, protocol: Optional[Union[str, "DiagLayer"]] = None) -> Opt
# unexpected format of parameter value
return 8

def use_can(self, protocol: Optional[Union[str, "DiagLayer"]] = None) -> bool:
def uses_can(self, protocol: Optional[Union[str, "DiagLayer"]] = None) -> bool:
"""
Check if CAN ought to be used as the link layer protocol.
"""
return self.get_can_receive_id(protocol=protocol) is not None

def use_can_fd(self, protocol: Optional[Union[str, "DiagLayer"]] = None) -> bool:
def uses_can_fd(self, protocol: Optional[Union[str, "DiagLayer"]] = None) -> bool:
"""Check if CAN-FD ought to be used.
If the ECU is not using CAN-FD for the specified protocol, `False`
is returned.
If this method returns `True`, `.use_can() == True` is implied
If this method returns `True`, `.uses_can() == True` is implied
for the protocol.
"""

if not self.use_can(protocol):
if not self.uses_can(protocol):
return False

com_param = self.get_comparam("CP_CANFDTxMaxDataLength", protocol=protocol)
Expand Down Expand Up @@ -721,7 +724,7 @@ def get_can_fd_baudrate(self,
If the ECU is not using CAN-FD for the specified protocol,
None is returned.
"""
if not self.use_can_fd(protocol=protocol):
if not self.uses_can_fd(protocol=protocol):
return None

com_param = self.get_comparam("CP_CANFDBaudrate", protocol=protocol)
Expand Down

0 comments on commit e645995

Please sign in to comment.