The sniffer package is used on the Positive Degree sniffer and control boards. It gathers sensors data, can operate some board control and is used for remote updates.
Project description
Mark-II-sniffer
Small piece of software running on-board (Omega2S+) sniffers to gather sensors data and operate some board control.
MQTT publisher: live data
Running the pub_main.py starts a publisher client that will continually read the board's data via Modbus and send it to the .../system_data MQTT topic. The Modbus communication is done over Serial by default, but can be configured for TCP clients.
MQTT subscriber: update automation
Running the sub_main.py starts a subscriber client that listens on the .../update topic. When receiving a message on this topic, the update_sniffer.sh script will be called, executing a git pull and rebooting the module.
Setup on the Omega2S+
1. Configure the system timezone
We want to make sure that the onion is configured at the correct timezone for the data to be accurate.
- List all the timezones with
onion time list - Scroll through the available zones and copy the line that represents your
- Set the correct timezone with
onion time set <timezone> <timezone string> - For more details, you can follow this tutorial.
2. Install basic packages
- Install python3 light with
opkg install python3-light - Install git with
opkg install git git-http ca-bundle - Install pip for python3 with
opkg install python3-pip
3. Clone the repository and install requirements
The automation requires the omega to do a git pull when receiving an update. By using a personnal access token to clone the repository at first, we don't have to authenticate with git for subsequent pulls. Anyways, since 2020 using password-based authentication for Git is deprecated, and using a PAT is more secure. For more information, see Creating a personal access token.
- Go to the root directory of the onion
- Clone the repository with
git clone https://ac7856efdf646a40d5d7b7a891e842b361b41b6d@github.com/Positive-Degree/Mark-II-sniffer.git - In the project folder, install the required libraries with
pip3 install -r requirements.txt - If the app has to communicate modbus over TCP, install pymodbus with
pip3 install -U pymodbus
4. Configure the app with the appropriate info
Some environment variables have to be configured into your environment for the application to work. (They can also be added in a .env file for development).
The necessary variables are listed in the .env.example file and can be sourced with bash. To make those variables persistent on a Linux system, add them in a bash (.sh) file in /etc/profile.d.
On the Onion, the python-dotenv library is used to read the environment variables for the script, so make sure you have a .env file that is populated with your configuration.
3. Start sniffer code on boot
The start_sniffer.sh contains the commands to launch the publisher and subscriber clients. Hence, we just have to call this script on boot to start them.
- edit the /etc/rc.local file on the Omega
- add the line
sh /root/Mark-II-sniffer/scripts/start_sniffer.sh <mode> <protocol> & - the mode is either 'sniffer' or 'controller' and the protocol 'tcp' or 'serial'
- If the app has to communicate modbus over TCP, we presume it won't run on the Onion. Hence, you can use the PM2 process manager or another method to start the script on boot/reboot for your system.
For further reference, see the full Onion documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sniffer-positivedegree-0.1.8.tar.gz.
File metadata
- Download URL: sniffer-positivedegree-0.1.8.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e93b787b8ac02a3b8e1dd99b3fe8e79aace1a9aef328705e197cb5a637b6047
|
|
| MD5 |
c013a72b678a9e8f12bd587193fa4dc2
|
|
| BLAKE2b-256 |
d5e7e9aa45665b182f8feb59cfb931d1827632f62635f59eef217c4899fac0b7
|
File details
Details for the file sniffer_positivedegree-0.1.8-py3-none-any.whl.
File metadata
- Download URL: sniffer_positivedegree-0.1.8-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.6.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5b8b6417a39ca69997eb942742959c0da43dde6b992b3f8baeb6ca1397f016f
|
|
| MD5 |
4c4d250f7457338adce815a005dda8ae
|
|
| BLAKE2b-256 |
7792469e1a0dfcd2b98567f5d8b15a69ca21dc2b13969c2698922ce4afe31b50
|