The SysFS driver is part of the kernel module for Unipi units with inputs and outputs and provides easy file-based access to all inputs and outputs.
To use 1-Wire on a Unipi unit with OpenSource OS, you must install and configure OWFS. In the case of an OS with EVOK, OWFS is already installed.
Do not install OWFS for Mervis OS! It uses an alternative method to work with 1-Wire and collisions could occur.
Check the following examples of reading and writing I/O to get started:
All files within SysFS can be accessed in the same way.
DO status reading:
cat /run/unipi/io_group1/do_1_01/do_value
Setting the DO to the closed state:
echo 1 > /run/unipi/io_group1/do_1_01/do_value
DI status reading:
cat /run/unipi/io_group1/di_1_01/di_value
Status reading of all first section DI's:
cat /run/unipi/io_group1/di_[1-3]_[0-9][0-9]/di_value
Status reading of all available DI units:
cat /run/unipi/io_group[1-3]/di_[1-3]_[0-9][0-9]/di_value
Starting from Debian 11, the SysFS comprises two main parts:
The Unipi SysFS is a subsystem that operates through standard files and is automatically managed by both the Linux kernel module and userspace tools. The main goal is to provide a straightforward interface for quick evaluation and writing short (not only) shell scripts without any SW dependencies.
For production deployment, we recommend using the Modbus TCP interface, which offers more capabilities and is more powerful. It is also a standard component of the standard (pre-installed) software bundle on all Unipi units.
Since SysFS files are scattered throughout the filesystem, we strongly recommend accessing them through the directory:
/run/unipi-plc
which serves as a sort of directory containing symbolic links to all individual components.
unipi_id
API version
Similarly, like most of the other APIs, SysFS can also be a subject of change in the future. Therefore, verifying the API version before any usage by a user application is strictly recommended.
/run/unipi-plc/unipi-id/api_version
Content example:
1.1
Product desription
Overall single-file summary of the product (Unipi PLC) in human-readable format.
/run/unipi-plc/unipi-id/product_description
Content example:
Product model: S167
Product version: 1.1
Product serial: 00000667
SKU: 2020028
Options: 0x00
Platform family: Patron (7)
Platform series: 0xFF
RAW platform ID: 0xFF07
To get and use just a single value from this list, you do not have to parse the whole complex file - use single-value files as a shorthand:
/run/unipi-plc/unipi-id/product_model
/run/unipi-plc/unipi-id/product_serial
/run/unipi-plc/unipi-id/platform_family
/run/unipi-plc/unipi-id/platform_id
Mainboard desription
The mainboard is a key part of every Unipi PLC. Contains own EEPROM memory storing all information about itself and the whole unit.
/run/unipi-plc/unipi-id/mainboard_description
Content example:
Model: Mainboard
Version: 1.2
Serial: 00000515
ID: 0x07D0
Nvmem: /sys/bus/nvmem/devices/2-00571/nvmem
To get mainboard type only, parsing of this file is not necessary - simply use this shorthand:
/run/unipi-plc/unipi-id/mainboard_id
Card description
Some Unipi platforms use a plug-in slot system. Every slot can host one custom-defined type of card. Similarly, as the mainboard, every card contains EEPROM memory storing information.
/run/unipi-plc/unipi-id/card_description.<xx>
where <xx> placeholder is the number of the slot.
Content example for slot number 12:
Model: IM205
Version: 1.0
Serial: 00000080
ID: 0x0079
Nvmem: /sys/bus/nvmem/devices/plcid12/nvmem
Slot: 12
To get only card ID as a single value, this file can be used:
/run/unipi-plc/unipi-id/card_id.<xx>
where <xx> placeholder is the number of the slot.
Fingerprint
To reliably detect if the hardware configuration of the Unipi PLC has been changed, the fingerprint value can be used. This can occur when e.g. a new card is inserted into a slot.
The fingerprint value is a unique hash and is computed during every boot.
/run/unipi-plc/unipi-id/fingerprint
Content example:
fcc85af4c8573f82cdd9a30bb27b4536dd68c8d6
I/O access