-
Notifications
You must be signed in to change notification settings - Fork 3
The comm.py Module
The comm.py module is the main point of interaction between this application and the satellite. It acts a client to both, and interprets commands sent from the operator to the satellite, and also interprets telemetry sent from the satellite.
First, run source ./env.sh
to set the necessary environment variables.
To use the website's satellite simulator with comm.py, run python3 comm.py
and type Y
when prompted.
To use the website with ground station software, run python3 comm.py -I [interface]
and type n
when prompted. This will let the website communicate with ground station software, which communicates with the satellite.
- NOTE: libcsp in this repo must be built before running comm.py with ground station software
- You can use the same command line options as you would in ex2_ground_station_software
- Example: Running
python3 comm.py -I uart -d /dev/ttyUSB0
will enable let you communicate via UART.
- Example: Running
- You can also run
python3 comm.py -I dummy
to enable integration with software while using its dummy responses if you don't have a dev board.
While the comm.py module runs, it polls the communications
table of the database that the web application runs on every 5 seconds (this time interval may be changed in the future). See here for the line of code that sets this value. Each poll, the comm.py module will execute a query to check whether there are any communications where is_queued==true && receiver=='comm'
. If there are, it will send these commands to the satellite and,
- If the response is received successfully, the response is logged and the
is_queued
value of the communication object that was sent to the satellite will changed tofalse
denoting that it has successfully completed - Otherwise, an error message will be logged (printed to stdout) and the
is_queued
value of the communication object will remain unchanged (assumption here is that the communication failed for network reasons so the comm.py module will try sending the communication again next polling iteration)
To extend the comm.py module, there are 4 files of interest in the root directory of the project:
Acts a loop for constantly checking commands sent by an operator in the communications table, and sending them to a socket.
This module posts the commands in automation.txt (a file with commands separated by newlines) to the communications table with an is_queued
value of true
and a receiver
value of 'comm'
, which will result in them being sent to the satellite by comm.py during its next polling iteration.
The script then loads the next passover time, and utlizes the linux at
program to schedule the next time automation will run. You will need to install at
, which can be done with sudo apt-get install at
on Ubuntu.
If there are no new passover times left in the database, the script grabs the TLE from the most recent housekeeping data and parses the TLE using the python package pyorbital. Acquisition of Signal (AOS) times for passovers in the next 24 hours are calculated using get_next_passes()
and those passovers are then added to the database.
There is an additional feature to send subscribed users notifications via Slack when a passover starts. You will need to make a Slack app using the Slack API and then add your app's token to a keys.sh
file as an environment variable. There is an example keys-example.sh
to show how this is to be done.
Run this script to schedule automation.py to run at the next passover time. Only necessary to run if no automation is scheduled (ie. passovers have ran out, or for initially setting up automation).