Artemis Teensy Flight Software
The software on the Teensy in the Artemis cubesat.
Artemis::Devices::PDU Class Reference

The PDU class. More...

#include <pdu.h>

Classes

struct  pdu_packet
 The PDU packet structure. More...
 
struct  pdu_telem
 The PDU telemetry packet structure. More...
 

Public Types

enum class  PDU_Type : uint8_t {
  NOP , CommandPing , CommandSetSwitch , CommandGetSwitchStatus ,
  DataPong , DataSwitchStatus , DataSwitchTelem
}
 Enumeration of PDU packet types.
 
enum class  PDU_SW : uint8_t {
  None , All , SW_3V3_1 , SW_3V3_2 ,
  SW_5V_1 , SW_5V_2 , SW_5V_3 , SW_5V_4 ,
  SW_12V , VBATT , WDT , HBRIDGE1 ,
  HBRIDGE2 , BURN , BURN1 , BURN2 ,
  RPI
}
 Enumeration of PDU switches.
 
enum class  PDU_SW_State : bool { SWITCH_OFF , SWITCH_ON }
 Enumeration of PDU switch state.
 

Public Member Functions

 PDU (HardwareSerial *hw_serial, int baud_rate)
 Construct a new PDU object. More...
 
bool ping ()
 Ping the PDU. More...
 
bool set_switch (PDU_SW sw, PDU_SW_State state)
 Set a switch on the PDU. More...
 
bool set_heater (PDU_SW_State state)
 Wrapper function to set the heater switch. More...
 
bool set_burn_wire (PDU_SW_State state)
 Wrapper function to set the burn wire switch. More...
 
bool refresh_switch_states ()
 Refresh the internal PDU class's switch states. More...
 

Public Attributes

std::map< std::string, PDU_SWPDU_SW_Type
 Mapping between PDU switches and their string names. More...
 
PDU_SW_State switch_states [NUMBER_OF_SWITCHES]
 The status of each switch on the PDU. More...
 

Detailed Description

The PDU class.

Constructor & Destructor Documentation

◆ PDU()

Artemis::Devices::PDU::PDU ( HardwareSerial *  hw_serial,
int  baud_rate 
)

Construct a new PDU object.

Parameters
hw_serialThe HardwareSerial connection unique to this instance.
baud_rateThe baud rate of the serial connection to the PDU.

Member Function Documentation

◆ ping()

bool Artemis::Devices::PDU::ping ( )

Ping the PDU.

Returns
true The PDU replied to the ping request with a pong reply.
false There was an error in sending the ping request or receiving the pong reply.

◆ refresh_switch_states()

bool Artemis::Devices::PDU::refresh_switch_states ( )

Refresh the internal PDU class's switch states.

Returns
true The switch states have been updated successfully and can be trusted.
false The switch state request failed to be sent or replied to.

◆ set_burn_wire()

bool Artemis::Devices::PDU::set_burn_wire ( PDU_SW_State  state)

Wrapper function to set the burn wire switch.

Parameters
stateThe desired state of the burn wire.
Returns
true The burn wire switch has been successfully set.
false The burn wire switch failed to be set.

◆ set_heater()

bool Artemis::Devices::PDU::set_heater ( PDU_SW_State  state)

Wrapper function to set the heater switch.

Parameters
stateThe desired state of the heater.
Returns
true The heater switch has been successfully set.
false The heater switch failed to be set.

◆ set_switch()

bool Artemis::Devices::PDU::set_switch ( PDU_SW  sw,
PDU_SW_State  state 
)

Set a switch on the PDU.

Parameters
swThe PDU_SW representing the switch on the PDU to be set.
stateThe desired switch state.
Returns
true The switch has been successfully set to the desired state.
false There was an issue setting the switch or receiving the reply, or the switch was not set.
Todo:
This function should check the switch state and ensure it matches what we expect. However, the reply from the PDU with the switch state should still be used to update the internal PDU class switch state, even if the switch hasn't been set.

Member Data Documentation

◆ PDU_SW_Type

std::map<std::string, PDU_SW> Artemis::Devices::PDU::PDU_SW_Type
Initial value:
= {
{ "all", PDU_SW::All},
{ "3v3_1", PDU_SW::SW_3V3_1},
{ "3v3_2", PDU_SW::SW_3V3_2},
{ "5v_1", PDU_SW::SW_5V_1},
{ "5v_2", PDU_SW::SW_5V_2},
{ "5v_3", PDU_SW::SW_5V_3},
{ "5v_4", PDU_SW::SW_5V_4},
{ "12v", PDU_SW::SW_12V},
{ "vbatt", PDU_SW::VBATT},
{ "wdt", PDU_SW::WDT},
{"hbridge1", PDU_SW::HBRIDGE1},
{"hbridge2", PDU_SW::HBRIDGE2},
{ "burn", PDU_SW::BURN},
{ "burn1", PDU_SW::BURN1},
{ "burn2", PDU_SW::BURN2},
{ "rpi", PDU_SW::RPI},
}

Mapping between PDU switches and their string names.

◆ switch_states

PDU_SW_State Artemis::Devices::PDU::switch_states[NUMBER_OF_SWITCHES]

The status of each switch on the PDU.

Todo:
Make this private.

The documentation for this class was generated from the following files: