Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
rosflight_firmware::StateManager Class Reference

#include <state_manager.h>

Classes

struct  State
 

Public Types

enum  : uint16_t {
  ERROR_NONE = 0x0000, ERROR_INVALID_MIXER = 0x0001, ERROR_IMU_NOT_RESPONDING = 0x0002, ERROR_RC_LOST = 0x0004,
  ERROR_UNHEALTHY_ESTIMATOR = 0x0008, ERROR_TIME_GOING_BACKWARDS = 0x0010, ERROR_UNCALIBRATED_IMU = 0x0020
}
 
enum  Event {
  EVENT_INITIALIZED, EVENT_REQUEST_ARM, EVENT_REQUEST_DISARM, EVENT_RC_LOST,
  EVENT_RC_FOUND, EVENT_ERROR, EVENT_NO_ERROR, EVENT_CALIBRATION_COMPLETE,
  EVENT_CALIBRATION_FAILED
}
 

Public Member Functions

struct __attribute__ ((packed)) BackupData
 Stores backup data for restoring the system state after a hard fault. More...
 
void check_backup_memory ()
 
void clear_error (uint16_t error)
 
void init ()
 
void run ()
 
void set_error (uint16_t error)
 
void set_event (Event event)
 
const Statestate () const
 
 StateManager (ROSflight &parent)
 
void write_backup_data (const BackupData::DebugInfo &debug)
 Write recovery data to backup memory in the case of a hard fault. More...
 

Private Types

enum  FsmState {
  FSM_STATE_INIT, FSM_STATE_PREFLIGHT, FSM_STATE_ARMED, FSM_STATE_ERROR,
  FSM_STATE_FAILSAFE, FSM_STATE_CALIBRATING
}
 

Private Member Functions

void process_errors ()
 
void update_leds ()
 

Private Attributes

FsmState fsm_state_
 
uint32_t hardfault_count_ = 0
 
uint32_t next_arming_error_msg_ms_ = 0
 
uint32_t next_led_blink_ms_ = 0
 
ROSflightRF_
 
State state_
 

Detailed Description

Definition at line 44 of file state_manager.h.

Member Enumeration Documentation

anonymous enum : uint16_t
Enumerator
ERROR_NONE 
ERROR_INVALID_MIXER 
ERROR_IMU_NOT_RESPONDING 
ERROR_RC_LOST 
ERROR_UNHEALTHY_ESTIMATOR 
ERROR_TIME_GOING_BACKWARDS 
ERROR_UNCALIBRATED_IMU 

Definition at line 68 of file state_manager.h.

Enumerator
EVENT_INITIALIZED 
EVENT_REQUEST_ARM 
EVENT_REQUEST_DISARM 
EVENT_RC_LOST 
EVENT_RC_FOUND 
EVENT_ERROR 
EVENT_NO_ERROR 
EVENT_CALIBRATION_COMPLETE 
EVENT_CALIBRATION_FAILED 

Definition at line 55 of file state_manager.h.

Enumerator
FSM_STATE_INIT 
FSM_STATE_PREFLIGHT 
FSM_STATE_ARMED 
FSM_STATE_ERROR 
FSM_STATE_FAILSAFE 
FSM_STATE_CALIBRATING 

Definition at line 170 of file state_manager.h.

Constructor & Destructor Documentation

rosflight_firmware::StateManager::StateManager ( ROSflight parent)

Definition at line 38 of file state_manager.cpp.

Member Function Documentation

struct rosflight_firmware::StateManager::__attribute__ ( (packed)  )
inline

Stores backup data for restoring the system state after a hard fault.

Also stores debugging information to be sent over serial after the connection is restored.

< magic number to ensure we only arm on startup if we really intended to

< number of hard faults since normal system startup

< state manager error codes

< set to ARM_MAGIC if the system was armed when the hard fault occured, 0 otherwise

Low-level debugging information for case of hard fault

It is up to the board support layer to populate this data

< register 0

< register 1

< register 2

< register 3

< register 12

< link register

< program counter

< program status register

< checksum for data in the struct, must be the last member

Computes checksum and prepares struct to be written to backup memory

Precondition
All data fields have been set, no data will be changed between calling this function and writing to memory
Postcondition
Checksum field is set and the struct is ready to be written to backup memory

Checks whether the checksum of a struct read from backup memory is valid

Returns
true The checksum is valid
false The checksum is invalid

Definition at line 85 of file state_manager.h.

void rosflight_firmware::StateManager::check_backup_memory ( )

Definition at line 285 of file state_manager.cpp.

void rosflight_firmware::StateManager::clear_error ( uint16_t  error)

Definition at line 75 of file state_manager.cpp.

void rosflight_firmware::StateManager::init ( )

Definition at line 46 of file state_manager.cpp.

void rosflight_firmware::StateManager::process_errors ( )
private

Definition at line 322 of file state_manager.cpp.

void rosflight_firmware::StateManager::run ( void  )

Definition at line 57 of file state_manager.cpp.

void rosflight_firmware::StateManager::set_error ( uint16_t  error)

Definition at line 66 of file state_manager.cpp.

void rosflight_firmware::StateManager::set_event ( StateManager::Event  event)

Definition at line 91 of file state_manager.cpp.

const State& rosflight_firmware::StateManager::state ( ) const
inline

Definition at line 140 of file state_manager.h.

void rosflight_firmware::StateManager::update_leds ( )
private

Definition at line 330 of file state_manager.cpp.

void rosflight_firmware::StateManager::write_backup_data ( const BackupData::DebugInfo &  debug)

Write recovery data to backup memory in the case of a hard fault.

This function should only be called by the hardfault interrupt handler

Precondition
Called from hardfault interrupt handler
Postcondition
Recovery data has been written to backup RAM and the hardfault interrupt handler may now reset the system
Parameters
debugLow-level debugging data populated by the hardfault handler

Definition at line 273 of file state_manager.cpp.

Member Data Documentation

FsmState rosflight_firmware::StateManager::fsm_state_
private

Definition at line 180 of file state_manager.h.

uint32_t rosflight_firmware::StateManager::hardfault_count_ = 0
private

Definition at line 168 of file state_manager.h.

uint32_t rosflight_firmware::StateManager::next_arming_error_msg_ms_ = 0
private

Definition at line 166 of file state_manager.h.

uint32_t rosflight_firmware::StateManager::next_led_blink_ms_ = 0
private

Definition at line 165 of file state_manager.h.

ROSflight& rosflight_firmware::StateManager::RF_
private

Definition at line 162 of file state_manager.h.

State rosflight_firmware::StateManager::state_
private

Definition at line 163 of file state_manager.h.


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


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Fri Oct 9 2020 03:17:21