10#include "support/configCosmosKernel.h"
11#include "support/cosmos-errno.h"
12#include "support/packetcomm.h"
14#include <TeensyThreads.h>
23 static constexpr uint8_t
SYNC0 =
'H';
25 static constexpr uint8_t
SYNC1 =
'e';
48 static constexpr uint8_t
MTU = 254;
59 MTU - (COSMOS_SIZEOF(PacketComm::Header) + 2);
601 uint8_t ax25_source[6];
608 uint8_t ax25_destination[6];
1178 uint8_t header_bytes[8];
1198 uint8_t payload[MTU + 20];
1213 int32_t last_error = 0;
1214 std::atomic<bool> buffer_full;
1224 Astrodev(HardwareSerial *hw_serial);
1226 uint32_t baud_rate = 38400);
1239 uint16_t
CalcCS(uint8_t *data, uint16_t size);
1242 void setSerial(HardwareSerial *new_serial);
1245 std::atomic<bool> ack_noop;
1246 std::atomic<bool> ack_reset;
1247 std::atomic<bool> ack_transmit;
1248 std::atomic<bool> ack_setTCVConfig;
1251 HardwareSerial *serial;
1252 bool running =
true;
1254 queue<vector<uint8_t>> queue_in;
1255 Threads::Mutex qmutex_in;
1257 queue<PacketComm> packet_queue_out;
1258 Threads::Mutex qmutex_out;
The satellite's Astrodev (Li-3) radio.
Definition astrodev.h:20
int32_t GetTCVConfig()
Send a get transceiver configuration command to the Astrodev radio.
Definition astrodev.cpp:331
static constexpr uint8_t SYNC0
The first synchronization byte.
Definition astrodev.h:23
int32_t TransmitPacketFromRadio(Cosmos::Support::PacketComm &packet)
Command the Astrodev radio to transmit a PacketComm packet.
Definition astrodev.cpp:367
uint16_t CalcCS(uint8_t *data, uint16_t size)
Calculate a checksum.
Definition astrodev.cpp:510
int32_t SetTCVConfig()
Set transceiver configuration settings on the radio.
Definition astrodev.cpp:431
int32_t NoOp()
Send a no-operation (no-op) command to the Astrodev radio.
Definition astrodev.cpp:296
std::map< uint16_t, uint8_t > RF_INDEX
Mapping of RF baud rate to integer configuration values.
Definition astrodev.h:83
int32_t SendAstrodevFrame(frame &message)
Send an Astrodev frame to the radio.
Definition astrodev.cpp:156
int32_t InitializeSerial(HardwareSerial *hw_serial, uint32_t baud_rate=38400)
Initialization of the serial connection to the Astrodev radio.
Definition astrodev.cpp:42
void setSerial(HardwareSerial *new_serial)
Sets the serial connection used to communicate with the radio.
Definition astrodev.cpp:751
static constexpr uint16_t PACKETCOMM_DATA_SIZE
The maximum size of a PacketComm payload.
Definition astrodev.h:58
static constexpr uint8_t TOTEENSY
A response being sent from the radio.
Definition astrodev.h:41
std::map< uint8_t, uint16_t > RF_BAUD
Mapping of integer configuration values to RF baud rate.
Definition astrodev.h:68
Command
Enumeration of Astrodev commands.
Definition astrodev.h:126
@ TRANSMIT
Send bytes to Astrodev radio.
@ BEACONCONFIG
Set beacon configuration.
@ FLASH
Write to the Astrodev radio's flash memory.
@ GETTCVCONFIG
Get Astrodev radio configuration.
@ FIRMWAREPACKET
Firmware packet write.
@ GET_RTC
Get Real-Time Clock (RTC) values.
@ WRITE_KEY_B_256
Used to write to the firmware.
@ WRITE_KEY_A_256
Used to write to the firmware.
@ SET_RTC
Set Real-Time Clock (RTC).
@ WRITE_KEY_B_128
Used to write to the firmware.
@ RFCONFIG
Low level RF configuration.
@ RECEIVE
Receive bytes from Astrodev radio.
@ WRITE_KEY_A_128
Used to write to the firmware.
@ BEACONDATA
Set beacon contents.
@ FASTSETPA
Set power amplifier level (high speed)
@ DIOKEY
Digital I/O (DIO) key write.
@ RESET
Reset Astrodev radio processors and systems.
@ ALARM_RTC
An alarm on the Real-Time Clock (RTC).
@ SETTCVCONFIG
Set Astrodev radio configuration.
@ FIRMWAREUPDATE
Firmware update command.
@ FIRMWAREREV
Firmware number, a 4-byte float.
static constexpr uint8_t SYNC1
The second synchronization byte.
Definition astrodev.h:25
int32_t SendHeaderOnlyFrame(Command command)
Helper function to construct and send header-only command frames to the Astrodev radio.
Definition astrodev.cpp:258
int32_t ReceiveAstrodevFrame(frame &message)
Receive an Astrodev frame from the radio.
Definition astrodev.cpp:546
OACommand
Enumeration of Over-the-Air (OA) Astrodev commands.
Definition astrodev.h:177
@ RADIO_RESET
Soft reset the radio.
@ PING_RETURN
Responds with telemetry structure.
@ PIN_TOGGLE
Directly toggle over-the-air pin.
int32_t GetTelemetry()
Sends a get telemetry command to the Astrodev radio.
Definition astrodev.cpp:346
std::map< uint16_t, uint8_t > UART_INDEX
Mapping of serial baud rate to integer configuration values.
Definition astrodev.h:112
static constexpr uint8_t TORADIO
A command being sent from the Teensy.
Definition astrodev.h:33
Astrodev()
Construct a new Astrodev:: Astrodev object.
Definition astrodev.cpp:17
static constexpr uint8_t MTU
The Maximum Transmission Units (MTU).
Definition astrodev.h:48
Modulation
Enumeration of Astrodev modulation types.
Definition astrodev.h:160
@ ASTRODEV_MODULATION_AFSK
@ ASTRODEV_MODULATION_NONE
No modulation.
@ ASTRODEV_MODULATION_GFSK
@ ASTRODEV_MODULATION_BPSK
int32_t VerifyConnection()
Verify serial connection to the Astrodev radio.
Definition astrodev.cpp:62
int32_t SetRFConfig(rf_config config)
Sets the RF configuration settings on the radio.
Definition astrodev.cpp:477
int32_t Reset()
Send a soft reset command to the Astrodev radio.
Definition astrodev.cpp:316
std::map< uint8_t, uint16_t > UART_BAUD
Mapping of integer configuration values to serial baud rate.
Definition astrodev.h:98
Definitions of Serial Console helper functions.
Structure for beacon configuration.
Definition astrodev.h:1043
uint8_t beacon_interval
The interval at which the beacon should be transmitted.
Definition astrodev.h:1051
uint16_t cs
Beacon configuration checksum.
Definition astrodev.h:1057
Structure for radio firmware version communication.
Definition astrodev.h:888
float rev
The firmware revision of the radio.
Definition astrodev.h:896
uint16_t cs
Firmware checksum.
Definition astrodev.h:902
Structure of Astrodev Command and Data Interface (CDI) frame.
Definition astrodev.h:1070
Structure for configuring discrete Astrodev radio functions.
Definition astrodev.h:235
uint16_t tlm_packet_logging_rate
Telemetry packet logging rate.
Definition astrodev.h:319
uint16_t tx_crc_enable
Enable CRC for transmitted packets.
Definition astrodev.h:297
uint16_t rx_crc_enable
Enable CRC for received packets.
Definition astrodev.h:286
uint16_t config2_pin13_functions
Pin 13 configuration options.
Definition astrodev.h:257
uint16_t radio_reset_enable
Enable radio reset.
Definition astrodev.h:357
uint16_t oa_commands_enable
Enable Over-the-Air (OA) commands.
Definition astrodev.h:339
uint16_t config1_pin14_dio_pattern
Pin 14 Digital I/O (DIO) enable pattern.
Definition astrodev.h:276
uint16_t config1_pin14_dio_enable
Pin 14 Digital I/O (DIO) enable options.
Definition astrodev.h:267
uint16_t tlm_packet_logging_enable
Enable telemetry packets.
Definition astrodev.h:307
uint16_t ext_event_pin12_functions
Pin 12 external event functions.
Definition astrodev.h:246
uint16_t factory_defaults_restored
Factory settings restore complete flag.
Definition astrodev.h:366
uint16_t tlm_dump_enable
Enable telemetry dump.
Definition astrodev.h:329
uint16_t code_upload_enable
Enable code uploading.
Definition astrodev.h:348
Structure for configuring more discrete Astrodev radio functions.
Definition astrodev.h:419
uint16_t rx_afc_enable
Enable receiver Automatic Frequency Control (AFC).
Definition astrodev.h:429
uint16_t zeros
Padding bits.
Definition astrodev.h:470
uint16_t test_mode_rx_cw
Enable receive Continuous Wave (CW) mode.
Definition astrodev.h:440
uint16_t test_mode_tbd
Enable a To-Be-Determined (TBD) test mode.
Definition astrodev.h:461
uint16_t test_mode_tx_cw
Enable transmit Continuous Wave (CW) mode.
Definition astrodev.h:451
Structure for radio Real-Time Clock (RTC) communication.
Definition astrodev.h:926
uint8_t min
The minute of a time.
Definition astrodev.h:968
uint8_t dow
The day of week of a date.
Definition astrodev.h:954
uint8_t hour
The hour of a time.
Definition astrodev.h:961
uint8_t sec
The second of a time.
Definition astrodev.h:975
uint8_t mon
The month of a date.
Definition astrodev.h:940
uint8_t alarm_day
The alarm day.
Definition astrodev.h:991
uint8_t day
The day of a date.
Definition astrodev.h:947
uint8_t alarm_hour
The alarm hour.
Definition astrodev.h:999
uint16_t year
The year of a date.
Definition astrodev.h:933
uint8_t alarm_dow
The alarm day of week.
Definition astrodev.h:983
uint8_t alarm_min
The alarm minute.
Definition astrodev.h:1007
The structure for a response from the Astrodev radio.
Definition astrodev.h:199
bool external_event_high
Whether or not an external event has been triggered.
Definition astrodev.h:209
bool gpio_a_high
Whether or not the GPIO A pin is on.
Definition astrodev.h:205
bool gpio_b_high
Whether or not the GPIO B pin is on.
Definition astrodev.h:207
uint8_t ack
The acknowledgement from the radio.
Definition astrodev.h:201
bool buffer_full
Whether or not the buffer is full.
Definition astrodev.h:203
Structure for configuring the RF functions of the Astrodev radio.
Definition astrodev.h:698
uint8_t front_end_level
The amplification level of the front end of the radio.
Definition astrodev.h:707
uint16_t rx_freq
The recieve frequency offset.
Definition astrodev.h:741
uint16_t tx_freq
The transmit frequency offset.
Definition astrodev.h:729
uint8_t power_amp_level
The amplification level of the power amplifier of the radio.
Definition astrodev.h:717
Structure for configuring the Astrodev radio.
Definition astrodev.h:508
uint16_t ax25_postamble_length
AX25 Mode transmit postamble length.
Definition astrodev.h:620
uint8_t tx_baud_rate
The RF transmit baud rate.
Definition astrodev.h:563
uint32_t tx_frequency
The operating frequency for the transmitter.
Definition astrodev.h:595
uint32_t rx_frequency
The operating frequency for the receiver.
Definition astrodev.h:588
uint8_t rx_baud_rate
The RF receive baud rate.
Definition astrodev.h:548
Devices::Astrodev::Modulation tx_modulation
The modulation for the transmitter.
Definition astrodev.h:581
function_config2 config2
More discrete radio function configuration.
Definition astrodev.h:636
Devices::Astrodev::Modulation rx_modulation
The modulation for the receiver.
Definition astrodev.h:572
function_config1 config1
Discrete radio function configuration.
Definition astrodev.h:628
uint16_t ax25_preamble_length
AX25 Mode transmit preamble length.
Definition astrodev.h:614
uint8_t interface_baud_rate
The baud rate of the radio's serial interface.
Definition astrodev.h:523
uint8_t power_amp_level
The transmit power amplifier level.
Definition astrodev.h:533
Structure for configuring telemetry data for the Astrodev radio.
Definition astrodev.h:770
uint8_t rtc_alarm_flag
Real-Time Clock (RTC) alarm flag.
Definition astrodev.h:833
uint8_t rssi
The Received Signal Strength Indicator (RSSI).
Definition astrodev.h:803
unsigned time_count
Timestamp of telemetry data.
Definition astrodev.h:794
uint16_t op_counter
Operations counter.
Definition astrodev.h:777
uint32_t bytes_rx
The total number of bytes received.
Definition astrodev.h:810
uint8_t rssi_last
The last recorded Recieved Signal Strength Indicator (RSSI).
Definition astrodev.h:826
int16_t msp430_temp
Radio temperature.
Definition astrodev.h:786
uint16_t cs
Telemetry checksum.
Definition astrodev.h:839
uint32_t bytes_tx
The total number of bytes transmitted.
Definition astrodev.h:817
The payload of the radio data frame.
Definition astrodev.h:1188
firmware firmw
Firmware version.
Definition astrodev.h:1204
rf_config rf
RF configuration.
Definition astrodev.h:1202
tcv_config tcv
Transciever configuration.
Definition astrodev.h:1200
telemetry telem
Telemetry data.
Definition astrodev.h:1206
realtimeclock rtc
Real-Time Clock (RTC) data.
Definition astrodev.h:1208