Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MIDAS/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.pio
.vscode
/src/log_checksum.h
**/.DS_Store
*.launch
2 changes: 2 additions & 0 deletions MIDAS/lib/ADS7138Q1/ads7138-q1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ bool ADS7138Init(){
AdcRegReadResult reg = adc_reg_read(ADC_ADDR, ADC_SYSTEM_STATUS);
if(reg.error != AdcError::NoError){
return false;
} else{
//process profiling continuity sensor initialize error
}
return reg.value != 0;
}
1 change: 1 addition & 0 deletions MIDAS/lib/ADXL355/PL_ADXL355.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ namespace PL {
SPI.begin();
pinMode(csPin, OUTPUT);
digitalWrite(csPin, HIGH);
//process profiling acceleration lowG
}

//==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion MIDAS/lib/Adafruit BNO08x/src/Adafruit_BNO08x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ bool Adafruit_BNO08x::begin_SPI(uint8_t cs_pin, uint8_t int_pin,
_HAL.getTimeUs = hal_getTimeUs;

return _init(sensor_id);
}
}//process profiling orientation

/*! @brief Initializer for post i2c/spi init
* @param sensor_id Optional unique ID for the sensor set
Expand Down
4 changes: 2 additions & 2 deletions MIDAS/lib/Arduino_LSM6DS3/src/LSM6DS3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ int LSM6DS3Class::begin()

// Set the ODR config register to ODR/4
writeRegister(LSM6DS3_CTRL8_XL, 0x09);

//process profiling acceleration initialized
return 1;
}
}//process profiling lowglsm

void LSM6DS3Class::end()
{
Expand Down
2 changes: 1 addition & 1 deletion MIDAS/lib/MS5611/MS5611.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void MS5611::init() {
C[reg] = readProm(reg);
}
SPI.endTransaction();
}
}//process profiling barometer initialized

int MS5611::read(uint8_t bits) {
// VARIABLES NAMES BASED ON DATASHEET <- Nice!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ bool QwiicKX134::beginSPI(uint8_t csPin, uint32_t spiPortSpeed,
return true;
else
return false;
}
}//process profiling acceleration highG

// Grabs raw accel data and passes it to the following function to be
// converted.
Expand Down
7 changes: 7 additions & 0 deletions MIDAS/lib/X-NUCLEO-GNSS1A1/src/teseo_liv3f_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@




/*
* Constant for strtol base param
*/
Expand Down Expand Up @@ -99,6 +100,10 @@ GNSS_StatusTypeDef TeseoLIV3F::I2CUpdate()
{
GNSS_PARSER_ParseMsg(&data, (eNMEAMsg)m, buffer);
}
} else{
//process profiling
//LogMessage error;
//error.message = 'GNSS PARSER ERROR';
}
strncpy(i2ch.inputString, i2ch.inputString2, sizeof(i2ch.inputString));
memset(i2ch.inputString2, 0, sizeof(i2ch.inputString2));
Expand Down Expand Up @@ -127,6 +132,8 @@ GNSS_StatusTypeDef TeseoLIV3F::UARTUpdate()
{
GNSS_PARSER_ParseMsg(&data, (eNMEAMsg)m, buffer);
}
} else{
//process profiling
}
memset(uarth.inputString, 0, sizeof(uarth.inputString));
uarth.stringComplete = false;
Expand Down
2 changes: 1 addition & 1 deletion MIDAS/lib/X-NUCLEO-GNSS1A1/src/teseo_liv3f_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class TeseoLIV3F
Wire.endTransmission(false);
delay(2000);
return GNSS_OK;
}
}//process profiling

/**
* @brief Update the internal data structures of the sensor using the appropriate communication method
Expand Down
10 changes: 9 additions & 1 deletion MIDAS/src/data_logging.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "data_logging.h"
#include "log_format.h"
#include "log_checksum.h"

#include <queue>
/**
* @brief Forward decleration of the ID recieving function
*/
Expand All @@ -11,6 +11,10 @@ constexpr ReadingDiscriminant get_discriminant();
/**
* @brief macro to associate a certain sensor with a specific number ID
*/

//std::queue<char[32]> logQueue; // data logging for process profiling


#define ASSOCIATE(ty, id) template<> constexpr ReadingDiscriminant get_discriminant<ty>() { return ReadingDiscriminant::id; }

