Skip to content

Commit 2938a90

Browse files
authored
Adapt to renamed "bustype" parameter on can.Bus (#489)
The bustype keyword has long been replaced by "interface" and the former is deprecated in python-can. The Network class passes it through without caring for the name, but documentation and tests referred to the older name regularly.
1 parent cc37aee commit 2938a90

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

README.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ The :code:`n` is the PDO index (normally 1 to 4). The second form of access is f
107107
# Arguments are passed to python-can's can.Bus() constructor
108108
# (see https://python-can.readthedocs.io/en/latest/bus.html).
109109
network.connect()
110-
# network.connect(bustype='socketcan', channel='can0')
111-
# network.connect(bustype='kvaser', channel=0, bitrate=250000)
112-
# network.connect(bustype='pcan', channel='PCAN_USBBUS1', bitrate=250000)
113-
# network.connect(bustype='ixxat', channel=0, bitrate=250000)
114-
# network.connect(bustype='vector', app_name='CANalyzer', channel=0, bitrate=250000)
115-
# network.connect(bustype='nican', channel='CAN0', bitrate=250000)
110+
# network.connect(interface='socketcan', channel='can0')
111+
# network.connect(interface='kvaser', channel=0, bitrate=250000)
112+
# network.connect(interface='pcan', channel='PCAN_USBBUS1', bitrate=250000)
113+
# network.connect(interface='ixxat', channel=0, bitrate=250000)
114+
# network.connect(interface='vector', app_name='CANalyzer', channel=0, bitrate=250000)
115+
# network.connect(interface='nican', channel='CAN0', bitrate=250000)
116116
117117
# Read a variable using SDO
118118
device_name = node.sdo['Manufacturer device name'].raw

canopen/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def connect(self, *args, **kwargs) -> Network:
9292
9393
:param channel:
9494
Backend specific channel for the CAN interface.
95-
:param str bustype:
95+
:param str interface:
9696
Name of the interface. See
9797
`python-can manual <https://python-can.readthedocs.io/en/stable/configuration.html#interface-names>`__
9898
for full list of supported interfaces.

doc/network.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ See its documentation for specifics on how to configure your specific interface.
2525
Call the :meth:`~canopen.Network.connect` method to start the communication, optionally providing
2626
arguments passed to a the :class:`can.BusABC` constructor::
2727

28-
network.connect(channel='can0', bustype='socketcan')
29-
# network.connect(bustype='kvaser', channel=0, bitrate=250000)
30-
# network.connect(bustype='pcan', channel='PCAN_USBBUS1', bitrate=250000)
31-
# network.connect(bustype='ixxat', channel=0, bitrate=250000)
32-
# network.connect(bustype='nican', channel='CAN0', bitrate=250000)
28+
network.connect(channel='can0', interface='socketcan')
29+
# network.connect(interface='kvaser', channel=0, bitrate=250000)
30+
# network.connect(interface='pcan', channel='PCAN_USBBUS1', bitrate=250000)
31+
# network.connect(interface='ixxat', channel=0, bitrate=250000)
32+
# network.connect(interface='nican', channel='CAN0', bitrate=250000)
3333

3434
Add nodes to the network using the :meth:`~canopen.Network.add_node` method::
3535

examples/simple_ds402_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
network = canopen.Network()
1212

1313
# Connect to the CAN bus
14-
network.connect(bustype='kvaser', channel=0, bitrate=1000000)
14+
network.connect(interface='kvaser', channel=0, bitrate=1000000)
1515

1616
network.check()
1717

test/test_local.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class TestSDO(unittest.TestCase):
1717
@classmethod
1818
def setUpClass(cls):
1919
cls.network1 = canopen.Network()
20-
cls.network1.connect("test", bustype="virtual")
20+
cls.network1.connect("test", interface="virtual")
2121
cls.remote_node = cls.network1.add_node(2, EDS_PATH)
2222

2323
cls.network2 = canopen.Network()
24-
cls.network2.connect("test", bustype="virtual")
24+
cls.network2.connect("test", interface="virtual")
2525
cls.local_node = cls.network2.create_node(2, EDS_PATH)
2626

2727
cls.remote_node2 = cls.network1.add_node(3, EDS_PATH)
@@ -180,11 +180,11 @@ class TestNMT(unittest.TestCase):
180180
@classmethod
181181
def setUpClass(cls):
182182
cls.network1 = canopen.Network()
183-
cls.network1.connect("test", bustype="virtual")
183+
cls.network1.connect("test", interface="virtual")
184184
cls.remote_node = cls.network1.add_node(2, EDS_PATH)
185185

186186
cls.network2 = canopen.Network()
187-
cls.network2.connect("test", bustype="virtual")
187+
cls.network2.connect("test", interface="virtual")
188188
cls.local_node = cls.network2.create_node(2, EDS_PATH)
189189

190190
cls.remote_node2 = cls.network1.add_node(3, EDS_PATH)
@@ -242,11 +242,11 @@ class TestPDO(unittest.TestCase):
242242
@classmethod
243243
def setUpClass(cls):
244244
cls.network1 = canopen.Network()
245-
cls.network1.connect("test", bustype="virtual")
245+
cls.network1.connect("test", interface="virtual")
246246
cls.remote_node = cls.network1.add_node(2, EDS_PATH)
247247

248248
cls.network2 = canopen.Network()
249-
cls.network2.connect("test", bustype="virtual")
249+
cls.network2.connect("test", interface="virtual")
250250
cls.local_node = cls.network2.create_node(2, EDS_PATH)
251251

252252
@classmethod

test/test_network.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def test_notify(self):
3232
self.assertListEqual(self.network.scanner.nodes, [2])
3333

3434
def test_send(self):
35-
bus = can.interface.Bus(bustype="virtual", channel=1)
36-
self.network.connect(bustype="virtual", channel=1)
35+
bus = can.interface.Bus(interface="virtual", channel=1)
36+
self.network.connect(interface="virtual", channel=1)
3737

3838
# Send standard ID
3939
self.network.send_message(0x123, [1, 2, 3, 4, 5, 6, 7, 8])
@@ -54,8 +54,8 @@ def test_send(self):
5454
self.network.disconnect()
5555

5656
def test_send_perodic(self):
57-
bus = can.interface.Bus(bustype="virtual", channel=1)
58-
self.network.connect(bustype="virtual", channel=1)
57+
bus = can.interface.Bus(interface="virtual", channel=1)
58+
self.network.connect(interface="virtual", channel=1)
5959

6060
task = self.network.send_periodic(0x123, [1, 2, 3], 0.01)
6161
time.sleep(0.1)

test/test_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class TestSync(unittest.TestCase):
66

77
def test_sync_producer(self):
88
network = canopen.Network()
9-
network.connect(bustype="virtual", receive_own_messages=True)
9+
network.connect(interface="virtual", receive_own_messages=True)
1010
producer = canopen.sync.SyncProducer(network)
1111
producer.transmit()
1212
msg = network.bus.recv(1)
@@ -16,7 +16,7 @@ def test_sync_producer(self):
1616

1717
def test_sync_producer_counter(self):
1818
network = canopen.Network()
19-
network.connect(bustype="virtual", receive_own_messages=True)
19+
network.connect(interface="virtual", receive_own_messages=True)
2020
producer = canopen.sync.SyncProducer(network)
2121
producer.transmit(2)
2222
msg = network.bus.recv(1)

test/test_time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class TestTime(unittest.TestCase):
66

77
def test_time_producer(self):
88
network = canopen.Network()
9-
network.connect(bustype="virtual", receive_own_messages=True)
9+
network.connect(interface="virtual", receive_own_messages=True)
1010
producer = canopen.timestamp.TimeProducer(network)
1111
producer.transmit(1486236238)
1212
msg = network.bus.recv(1)

0 commit comments

Comments
 (0)