Skip to content

Commit f875098

Browse files
committed
Added documentation on GS APIs
1 parent ecc226a commit f875098

File tree

8 files changed

+130
-11
lines changed

8 files changed

+130
-11
lines changed

api/api-overview.tex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Ground stations expose uplink and downlink functionality through API based on ZeroMQ messages (https://zeromq.org/) through TCP transport. The TCP endpoints are not exposed to public network, so in order to work with them, the Client must be connected to the same network.
2+
3+
All data exchanged between ground and PW-Sat2 are AX.25 KISS-encoded frames. Consult AX.25 (http://www.ax25.net/AX25.2.2-Jul\%2098-2.pdf) and APRS (http://www.aprs.org/doc/APRS101.PDF) documentation.
4+
5+
Summary of available endpoints:
6+
\begin{longtable}{l|l}
7+
\toprule
8+
\textbf{Function} & \textbf{Endpoint} \\
9+
\midrule
10+
\endhead
11+
Receive downlink frames & \texttt{tcp://<host>:7001} \\
12+
Transmit uplink frame & \texttt{tcp://<host>:7000} \\
13+
\bottomrule
14+
\end{longtable}
15+
16+
PW-Sat2 maintains an open-source repository, containing among others, a Python code used to decode and encode PW-Sat2 data. The relevant parts are located in GitHub repository: https://github.com/PW-Sat2/PWSat2OBC/tree/master/integration_tests.

api/downlink.tex

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
\section{Receiving data}
2+
3+
All frames received and decoded by ground station are pushed as ZeroMQ message. In order to to receive it, client must subscribe to endpoint \texttt{tcp://<host>:7001}.
4+
5+
The incoming frames are AX.25 frames, without synchronization sequence and end flags.
6+
7+
\begin{longtable}{l|l}
8+
\toprule
9+
\textbf{Bytes} & \textbf{Meaning} \\
10+
\midrule
11+
\endhead
12+
7 bytes & Destination call sign \\
13+
7 bytes & Source call sign \\
14+
1 byte & Frame type (constant 0x03) \\
15+
1 byte & Protocol Id (constant 0xF0) \\
16+
6 bits & Frame APID \\
17+
18 bits & Sequence number \\
18+
227 bytes & Frame Payload \\
19+
last 2 bytes & FCS \\
20+
\bottomrule
21+
\end{longtable}
22+
23+
The payload data depends on the frame APID. The PW-Sat2 OBC repository contains code to parse it.
24+
Below is an example (simplified) python code to connect, receive and decode frame.
25+
26+
\begin{verbatim}
27+
import response_frames # from PWSat2OBC/integration_tests
28+
import zmq
29+
30+
sock = context.socket(zmq.SUB)
31+
sock.connect("tcp://%s:%d" % (target, port))
32+
sock.setsockopt(zmq.SUBSCRIBE, "")
33+
34+
frame = sock.recv()
35+
payload = frame[16:-2] # extract ax.25 payload
36+
frame_decoder = response_frames.FrameDecoder(response_frames.frame_factories)
37+
print(frame_decoder.decode(frame))
38+
\end{verbatim}

api/uplink.tex

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
\section{Transmitting data}
2+
3+
Similarly to downlink, the uplink uses AX.25 frames (APRS) encoded as ZeroMQ messages, sent to ground station's endpoint (\texttt{tcp://<host>:7000}).
4+
5+
The message follows AX.25 format:
6+
7+
8+
\begin{longtable}{l|l}
9+
\toprule
10+
\textbf{Bytes} & \textbf{Meaning} \\
11+
\midrule
12+
\endhead
13+
7 bytes & Destination call sign \\
14+
7 bytes & Source call sign \\
15+
1 byte & Frame type (constant 0x03) \\
16+
1 byte & Protocol Id (constant 0xF0) \\
17+
4 bytes & Security Code (verified na OBC) \\
18+
1 byte & Frame APID \\
19+
195 bytes & Frame Payload \\
20+
\bottomrule
21+
\end{longtable}
22+
23+
PW-Sat2 OBC repository contains Python code for all available Telecommands to generate payload for AX.25 frames. Below is an example (simplified) python code to connect to ground station, encode telecommand and transmit it.
24+
25+
\begin{verbatim}
26+
27+
import aprs
28+
import zmq
29+
30+
class Wrap:
31+
def __init__(self, byte_str):
32+
self.byte_str = byte_str
33+
34+
def encode(self, *args):
35+
return self.byte_str
36+
37+
def send():
38+
sock = self.context.socket(zmq.PUB)
39+
sock.connect("tcp://%s:%d" % (target, port))
40+
41+
aprs_frame = aprs.Frame()
42+
aprs_frame.source = aprs.Callsign(self.source_callsign)
43+
aprs_frame.destination = aprs.Callsign(self.destination_callsign)
44+
45+
payload = frame.build()
46+
aprs_frame.text = Wrap(convert_bytes_to_string(payload))
47+
buff = array.array('B', self.aprs_frame.encode_kiss())
48+
msg = convert_bytes_to_string(buff)
49+
sock.send(msg)
50+
51+
\end{verbatim}
52+
53+
Example: requesting beacon frame using PW-Sat2 OBC repository code:
54+
55+
\begin{verbatim}
56+
import telecommand
57+
send(telecommand.SendBeacon())
58+
\end{verbatim}

main.tex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ \chapter{PW-Sat2 - Overview}
1818
\input{overview/extended-mission.tex}
1919
\input{overview/operations.tex}
2020

21+
\chapter{API}
22+
\input{api/api-overview.tex}
23+
\input{api/downlink.tex}
24+
\input{api/uplink.tex}
25+
2126
\chapter{Software tools reference}
27+
\input{tools/tools-overview.tex}
2228
\input{tools/mission-repo.tex}
2329
\input{tools/gnuradio.tex}
2430
\input{tools/grafana.tex}
25-
\input{tools/session-monitor.tex}
31+
% \input{tools/session-monitor.tex}
2632
\input{tools/uplink-console.tex}
27-
\input{tools/tasklist-generator.tex}
28-
\input{tools/autosession.tex}
33+
% \input{tools/tasklist-generator.tex}
34+
% \input{tools/autosession.tex}
2935

3036
\chapter{\obc Concepts}
3137
\input{obc-procedures/adcs.tex}

overview/basic-information.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ \section{PW-Sat2 Basic information}
2323
\end{itemize}
2424
\item Radio (using amateur bands):
2525
\begin{itemize}
26-
\item Uplink: 145.900, BPSK, 1200bps
27-
\item Downlink: 435.275, BPSK, 9600bps
26+
\item Uplink: 145.900, AFSK, 1200bps, AX.25
27+
\item Downlink: 435.275, BPSK, 9600bps, AX.25
2828
\item Full-duplex communication possible.
2929
\end{itemize}
3030
\end{itemize}

overview/operations.tex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ \subsection{Session type: Deep-sleep refresh}
3232
Occurs every other day. It's manual: the task list is constant, but operator controls transmission manually using \toolref{Uplink Console}.
3333

3434
\subsection{Session type: Full-mode sessions}
35-
Occurs every 2 weeks. It's manual and requires most work. They're planned at least couple days in advance. Plans for experiments and photos are prepared by OPER members responsible for each experiments. All task lists are prepared (with help of \toolref{Tasklist Generator}) and executed (using \toolref{Uplink Console}) by operators manually.
35+
Occurs every 2 weeks. It's manual and requires most work. They're planned at least couple days in advance. Plans for experiments and photos are prepared by OPER members responsible for each experiments. All task lists are prepared (with help of Tasklist Generator) and executed (using \toolref{Uplink Console}) by operators manually.
3636

3737
\subsection{Steps for each session}
3838

3939
\begin{enumerate}
4040
\item Operator prepares pull request in \toolref{Mission Repository} with data.json, tasklist.py and summary.py. In case of Deep-sleep refresh session, only data.json change is needed.
4141
\item Other team members review and approve the pull request.
4242
\item Operator merges the pull request at least 10 minutes before session.
43-
\item \toolref{Autosession} monitors the repository every minute to check for update. It should automatically pull the changes (and output "New session" in console).
44-
\item \toolref{GnuRadio} is launched by \toolref{Autosession} automatically 2 minutes before session start (taken from data.json).
43+
\item Autosession monitors the repository every minute to check for update. It should automatically pull the changes (and output "New session" in console).
44+
\item \toolref{GnuRadio} is launched by Autosession automatically 2 minutes before session start (taken from data.json).
4545
\item At ths point is possible to launch \toolref{Uplink Console}.
46-
\item After session ends, \toolref{Autosession} closes \toolref{GnuRadio}.
47-
\item Instance of \toolref{Autosession} that's running on primary GS will now summarize the session: download all frames from radio.pw-sat.pl, extract beacons, file lists, and run summary.py if available (which is used to decode experiment data and photos automatically). After that all artifacts are pushed to \toolref{Mission Repository} and telemetry is uploaded to \toolref{Grafana}.
46+
\item After session ends, Autosession closes \toolref{GnuRadio}.
47+
\item Instance of Autosession that's running on primary GS will now summarize the session: download all frames from radio.pw-sat.pl, extract beacons, file lists, and run summary.py if available (which is used to decode experiment data and photos automatically). After that all artifacts are pushed to \toolref{Mission Repository} and telemetry is uploaded to \toolref{Grafana}.
4848
\end{enumerate}
4949

5050

tools/grafana.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
\tool{Grafana}
22

3-
http://grafana.pw-sat.pl:3000/
3+
Grafana contains all telemetry information gathered throughout the mission, accessible through visual dashboards. Access it via http://grafana.pw-sat.pl:3000/.

tools/tools-overview.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This section discusses tools available on ground stations. To use them, connect to ground station either by SSH (if console is enough) or VNC (if access to UI is needed).

0 commit comments

Comments
 (0)