Skip to content

Commit 4365157

Browse files
committed
Implement CanProtocol for UcanBus
1 parent 2aa8ceb commit 4365157

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

can/interfaces/systec/ucanbus.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import logging
22
from threading import Event
33

4-
from can import BusABC, BusState, Message
5-
from ...exceptions import CanError, CanInitializationError, CanOperationError
6-
4+
from can import (
5+
BusABC,
6+
BusState,
7+
Message,
8+
CanProtocol,
9+
CanError,
10+
CanInitializationError,
11+
CanOperationError,
12+
)
713
from .constants import *
8-
from .structures import *
914
from .exceptions import UcanException
15+
from .structures import *
1016
from .ucan import UcanServer
1117

1218
log = logging.getLogger("can.systec")
@@ -145,7 +151,12 @@ def __init__(self, channel, can_filters=None, **kwargs):
145151

146152
self._is_filtered = False
147153

148-
super().__init__(channel=channel, can_filters=can_filters, **kwargs)
154+
super().__init__(
155+
channel=channel,
156+
can_filters=can_filters,
157+
protocol=CanProtocol.CAN_20,
158+
**kwargs,
159+
)
149160

150161
def _recv_internal(self, timeout):
151162
try:

test/test_systec.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def setUp(self):
3636

3737
def test_bus_creation(self):
3838
self.assertIsInstance(self.bus, ucanbus.UcanBus)
39+
self.assertEqual(self.bus.protocol, can.CanProtocol.CAN_20)
40+
3941
self.assertTrue(ucan.UcanInitHwConnectControlEx.called)
4042
self.assertTrue(
4143
ucan.UcanInitHardwareEx.called or ucan.UcanInitHardwareEx2.called

0 commit comments

Comments
 (0)