Skip to content

Commit

Permalink
Make interface optional. Correct the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoyding committed Apr 27, 2024
1 parent 2ed0cd5 commit 1c7e252
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You can instantiate a CaroA04 object and start it to communicate with the device
from caroa04 import CaroA04

caro = CaroA04()
caro.start(0xE0, 'pcan', 250000, 'PCAN_USBBUS1') # start communication
caro.start(0xE0, 'pcan', 250000, 'PCAN_USBBUS1') # start communication with device node ID 0xE0

caro.do1.phys = True # set do1 state to True
print(caro.do1.phys) # read do1 state
Expand All @@ -40,7 +40,7 @@ caro.bitrate.phys = 500000 # set different baudrate (will require device power
print(caro.node_id.phys) # read current address code
caro.node_id.phys = 0xE1 # set address code (will require device power cycle)

caro.shutdown() # free the bus
caro.stop() # free the bus
```

In order to share the bus with other participants, you can assign the bus attribute of the CaroA04 object before starting it.
Expand All @@ -58,8 +58,8 @@ caro = CaroA04()
caro.bus = nw.bus # use the bus already started by canopen
nw.notifier.add_listener(caro.listener) # add listener so that we can receive messages

caro.start(0xE0, 'pcan') # start communication
caro.shutdown() # free the bus
caro.start(0xE0) # start communication with node ID 0xE0
caro.stop() # free the bus
```

## Features
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You can instantiate a CaroA04 object and start it to communicate with the device
from caroa04 import CaroA04
caro = CaroA04()
caro.start(0xE0, 'pcan', 250000, 'PCAN_USBBUS1') # start communication
caro.start(0xE0, 'pcan', 250000, 'PCAN_USBBUS1') # start communication with device node ID 0xE0
caro.do1.phys = True # set do1 state to True
print(caro.do1.phys) # read do1 state
Expand All @@ -58,7 +58,7 @@ You can instantiate a CaroA04 object and start it to communicate with the device
print(caro.node_id.phys) # read current address code
caro.node_id.phys = 0xE1 # set address code (will require device power cycle)
caro.shutdown() # free the bus
caro.stop() # free the bus
..
Expand All @@ -78,8 +78,8 @@ You should simply then add CaroA04's listener to the existing bus' notifier.
caro.bus = nw.bus # use the bus already started by canopen
nw.notifier.add_listener(caro.listener) # add listener so that we can receive messages
caro.start(0xE0, 'pcan') # start communication
caro.shutdown() # free the bus
caro.start(0xE0) # start communication with node ID 0xE0
caro.stop() # free the bus
..
Expand Down
3 changes: 2 additions & 1 deletion src/caroa04/caroa04.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self):
self.node_id
)

def start(self, node_id, interface, bitrate=None, channel=None):
def start(self, node_id, interface=None, bitrate=None, channel=None):
"""
Start the communication.
:param node_id: node ID (or address code) of the device
Expand Down Expand Up @@ -163,3 +163,4 @@ def stop(self):
caro.do1.phys = True
print(caro.do1.phys)
caro.do1.phys = False
caro.stop()
2 changes: 1 addition & 1 deletion tests/test_caroa04.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def stop(self):
self.bus = None


class TestVirtualCanIoExp1:
class TestVirtualCaroA04:
@pytest.fixture(scope="class")
def caro(self):
return CaroA04()
Expand Down

0 comments on commit 1c7e252

Please sign in to comment.