Skip to content

Commit 2aa8ceb

Browse files
committed
Implement CanProtocol for the SerialBus
1 parent 9a39e2e commit 2aa8ceb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

can/interfaces/serial/serial_can.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
import struct
1313
from typing import Any, List, Tuple, Optional
1414

15-
from can import BusABC, Message
1615
from can import (
16+
BusABC,
17+
Message,
18+
CanProtocol,
1719
CanInterfaceNotImplementedError,
1820
CanInitializationError,
1921
CanOperationError,
@@ -97,7 +99,7 @@ def __init__(
9799
"could not create the serial device"
98100
) from error
99101

100-
super().__init__(channel, *args, **kwargs)
102+
super().__init__(channel, protocol=CanProtocol.CAN_20, *args, **kwargs)
101103

102104
def shutdown(self) -> None:
103105
"""

test/serial_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
import can
1313
from can.interfaces.serial.serial_can import SerialBus
14-
15-
from .message_helper import ComparingMessagesTestCase
1614
from .config import IS_PYPY
17-
15+
from .message_helper import ComparingMessagesTestCase
1816

1917
# Mentioned in #1010
2018
TIMEOUT = 0.5 if IS_PYPY else 0.1 # 0.1 is the default set in SerialBus
@@ -52,6 +50,9 @@ def __init__(self):
5250
self, allowed_timestamp_delta=None, preserves_channel=True
5351
)
5452

53+
def test_can_protocol(self):
54+
self.assertEqual(self.bus.protocol, can.CanProtocol.CAN_20)
55+
5556
def test_rx_tx_min_max_data(self):
5657
"""
5758
Tests the transfer from 0x00 to 0xFF for a 1 byte payload

0 commit comments

Comments
 (0)