Skip to content

Commit 5ae8e44

Browse files
committed
Implement CanProtocol for NeousysBus
1 parent 08e9446 commit 5ae8e44

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

can/interfaces/neousys/neousys.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
except ImportError:
3636
from ctypes import CDLL
3737

38-
from can import BusABC, Message
39-
from ...exceptions import (
38+
from can import (
39+
BusABC,
40+
Message,
4041
CanInitializationError,
4142
CanOperationError,
4243
CanInterfaceNotImplementedError,
44+
CanProtocol,
4345
)
4446

4547

@@ -143,7 +145,7 @@ def __init__(self, channel, device=0, bitrate=500000, **kwargs):
143145
:param device: device number
144146
:param bitrate: bit rate.
145147
"""
146-
super().__init__(channel, **kwargs)
148+
super().__init__(channel, protocol=CanProtocol.CAN_20, **kwargs)
147149

148150
if NEOUSYS_CANLIB is None:
149151
raise CanInterfaceNotImplementedError("Neousys WDT_DIO Can driver missing")

test/test_neousys.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
#!/usr/bin/env python
22

3-
import ctypes
4-
import os
5-
import pickle
63
import unittest
7-
from unittest.mock import Mock
8-
94
from ctypes import (
105
byref,
116
cast,
127
POINTER,
138
sizeof,
149
c_ubyte,
1510
)
16-
17-
import pytest
11+
from unittest.mock import Mock
1812

1913
import can
2014
from can.interfaces.neousys import neousys
@@ -42,6 +36,7 @@ def tearDown(self) -> None:
4236

4337
def test_bus_creation(self) -> None:
4438
self.assertIsInstance(self.bus, neousys.NeousysBus)
39+
self.assertEqual(self.bus.protocol, can.CanProtocol.CAN_20)
4540
self.assertTrue(neousys.NEOUSYS_CANLIB.CAN_Setup.called)
4641
self.assertTrue(neousys.NEOUSYS_CANLIB.CAN_Start.called)
4742
self.assertTrue(neousys.NEOUSYS_CANLIB.CAN_RegisterReceived.called)
@@ -68,6 +63,8 @@ def test_bus_creation(self) -> None:
6863
def test_bus_creation_bitrate(self) -> None:
6964
self.bus = can.Bus(channel=0, interface="neousys", bitrate=200000)
7065
self.assertIsInstance(self.bus, neousys.NeousysBus)
66+
self.assertEqual(self.bus.protocol, can.CanProtocol.CAN_20)
67+
7168
CAN_Start_args = (
7269
can.interfaces.neousys.neousys.NEOUSYS_CANLIB.CAN_Setup.call_args[0]
7370
)

0 commit comments

Comments
 (0)