Simple Python module that read/write GPIO status from IO Expansion
board (based on AW9523 chip) and share them on the local DBus.
This repository is part of the Smart Van Project.
FW Name: FW IO Exp
FW Group: com.robypomper.smartvan.fw.ioexp
FW Version: 1.0.1
README | CHANGELOG | TODOs | LICENCE
Once ran, this script reads data from the IO Exp via I2C then notify the DBus with updated values. On the other side, when it executes a DBus method, it sends the new value to the IO Exp. Then the value is updated back, next time the values are read. The DBus service and his properties are defined into _dbus_descs.py file. More info on Supported devices and value mapping.
This is a Python script, so python
is required to run it.
$ python --version
# if not installed, then run
$ sudo apt-get install python3 python3-pip
In addition, some other package must be installed in order to configure
python's dependencies like PyGObject
or pydbus
. If you are using a
debian/ubuntu based distribution, then you can run:
$ sudo apt-get install libcairo2-dev libgirepository1.0-dev dbus-x11
Once Python was installed on your machine, you can install the script's
requirements globally or create a dedicated venv
.
# Init venv (Optional)
$ python -m venv venev
$ source venv/bin/activate
# Install script's requirements
$ pip install -r requirements.txt
Now, you are ready to run the script with the command:
$ python run.py
or alternative options
$ python run.py --quiet
$ python run.py --debug --simulate
$ python run.py --dbus-name com.custom.bus --dbus-obj-path /custom/path --dbus-iface com.custom.IFace
For script's remote usage please see the dedicated page.
Defaults DBus params are:
- DBus Name:
com.ioexp
- DBus Obj Path: DEV_TYPE_* (eg:
/io_expansion_board
) - DBus Interface: DEV_IFACE_* (eg:
com.ioexp
)
The run.py
script accept following arguments:
-h
,--help
: show this help message and exit-v
,--version
: show version and exit--simulate
: Simulate a versionV3.2P
--dbus-name DBUS_NAME
: DBus name--dbus-obj-path DBUS_OBJ_PATH
: DBus object path (if None, the device type will be used, if empty nothing will be used)--dbus-iface DBUS_IFACE
: DBus interface (if None, the device interface will be used, if empty nothing will be used)--dev
: enable development mode, increase logged messages info--debug
: Set log level to debug--quiet
: Set log level to error
The main goal for this script is to link the Device's protocol to the DBus. So, in addition to the main script, all other files are related to the Device or to the DBus protocols.
Module's files can be grouped in 2 categories:
Definitions:
- ioexp/mappings.py:
definition of
PID
,PROPS_CODES
andCALC_PROPS_CODES
tables - ioexp/_definitions.py: definitions of supported devices, DUbus ifaces and custom properties types
- ioexp/_parsers.py: custom properties parsers
- ioexp/_calculated.py: custom properties calculators and data generator methods for simulator
- ioexp/_dbus_descs.py: definition of DBus iface's descriptors
Operations:
- run.py: main firmware script
- ioexp/device.py: class that represent the device
- ioexp/simulator.py: class that represent the simulated device
- dbus/obj.py: class that represent aDBus object to publish
- dbus/daemon.py: methods to handle the DBus daemon
- base/commons.py: commons properties parsers and simulator methods
- base/device.py: base class for devices
- base/device_serial.py: base implementation for serial devices