iaq_sensor_wired/tests/README.md
2023-11-09 22:14:19 +01:00

2.4 KiB

Test scripts

These are obsolete - please refer to Python package

Python scripts used for sensor reading, configuring and automated testing. All scripts assume that 485 converter device file is /dev/rs485.

User scripts

Following scripts are meant to be used by user for sensor search, read and config (write).

find_device.py

Search for device over all combinations of given baudrates and addresses. If no arguments are given, script tries all possible combinations (which takes really long time).

Usage:

./find_device.py [ -a [{FIRST_ADDR-LAST_ADDR | ADDR} ...] ] [ -b [BAUD ...]]

Examples:

Complete search (slow!):
	./find_device.py
Look for devices 123,10,56 at baudrates 19200,115200:
	./find_device.py -a 123 10 56 -b 19200 115200
Look for devices 10-55 at baudrate 19200:
	./find_device.py -a 10-55 -b 19200
Look for device 1-10 and 55 at baudrate 115200:
	./find_device.py -a 1-10 55 -b 115200
Look for device 1-10 at all possible baudrates:
	./find_device.py -a 1-10 55

query_device.py

Script for interaction with sensor. Allows reading from input register and read/write access to holding registers.

Usage:

./query_device.py ADDR [BAUDRATE] [{read [REGISTER ...] | write VALUE REGISTER}]
where:
    - ADDR is Modbus address (use 0 for broadcast; note that only write can be broadcast)
    - BAUDRATE is (optional) baud rate; default value is 19200
    - action can be "read", "write" or can be omitted (defaults to "read all")
    - REGISTER can be either human-friendly register name (e.g. "CO2") or register number (30001)
    - read may have list of REGISTER arguments (combining both register numbers and names)
    - VALUE is 16-bit integer in decimal format
    - to get list of human-friendly names just read all registers from sensor (run script with address only)

Examples

Read all registers from sensor 247, default baud rate:
    ./query_device.py 247
Read only CO2 register from sensor 123, baudrate 4800:
    ./query_device.py 123 4800 read CO2
Read CO2, T_SHT4x and RH_SCD4x from sensor 222, default baudrate:
    ./query_device.py 222 read CO2 T_SHT4x RH_SCD4x
Turn LED off for sensor 247, baud 115200:
    ./query_device.py 247 115200 write 0 LED_on_register
Set brightness of all connected sensors to 50%:
    ./query_device.py 0 write 50 LED_brightness_register