ASSOCIATE(LowGData, ID_LOWG)
Expand All @@ -25,6 +29,8 @@ ASSOCIATE(Orientation, ID_ORIENTATION)
ASSOCIATE(FSMState, ID_FSM)
ASSOCIATE(KalmanData, ID_KALMAN)
ASSOCIATE(PyroState, ID_PYRO)
ASSOCIATE(ProcessTime, ID_PROCESSTIME);
ASSOCIATE(LogMessages, ID_LOGMESSAGES)

/**
* @brief writes a reading, with its ID, timestamp, and data to a specific sink
Expand Down Expand Up @@ -88,6 +94,8 @@ void log_data(LogSink& sink, RocketData& data) {
log_from_sensor_data(sink, data.fsm_state);
log_from_sensor_data(sink, data.kalman);
log_from_sensor_data(sink, data.pyro);
log_from_sensor_data(sink, data.processTime);
log_from_sensor_data(sink, data.logMessages);
}

#ifndef SILSIM
Expand Down
5 changes: 4 additions & 1 deletion MIDAS/src/hardware/Barometer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "sensors.h"
#include <MS5611.h>
#include <queue>

MS5611 MS(MS5611_CS); //singleton object for the MS sensor
extern std::queue<std::string> logQueue;

/**
* @brief Initializes barometer, returns NoError
Expand All @@ -10,7 +12,8 @@ MS5611 MS(MS5611_CS); //singleton object for the MS sensor
*/
ErrorCode BarometerSensor::init() {
MS.init();

//process profiling
logQueue.push("BarometerInitialized");
return ErrorCode::NoError;
}

Expand Down
5 changes: 4 additions & 1 deletion MIDAS/src/hardware/Continuity.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include "sensors.h"
#include "ads7138-q1.h"
#include <hal.h>
#include <queue>


#define PYRO_VOLTAGE_DIVIDER (5.0 / (5.0 + 20.0)) //voltage divider for pyro batt voltage, check hardware schematic
#define CONT_VOLTAGE_DIVIDER (5.0 / (5.0 + 20.0)) //voltage divider for continuity voltage, check hardware schematic
extern std::queue<std::string> logQueue;

/**
* @brief Initializes ADC, returns NoError
Expand All @@ -12,7 +15,7 @@
*/
ErrorCode ContinuitySensor::init() {
ADS7138Init(); // Ask ADS to init the pins, we still need to get the device to actually read

logQueue.push("BarometerInitialized");//process profiling
return ErrorCode::NoError;
}

Expand Down
2 changes: 1 addition & 1 deletion MIDAS/src/hardware/Emmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ ErrorCode EMMCSink::init(){
if (!file) {
return ErrorCode::EmmcCouldNotOpenFile;
}

//process profiling
return ErrorCode::NoError;
}
2 changes: 1 addition & 1 deletion MIDAS/src/hardware/GPSSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TeseoLIV3F teseo(&Wire, GPS_RESET, GPS_ENABLE); // singleton for the teseo g
*/
ErrorCode GPSSensor::init() {
teseo.init(); // always returns ok for some reason

//process profiling
return ErrorCode::NoError;
}

Expand Down
9 changes: 9 additions & 0 deletions MIDAS/src/hardware/HighG.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "sensors.h"
#include "SparkFun_Qwiic_KX13X.h"
#include <queue>

QwiicKX134 KX; // global static instance of the sensor
extern std::queue<std::string> logQueue;

