Skip to main content
https://img.shields.io/pypi/v/caroa04.svg Python versions See Build Status on GitHub Actions Documentation Status

Library to control the CAROA04 CAN-IO expander device from eletechsup.

Installation

You can install “caroa04” via pip from PyPI:

$ pip install caroao4

Usage

You can instantiate a CaroA04 object and start it to communicate with the device as follows.

from caroa04 import CaroA04

caro = CaroA04()
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
print(caro.di1.phys)  # read di1 state

print(caro.bitrate.phys)  # read current bitrate
caro.bitrate.phys = 500000  # set different baudrate (will require device power cycle)

print(caro.node_id.phys)  # read current address code
caro.node_id.phys = 0xE1  # set address code (will require device power cycle)

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. You should simply then add CaroA04’s listener to the existing bus’ notifier.

import canopen
from caroa04 import CaroA04

nw = canopen.Network()
nw.connect(interface='pcan', bitrate=250000, channel='PCAN_USBBUS1')


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)  # start communication with node ID 0xE0
caro.stop()  # free the bus

Features

  • This library uses the python-can library to communicate with the device. Please refer to its documentation to know about all the CAN interfaces that can be used with this library (https://python-can.readthedocs.io/en/stable/)

  • The device has 4 digital outputs and 4 digital inputs. Hence the signals can be read/written by using the attributes of the CaroA04 class:
    • do1, do2, do3, do4 : digital output 1 to digital output 4

    • di1, di2, di3, di4 : digital input 1 to digital input 4

    • bitrate, node_id : bitrate and address code of the device

  • Each signal has a raw value and a physical value. For example, the device does not understand a bitrate in bps. It expects an enumeration that it will interpret. So it can either be set by writing its physical value (bitrate.phys = 250000) or by writing its raw value (bitrate.raw) as follows:
    • 0: 5 kbps

    • 1: 10 kbps

    • 2: 20 kbps

    • 3: 50 kbps

    • 4: 100 kbps

    • 5: 120 kbps

    • 6: 200 kbps

    • 7: 250 kbps

    • 8: 400 kbps

    • 9: 500 kbps

    • 10: 800 kbps

    • 11: 1000 kbps

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Release files for caroa04 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for caroa04 1.0.3
File Size Uploaded
caroa04-1.0.3.tar.gz 16.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for caroa04 1.0.3
File Interpreter ABI Platform
caroa04-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 25.7 kB

Release files / caroa04-1.0.3.tar.gz

Download URL caroa04-1.0.3.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e8e6673afafb0b229fb0097b4632ee0d98936ad5a4af09058c64bde93af98622
BLAKE2b-256 checksum
How to use checksums
8e42647fa5c721a3e99abd5da85490954287b80c60ca60e014f68e03a1fe2232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.0

Release files / caroa04-1.0.3-py3-none-any.whl

Download URL caroa04-1.0.3-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cbe49b779171a67fb947da458642dece517a6256ba903fb48a582a7d8f90cc5
BLAKE2b-256 checksum
How to use checksums
a494775c5af23aa33e415be1ad0374d82e0196d1db8ba3268c4ed68065ada151
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.0

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page