diff --git a/can/message.py b/can/message.py index 02706583c..63a4eea41 100644 --- a/can/message.py +++ b/can/message.py @@ -110,10 +110,10 @@ def __init__( # pylint: disable=too-many-locals, too-many-arguments def __str__(self) -> str: field_strings = [f"Timestamp: {self.timestamp:>15.6f}"] if self.is_extended_id: - arbitration_id_string = f"ID: {self.arbitration_id:08x}" + arbitration_id_string = f"{self.arbitration_id:08x}" else: - arbitration_id_string = f"ID: {self.arbitration_id:04x}" - field_strings.append(arbitration_id_string.rjust(12, " ")) + arbitration_id_string = f"{self.arbitration_id:03x}" + field_strings.append(f"ID: {arbitration_id_string:>8}") flag_string = " ".join( [ diff --git a/doc/message.rst b/doc/message.rst index d47473e17..e0003cfe5 100644 --- a/doc/message.rst +++ b/doc/message.rst @@ -44,7 +44,7 @@ Message 2\ :sup:`29` - 1 for 29-bit identifiers). >>> print(Message(is_extended_id=False, arbitration_id=100)) - Timestamp: 0.000000 ID: 0064 S Rx DL: 0 + Timestamp: 0.000000 ID: 064 S Rx DL: 0 .. attribute:: data @@ -106,7 +106,7 @@ Message Previously this was exposed as `id_type`. >>> print(Message(is_extended_id=False)) - Timestamp: 0.000000 ID: 0000 S Rx DL: 0 + Timestamp: 0.000000 ID: 000 S Rx DL: 0 >>> print(Message(is_extended_id=True)) Timestamp: 0.000000 ID: 00000000 X Rx DL: 0