/**
* @brief Initializes the high G sensor
Expand All @@ -11,15 +13,22 @@ QwiicKX134 KX; // global static instance of the sensor
ErrorCode HighGSensor::init() {
KX.beginSPI(KX134_CS);
if (!KX.initialize(DEFAULT_SETTINGS)) {

logQueue.push("HighGCouldNotBeInitialized");//process profiling
return ErrorCode::HighGCouldNotBeInitialized;
}

if(!KX.setOutputDataRate(0xb)) {
logQueue.push("HighGCouldNotUpdateDataRate");//process profiling
return ErrorCode::HighGCouldNotUpdateDataRate;
}


logQueue.push("HighGInitialized");//process profiling
KX.setRange(3);
return ErrorCode::NoError;


}

/**
Expand Down
3 changes: 2 additions & 1 deletion MIDAS/src/hardware/LowG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ ErrorCode LowGSensor::init() {
// todo set low pass filter frequency to 250hx
sensor.enableMeasurement();
return error;
}
//process profiling
}

/**
* @brief Reads and returns the data from the sensor
Expand Down
1 change: 1 addition & 0 deletions MIDAS/src/hardware/LowGLSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ErrorCode LowGLSMSensor::init() {
return ErrorCode::GyroCouldNotBeInitialized;
}
return ErrorCode::NoError;
//process profiling
}

/**
Expand Down
18 changes: 15 additions & 3 deletions MIDAS/src/hardware/Magnetometer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <Adafruit_LIS3MDL.h>

#include <queue>
#include "sensors.h"
#include "hal.h"

extern std::queue<std::string> logQueue; // global variable queue for logging the important status of the sensor.

Adafruit_LIS3MDL LIS3MDL; // global static instance of the sensor

ErrorCode MagnetometerSensor::init() {
Expand All @@ -11,9 +13,13 @@ ErrorCode MagnetometerSensor::init() {
}
LIS3MDL.setOperationMode(LIS3MDL_CONTINUOUSMODE); // Reading continuously, instead of single-shot or off
LIS3MDL.setDataRate(LIS3MDL_DATARATE_155_HZ);
LIS3MDL.setRange(LIS3MDL_RANGE_4_GAUSS); // Earth's magnetic field is 1/2 gauss, can detect high current
LIS3MDL.setRange(LIS3MDL_RANGE_4_GAUSS);
// Earth's magnetic field is 1/2 gauss, can detect high current
char message[64];
snprintf(message, sizeof(message), "MagnetometerInitizedW/Mode:%dRate:%dRange:%d", LIS3MDL_CONTINUOUSMODE, static_cast<int>(LIS3MDL_DATARATE_155_HZ), LIS3MDL_RANGE_4_GAUSS);
logQueue.push(message);
return ErrorCode::NoError;
}
}//process profiling

Magnetometer MagnetometerSensor::read() {
// read from aforementioned global instance of sensor
Expand All @@ -25,3 +31,9 @@ Magnetometer MagnetometerSensor::read() {
Magnetometer reading{mx, my, mz};
return reading;
}

//void addMessageQueue(String m){
// char message[64];
//snprintf(message, sizeof(message), m);
//logQueue.push(message);
//}
2 changes: 1 addition & 1 deletion MIDAS/src/hardware/Orientation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ErrorCode OrientationSensor::init() {
return ErrorCode::CannotInitBNO;
}
return ErrorCode::NoError;
}
}//process profiling

/**
* @brief Turns a quaternion into its corresponding Euler 3D vector representation
Expand Down
2 changes: 1 addition & 1 deletion MIDAS/src/hardware/Pyro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ErrorCode Pyro::init() {
// } else {
return ErrorCode::NoError; // GPIO Driver always claimes it errored even when it doesn't.
// }
}
}//process profiling

#ifdef IS_SUSTAINER

Expand Down
2 changes: 1 addition & 1 deletion MIDAS/src/hardware/SDLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ErrorCode SDSink::init() {
}

return ErrorCode::NoError;
}
}//process profiling

/**
* @brief Writes a byte buffer to the SD card
Expand Down
2 changes: 2 additions & 0 deletions MIDAS/src/log_checksum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// autogenerated on build by applying crc32 on the concatenation of log_format.h and sensor_data.h
#define LOG_CHECKSUM (0xb8f3527e)
4 changes: 4 additions & 0 deletions MIDAS/src/log_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ enum ReadingDiscriminant {
ID_FSM = 10,
ID_KALMAN = 11,
ID_PYRO = 12,
ID_PROCESSTIME = 13,
ID_LOGMESSAGES = 14
};


Expand Down Expand Up @@ -51,5 +53,7 @@ struct LoggedReading {
KalmanData kalman;
FSMState fsm;
PyroState pyro;
ProcessTime processtime;
LogMessages logMessages;
} data;
};
2 changes: 2 additions & 0 deletions MIDAS/src/rocket_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ struct RocketData {
SensorData<Magnetometer> magnetometer;
SensorData<Orientation> orientation;
SensorData<Voltage> voltage;
SensorData<ProcessTime> processTime;
SensorData<LogMessages> logMessages;

Latency log_latency;
};
30 changes: 30 additions & 0 deletions MIDAS/src/sensor_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,33 @@ struct PyroState {
bool is_global_armed = false;
PyroChannel channels[4];
};

enum class ProcessName {
TELEMETRY = 1,
ORIENTATION = 2,
KALMAN = 3,
BUZZER = 4,
FSM = 5,
I2C = 6,
MAGNETOMETER = 7,
ACCELEROMETERS = 8,
BAROMETER = 9,
LOGGER = 10
};

/**
* @struct ProcessTime
*
* @brief The process time of the processes in the thread
*/
struct ProcessTime
{
ProcessName name;
float dt;
};

struct LogMessages
{
char message[64];
};

Loading