diff --git a/README.rst b/README.rst index 3c469e84..34246093 100644 --- a/README.rst +++ b/README.rst @@ -107,12 +107,12 @@ The :code:`n` is the PDO index (normally 1 to 4). The second form of access is f # Arguments are passed to python-can's can.Bus() constructor # (see https://python-can.readthedocs.io/en/latest/bus.html). network.connect() - # network.connect(bustype='socketcan', channel='can0') - # network.connect(bustype='kvaser', channel=0, bitrate=250000) - # network.connect(bustype='pcan', channel='PCAN_USBBUS1', bitrate=250000) - # network.connect(bustype='ixxat', channel=0, bitrate=250000) - # network.connect(bustype='vector', app_name='CANalyzer', channel=0, bitrate=250000) - # network.connect(bustype='nican', channel='CAN0', bitrate=250000) + # network.connect(interface='socketcan', channel='can0') + # network.connect(interface='kvaser', channel=0, bitrate=250000) + # network.connect(interface='pcan', channel='PCAN_USBBUS1', bitrate=250000) + # network.connect(interface='ixxat', channel=0, bitrate=250000) + # network.connect(interface='vector', app_name='CANalyzer', channel=0, bitrate=250000) + # network.connect(interface='nican', channel='CAN0', bitrate=250000) # Read a variable using SDO device_name = node.sdo['Manufacturer device name'].raw diff --git a/canopen/network.py b/canopen/network.py index 54280909..f6446208 100644 --- a/canopen/network.py +++ b/canopen/network.py @@ -92,7 +92,7 @@ def connect(self, *args, **kwargs) -> Network: :param channel: Backend specific channel for the CAN interface. - :param str bustype: + :param str interface: Name of the interface. See `python-can manual `__ for full list of supported interfaces. diff --git a/doc/network.rst b/doc/network.rst index 7efab634..42b6618a 100644 --- a/doc/network.rst +++ b/doc/network.rst @@ -25,11 +25,11 @@ See its documentation for specifics on how to configure your specific interface. Call the :meth:`~canopen.Network.connect` method to start the communication, optionally providing arguments passed to a the :class:`can.BusABC` constructor:: - network.connect(channel='can0', bustype='socketcan') - # network.connect(bustype='kvaser', channel=0, bitrate=250000) - # network.connect(bustype='pcan', channel='PCAN_USBBUS1', bitrate=250000) - # network.connect(bustype='ixxat', channel=0, bitrate=250000) - # network.connect(bustype='nican', channel='CAN0', bitrate=250000) + network.connect(channel='can0', interface='socketcan') + # network.connect(interface='kvaser', channel=0, bitrate=250000) + # network.connect(interface='pcan', channel='PCAN_USBBUS1', bitrate=250000) + # network.connect(interface='ixxat', channel=0, bitrate=250000) + # network.connect(interface='nican', channel='CAN0', bitrate=250000) Add nodes to the network using the :meth:`~canopen.Network.add_node` method:: diff --git a/examples/simple_ds402_node.py b/examples/simple_ds402_node.py index 5847923d..b9b96180 100644 --- a/examples/simple_ds402_node.py +++ b/examples/simple_ds402_node.py @@ -11,7 +11,7 @@ network = canopen.Network() # Connect to the CAN bus - network.connect(bustype='kvaser', channel=0, bitrate=1000000) + network.connect(interface='kvaser', channel=0, bitrate=1000000) network.check() diff --git a/test/test_local.py b/test/test_local.py index dd6efe1a..387c9f88 100644 --- a/test/test_local.py +++ b/test/test_local.py @@ -17,11 +17,11 @@ class TestSDO(unittest.TestCase): @classmethod def setUpClass(cls): cls.network1 = canopen.Network() - cls.network1.connect("test", bustype="virtual") + cls.network1.connect("test", interface="virtual") cls.remote_node = cls.network1.add_node(2, EDS_PATH) cls.network2 = canopen.Network() - cls.network2.connect("test", bustype="virtual") + cls.network2.connect("test", interface="virtual") cls.local_node = cls.network2.create_node(2, EDS_PATH) cls.remote_node2 = cls.network1.add_node(3, EDS_PATH) @@ -180,11 +180,11 @@ class TestNMT(unittest.TestCase): @classmethod def setUpClass(cls): cls.network1 = canopen.Network() - cls.network1.connect("test", bustype="virtual") + cls.network1.connect("test", interface="virtual") cls.remote_node = cls.network1.add_node(2, EDS_PATH) cls.network2 = canopen.Network() - cls.network2.connect("test", bustype="virtual") + cls.network2.connect("test", interface="virtual") cls.local_node = cls.network2.create_node(2, EDS_PATH) cls.remote_node2 = cls.network1.add_node(3, EDS_PATH) @@ -242,11 +242,11 @@ class TestPDO(unittest.TestCase): @classmethod def setUpClass(cls): cls.network1 = canopen.Network() - cls.network1.connect("test", bustype="virtual") + cls.network1.connect("test", interface="virtual") cls.remote_node = cls.network1.add_node(2, EDS_PATH) cls.network2 = canopen.Network() - cls.network2.connect("test", bustype="virtual") + cls.network2.connect("test", interface="virtual") cls.local_node = cls.network2.create_node(2, EDS_PATH) @classmethod diff --git a/test/test_network.py b/test/test_network.py index 095648ad..03cbe61b 100644 --- a/test/test_network.py +++ b/test/test_network.py @@ -32,8 +32,8 @@ def test_notify(self): self.assertListEqual(self.network.scanner.nodes, [2]) def test_send(self): - bus = can.interface.Bus(bustype="virtual", channel=1) - self.network.connect(bustype="virtual", channel=1) + bus = can.interface.Bus(interface="virtual", channel=1) + self.network.connect(interface="virtual", channel=1) # Send standard ID self.network.send_message(0x123, [1, 2, 3, 4, 5, 6, 7, 8]) @@ -54,8 +54,8 @@ def test_send(self): self.network.disconnect() def test_send_perodic(self): - bus = can.interface.Bus(bustype="virtual", channel=1) - self.network.connect(bustype="virtual", channel=1) + bus = can.interface.Bus(interface="virtual", channel=1) + self.network.connect(interface="virtual", channel=1) task = self.network.send_periodic(0x123, [1, 2, 3], 0.01) time.sleep(0.1) diff --git a/test/test_sync.py b/test/test_sync.py index 0321ceb6..a88fd0b5 100644 --- a/test/test_sync.py +++ b/test/test_sync.py @@ -6,7 +6,7 @@ class TestSync(unittest.TestCase): def test_sync_producer(self): network = canopen.Network() - network.connect(bustype="virtual", receive_own_messages=True) + network.connect(interface="virtual", receive_own_messages=True) producer = canopen.sync.SyncProducer(network) producer.transmit() msg = network.bus.recv(1) @@ -16,7 +16,7 @@ def test_sync_producer(self): def test_sync_producer_counter(self): network = canopen.Network() - network.connect(bustype="virtual", receive_own_messages=True) + network.connect(interface="virtual", receive_own_messages=True) producer = canopen.sync.SyncProducer(network) producer.transmit(2) msg = network.bus.recv(1) diff --git a/test/test_time.py b/test/test_time.py index d8d12e53..a5922442 100644 --- a/test/test_time.py +++ b/test/test_time.py @@ -6,7 +6,7 @@ class TestTime(unittest.TestCase): def test_time_producer(self): network = canopen.Network() - network.connect(bustype="virtual", receive_own_messages=True) + network.connect(interface="virtual", receive_own_messages=True) producer = canopen.timestamp.TimeProducer(network) producer.transmit(1486236238) msg = network.bus.recv(1)