Skip to content

Repository files navigation

Sensor data parser

A parser of data from a sensor.

Dependencies

If you have Python 3.11 and poetry installed, you can create a virtual environment with all the dependencies

make init

And then activate it

make shell

Or build a docker image from the Dockerfile file.

Usage

Pass data through stdin.

python3 -m sensor_data_parser [-h] [--create-db] [--db-path DB_PATH]
OptionDescription
-h, --helpShow the help message and exit
--create-tablesCreate tables for saving pressure packets
--db-path DB_PATHSpecify the path of the sqlite db where packets are gonna be saved, sqlite.db by default

Data format

Data is a hex string that is divided into chunks of size 8, and a chunk has the following format:

IndexesDescription
0-1Packet identifier in hex representation which should always be equal to '80'
2-3Current value counter in hex representation [00-7f]
4-7Pressure value in hex representation

If a chunk has a wrong format, it's not saved to the db.

Example

Create sqlite.db file with necessary tables.

python3 -m sensor_data_parser --create-tables

Parse the data and save valid packets in sqlite.db.

python3 -m sensor_data_parser <<<"34ffffff80490000804a0000804b0000804c0000804d000079f3ffff"

The pressure_packet table in sqlite.db after that

idcurrent_value_counterstatuspressure_value
173800
274800
375800
476800
577800

Make commands

CommandDescription
make initInstall poetry and create a virtual environment
make shellActivate the virtual environment
make testRun tests
make coverageRun tests with coverage
make lintFormat .py files in the project
make check_lintCheck if .py files are formatted
make lockCreate poetry.lock file from pyproject.toml

About

A parser of data from a sensor

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages