Ke Ao Teensy Flight Software
The software on the Teensy in the Ke Ao cubesat.
Loading...
Searching...
No Matches
astrodev_channel.cpp File Reference

The channel controlling the Astrodev (Li-3) radio. More...

#include "channels/artemis_channels.h"
#include <Arduino.h>
#include <astrodev.h>
#include <deque>

Macros

#define ASTRODEV_BAUD   9600
 The baud rate of the serial connection to the radio.
 
#define ASTRODEV_FREQ   435000
 The operating frequency of the Astrodev radio in kHz.
 

Functions

int32_t astrodev_init (HardwareSerial *new_serial, uint32_t baud_rate)
 Helper function to initialize Astrodev radio.
 
int32_t astrodev_recv ()
 Helper function to receive Astrodev frames from the Astrodev radio.
 
int32_t astrodev_send ()
 Helper function to send PacketComm packets through the Astrodev radio.
 

Detailed Description

The channel controlling the Astrodev (Li-3) radio.

This is the channel that controls the Astrodev (Li-3) radio, in parallel to all other channels. When it gets a slice of computing time on the Teensy's processor, it performs actions related to the Astrodev radio. This channel must be written such that it can be interrupted at any time to switch to the next channel.

Todo:

Test astrodev channel without astrodev threads

See if we need individual threads for sending/receiving

Function Documentation

◆ astrodev_init()

int32_t astrodev_init ( HardwareSerial *  new_serial,
uint32_t  baud_rate 
)

Helper function to initialize Astrodev radio.

Parameters
new_serialPointer to a HardwareSerial object representing a serial port on the Teensy.
baud_rateThe baud rate at which to communicate with the Astrodev radio.
Returns
int32_t Returns 0 if successful, -1 if unsuccessful due to checks in this function. May return other negative numbers, indicating error in called functions.

The Astrodev radio is initialized with the passed-in serial port and baud rate.

The Teensy connects to the Astrodev radio over the initialized serial connection. This connection generates no-op and reset Astrodev frames. If these frames are unacknowledged or replied to with a no-ack, the initialization of the Astrodev radio has failed.

The internal Astrodev radio object is configured using pre-defined values.

The configuration settings of the internal Astrodev radio object are applied to the actual Astrodev radio. If the configuration is not sucessfully applied, return with an error code.

The transceiver configuration settings of the actual Astrodev radio are verified by polling the radio. If the Astrodev radio transceiver configuration request cannot be sent, return with an error code. If the request was sent but the settings do not match the internal Astrodev radio object, return -1.

◆ astrodev_recv()

int32_t astrodev_recv ( )

Helper function to receive Astrodev frames from the Astrodev radio.

Returns
int32_t Returns Astrodev frame payload size in bytes. This value is 0 if the frame is an ack-type header-only reply frame. Returns -1 if received frame is of a command type that is not handled. May return other negative values, indicating error in called functions.

The radio is commanded to receive an Astrodev frame. If a frame is received, check its header for its command type. Handle the frame based on this type. See the code for a detailed explaination.

◆ astrodev_send()

int32_t astrodev_send ( )

Helper function to send PacketComm packets through the Astrodev radio.

Returns
int32_t Returns Astrodev frame payload size in bytes. This value includes the Astrodev header, payload (which is the entire PacketComm packet), and Astrodev checksum. Returns -1 if unsucessful. May return other negative values, indicating error in called functions.

The radio is commanded to transmit the internally-defined outgoing packet if the buffer is not full. If the buffer is full, the Teensy waits for a short while before pinging the radio to clear the buffer_full flag and trying again. If the buffer remains full after three tries, return with an error code.