Task 3
Description
A Python program monitor_pc_ws_client.py
runs on the PC and performs these operations:
- it retrieves data from the RPI (images, sensor data)
- it preprocesses the data and prepares these data in a way to make them accessible to other programs.
As shown in the figure below program monitor_pc_ws_client.py
relies on two input files (json
format):
input file | description |
credential file | crendentials required to login the RPI and establish a SSH session transferring files with SFTP |
configuration file | general configuration data |
A third (optional) argument is a file name. If provided the program records some status information in this file. After the program terminates such a file could provide helpful information for debugging.
The next figure shows the workflow implemented by program monitor_pc_ws_client.py
.
Workflow
- The two input files for credentials and configuration data are read and evaluated
- The program checks if the message broker
RabbitMQ
is running- the program aborts otherwise
- The program checks if the
PostgreSQL
server is running- the program aborts if the server is unavailable
- To check if a SSH session could be started on the Raspberry PI it is attempted to make a SSH connection
- the program aborts if it cannot connect
- The program starts the process of capturing/storing images on the Raspberry PI
- for more details on how to start this program on the RPI see this page.
- The program starts program
monitor_rpi_ws_server.py
on the RPI. This program not only monitors the file system of the RPI for newly captured images moreover it produces sensor data. For more details see this page. - The monitoring process now starts on the PC
- for communication with the RPI a websockets connection will be established
- Data are exchanged over the websocket connection. Here are some details of what this exchange is all about and how it is further processed on the PC:
- notifications about sensor data are received from the RPI. The notifications are converted into appropriately formatted messages which are published to the
MQTT
message queue of message brokerRabbitMQ
. - notfications about new images are sent to the PC. The program on the PC may then decide to request a new image from the RPI. The program on the PC stores such images in a dedicated directory from where images can be accessed by other applications.
- notifications about sensor data are received from the RPI. The notifications are converted into appropriately formatted messages which are published to the
Summary
Program monitor_pc_ws_client.py
serves as a data collection utility. Data can be either sensor data or images, both of which are generated on the Raspberry PI. Apart from making these collected data available to other applications program monitor_pc_ws_client.py
does little or no post processing of these data. It is the responsibility of other applications to decide what to do with these data.
Resources
Program
and some sample configuration files will be made available on GitHub.monitor_pc_ws_client.py