diff --git a/radsat-sk/framework/fileio/RFram.c b/radsat-sk/framework/fileio/RFram.c index 63d0244e..4d158e05 100644 --- a/radsat-sk/framework/fileio/RFram.c +++ b/radsat-sk/framework/fileio/RFram.c @@ -8,6 +8,7 @@ #include #include #include +#include /*************************************************************************************************** @@ -34,7 +35,8 @@ int framInit(void) { int error = FRAM_start(); - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) + errorReportComponent(componentHalFram , error); return error; } @@ -57,7 +59,8 @@ int framRead(uint8_t* data, uint32_t address, uint32_t size) { int error = FRAM_read(data, address, size); - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) + errorReportComponent(componentHalFram , error); return error; } @@ -80,7 +83,8 @@ int framWrite(uint8_t* data, uint32_t address, uint32_t size) { int error = FRAM_writeAndVerify(data, address, size); - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) + errorReportComponent(componentHalFram , error); return error; } diff --git a/radsat-sk/operation/message/crypt/RKey.c b/radsat-sk/operation/message/crypt/RKey.c index 64aaaff8..b5768b56 100644 --- a/radsat-sk/operation/message/crypt/RKey.c +++ b/radsat-sk/operation/message/crypt/RKey.c @@ -7,6 +7,7 @@ #include #include #include +#include /*************************************************************************************************** @@ -55,13 +56,22 @@ uint8_t privateKey(void) { int error = 0; // read from FRAM - error = framRead(&key1, PRIVATE_KEY_ADDR_ONE, sizeof(key1)); - if (error) return 0; + error = framRead(&key1, PRIVATE_KEY_ADDR_ONE, sizeof(key1)) + + if (error != SUCCESS) + errorReportModule(moduleFram , error); + return error; + error = framRead(&key2, PRIVATE_KEY_ADDR_TWO, sizeof(key2)); - if (error) return 0; + + if (error != SUCCESS) + errorReportModule(moduleFram , error); + return error; error = framRead(&key3, PRIVATE_KEY_ADDR_THREE, sizeof(key3)); - if (error) return 0; + if (error != SUCCESS) + errorReportModule(moduleFram , error); + return error; // all of the keys are the same if ((key1 == key2) && (key1 == key3) && (key2 == key3)) { key = key1; @@ -108,7 +118,6 @@ uint8_t privateKey(void) { debugPrint("RKey: all three keys are different (Key1 = %d, Key2 = %d, Key3 = %d). Sending Key1...\n", key1, key2, key3); - // TODO: report an error to the system manager key = key1; } diff --git a/radsat-sk/operation/services/RFileTransferService.c b/radsat-sk/operation/services/RFileTransferService.c index 40c9ce0f..2845fa16 100644 --- a/radsat-sk/operation/services/RFileTransferService.c +++ b/radsat-sk/operation/services/RFileTransferService.c @@ -10,6 +10,7 @@ #include #include #include +#include /** diff --git a/radsat-sk/operation/subsystems/RAntenna.c b/radsat-sk/operation/subsystems/RAntenna.c index e52186a5..d29834af 100644 --- a/radsat-sk/operation/subsystems/RAntenna.c +++ b/radsat-sk/operation/subsystems/RAntenna.c @@ -10,6 +10,7 @@ #include #include #include +#include /*************************************************************************************************** @@ -54,7 +55,9 @@ int antennaInit(void) { if (error == 0) antennaInitialized = 1; - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) + errorReportComponent(moduleFram , error) + return error; } @@ -80,7 +83,7 @@ int antennaDeploymentAttempt(void) { // Error check for requesting antenna status if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); return error; } @@ -101,7 +104,9 @@ int antennaDeploymentAttempt(void) { // Error check for Arming A Side if(error != 0) { - // TODO: record errors (if present) to System Manager + + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -111,7 +116,8 @@ int antennaDeploymentAttempt(void) { // Error check for antenna status if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -127,7 +133,8 @@ int antennaDeploymentAttempt(void) { // Check if autoDeployment failed if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -137,7 +144,8 @@ int antennaDeploymentAttempt(void) { // Check if disarm failed if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } } @@ -159,7 +167,8 @@ int antennaDeploymentAttempt(void) { // Error check for requesting antenna status if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -180,7 +189,8 @@ int antennaDeploymentAttempt(void) { // Error check for requesting antenna status if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -190,7 +200,8 @@ int antennaDeploymentAttempt(void) { // Error check for antenna status if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -206,7 +217,9 @@ int antennaDeploymentAttempt(void) { // Check if autoDeployment failed if(error != 0) { - // TODO: record errors (if present) to System Manager + + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -216,7 +229,8 @@ int antennaDeploymentAttempt(void) { // Check if disarm failed if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } } @@ -253,7 +267,8 @@ int antennaTelemetry(antenna_telemetry_t* telemetry) { // Error check for Isis Antenna function if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -272,7 +287,8 @@ int antennaTelemetry(antenna_telemetry_t* telemetry) { // Error check for Isis Antenna function if(error != 0) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -299,15 +315,17 @@ int antennaReset(void) { int error = IsisAntS_reset(ANTENNA_INDEX, isisants_sideA); if (error != SUCCESS) { - // TODO: record errors (if present) to System Manager + + errorReportComponent(componentSsiAntenna,error); + return error; } // Reset side B antenna. See section 6.2 of Antenna System User Manual error = IsisAntS_reset(ANTENNA_INDEX, isisants_sideB); - if (error != SUCCESS) { - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) { + errorReportComponent(componentSsiAntenna,error); } return error; @@ -328,7 +346,8 @@ int antennaTemperature(float* temperatureOne, float* temperatureTwo) { int error = IsisAntS_getTemperature(ANTENNA_INDEX, isisants_sideA, &temperature); if (error != SUCCESS) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); + return error; } @@ -339,7 +358,7 @@ int antennaTemperature(float* temperatureOne, float* temperatureTwo) { *temperatureTwo = ((float)temperature * -0.2922) + 190.65; if (error != SUCCESS) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentSsiAntenna,error); } return error; diff --git a/radsat-sk/operation/subsystems/RBattery.c b/radsat-sk/operation/subsystems/RBattery.c index e6a89f51..1ca7df8b 100644 --- a/radsat-sk/operation/subsystems/RBattery.c +++ b/radsat-sk/operation/subsystems/RBattery.c @@ -110,6 +110,11 @@ static uint32_t batteryTemperatureCommandBytes[4] = { 0x10E3B8 // Daughterboard 3 Temperature }; +/** + * Command for Resetting Battery Watchdog (0x2200) + */ +static uint8_t batteryWatchdogResetCommand[2] = {0x22, 0x00}; + /*************************************************************************************************** PRIVATE FUNCTION STUBS ***************************************************************************************************/ @@ -246,6 +251,21 @@ int batteryIsNotSafe(uint8_t* safeFlag) { return SUCCESS; } +/** + * Pet the Communications watchdog on the Battery using code 0x22 + * @return either an error if it occurred, or 0 + */ +int batteryPetWatchDog(void) { + // One way communication so just use transmit using reset watchdog command 0x22 + int error = i2cTransmit(BATTERY_I2C_SLAVE_ADDR, batteryWatchdogResetCommand, BATTERY_COMMAND_LENGTH); + + if (error != SUCCESS) { + return error; + } + + return SUCCESS; +} + /*************************************************************************************************** PRIVATE FUNCTIONS diff --git a/radsat-sk/operation/subsystems/RBattery.h b/radsat-sk/operation/subsystems/RBattery.h index a6da0d06..031ddc9b 100644 --- a/radsat-sk/operation/subsystems/RBattery.h +++ b/radsat-sk/operation/subsystems/RBattery.h @@ -42,6 +42,6 @@ typedef struct _battery_status_t { int batteryTelemetry(battery_status_t* dataStorage); int batteryIsNotSafe(uint8_t* safeFlag); - +int batteryPetWatchdog(void); #endif /* RBATTERY_H_ */ diff --git a/radsat-sk/operation/subsystems/RObc.c b/radsat-sk/operation/subsystems/RObc.c index ff108dad..779b4e7d 100644 --- a/radsat-sk/operation/subsystems/RObc.c +++ b/radsat-sk/operation/subsystems/RObc.c @@ -9,6 +9,7 @@ #include #include #include +#include /*************************************************************************************************** PUBLIC API @@ -24,7 +25,7 @@ int obcTelemetry(obc_telemetry_t* telemetry){ int error = RTC_getTemperature(&temperature); if (error != SUCCESS) { - // TODO: record errors (if present) to System Manager + errorReportComponent(componentObc,error); return error; } diff --git a/radsat-sk/operation/subsystems/RPdb.c b/radsat-sk/operation/subsystems/RPdb.c index a0732396..1ba8a620 100644 --- a/radsat-sk/operation/subsystems/RPdb.c +++ b/radsat-sk/operation/subsystems/RPdb.c @@ -8,6 +8,7 @@ #include #include #include +#include /*************************************************************************************************** diff --git a/radsat-sk/operation/subsystems/RPdb.h b/radsat-sk/operation/subsystems/RPdb.h index b3d4cd1b..e19b0ad9 100644 --- a/radsat-sk/operation/subsystems/RPdb.h +++ b/radsat-sk/operation/subsystems/RPdb.h @@ -49,6 +49,6 @@ typedef struct _pdb_status_t { int pdbSunSensorData(sun_sensor_status_t* sunData); int pdbTelemetry(pdb_status_t* dataStorage); -int pdbPetWatchdog(void); +int pdbPetWatchDog(void); #endif /* RPdb_H_ */ diff --git a/radsat-sk/operation/subsystems/RTransceiver.c b/radsat-sk/operation/subsystems/RTransceiver.c index 3319b2af..65b04adc 100644 --- a/radsat-sk/operation/subsystems/RTransceiver.c +++ b/radsat-sk/operation/subsystems/RTransceiver.c @@ -10,6 +10,7 @@ #include #include #include +#include /*************************************************************************************************** @@ -72,7 +73,10 @@ int transceiverInit(void) { if (!error) initialized = 1; - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) { + errorReportComponent(componentTransceiver,error); + return error; + } return error; } @@ -96,7 +100,10 @@ int transceiverRxFrameCount(uint16_t* numberOfFrames) { int error = IsisTrxvu_rcGetFrameCount(TRANSCEIVER_INDEX, numberOfFrames); - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) { + errorReportComponent(componentTransceiver,error); + return error; + } return error; } @@ -129,7 +136,10 @@ int transceiverGetFrame(uint8_t* messageBuffer, uint16_t* sizeOfMessage) { // provide the size of the message to the caller *sizeOfMessage = frame.rx_length; - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) { + errorReportComponent(componentTransceiver,error); + return error; + } return error; } @@ -155,7 +165,10 @@ int transceiverSendFrame(uint8_t* message, uint8_t messageSize, uint8_t* slotsRe int error = IsisTrxvu_tcSendAX25DefClSign(TRANSCEIVER_INDEX, message, messageSize, slotsRemaining); - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) { + errorReportComponent(componentTransceiver,error); + return error; + } return error; } @@ -180,7 +193,10 @@ int transceiverPowerCycle(void) { // send full hard reset command int error = IsisTrxvu_hardReset(TRANSCEIVER_INDEX); - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) { + errorReportComponent(componentTransceiver,error); + return error; + } return error; } @@ -195,9 +211,12 @@ int transceiverSoftReset(void){ //send full soft reset command int error = IsisTrxvu_softReset(TRANSCEIVER_INDEX); - //TODO: record errors (if present) to System Manager + if (error != 0) - return error; + + errorReportComponent(componentTransceiver,error); + + return error; return SUCCESS; } @@ -220,14 +239,16 @@ int transceiverTelemetry(transceiver_telemetry_t* telemetry) { int error = IsisTrxvu_rcGetTelemetryAll(TRANSCEIVER_INDEX, &rawRxTelemetry); - // TODO: record errors (if present) to System Manager + if (error) + errorReportComponent(componentTransceiver,error); return error; error = IsisTrxvu_tcGetTelemetryAll(TRANSCEIVER_INDEX, &rawTxTelemetry); - // TODO: record errors (if present) to System Manager + if (error) + errorReportComponent(componentTransceiver,error); return error; uint16_t uptime = 0; @@ -276,20 +297,28 @@ int transceiverTelemetry(transceiver_telemetry_t* telemetry) { } -int transceiverResetWatchDogs(void) { +int transceiverPetWatchDogs(void) { int error = 0; - // create buffer to hold reset command code + // create buffer to hold pet command code uint8_t writeData[TRX_WDOG_RESET_CMD_SIZE] = { TRX_WDOG_RESET_CMD_CODE }; +<<<<<<< HEAD + // transmit WDOG pet to receiver module +======= // transmit WDOG reset_t to receiver module +>>>>>>> aa164ee08d0f9195d610920edab623484dec5094 error = i2cTransmit(TRANSCEIVER_RX_I2C_SLAVE_ADDR, writeData, sizeof(writeData)); if (error != 0) return error; +<<<<<<< HEAD + // transmit WDOG pet to transmitter module +======= // transmit WDOG reset_t to transmitter module +>>>>>>> aa164ee08d0f9195d610920edab623484dec5094 error = i2cTransmit(TRANSCEIVER_TX_I2C_SLAVE_ADDR, writeData, sizeof(writeData)); if (error != 0) @@ -313,7 +342,10 @@ static int transceiverRxUpTime(uint16_t* uptime) { int error = IsisTrxvu_rcGetUptime(TRANSCEIVER_INDEX, (unsigned int *) uptime); - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) { + errorReportComponent(componentTransceiver,error); + return error; + } return error; } @@ -329,7 +361,10 @@ static int transceiverTxUpTime(uint16_t* uptime) { int error = IsisTrxvu_tcGetUptime(TRANSCEIVER_INDEX, (unsigned int *) uptime); - // TODO: record errors (if present) to System Manager + if (error != SUCCESS) { + errorReportComponent(componentTransceiver,error); + return error; + } return error; } diff --git a/radsat-sk/operation/subsystems/RTransceiver.h b/radsat-sk/operation/subsystems/RTransceiver.h index fd1ad098..065f8f9f 100644 --- a/radsat-sk/operation/subsystems/RTransceiver.h +++ b/radsat-sk/operation/subsystems/RTransceiver.h @@ -78,7 +78,7 @@ int transceiverGetFrame(uint8_t* messageBuffer, uint16_t* sizeOfMessage); int transceiverSendFrame(uint8_t* message, uint8_t messageSize, uint8_t* slotsRemaining); int transceiverPowerCycle(void); int transceiverTelemetry(transceiver_telemetry_t* telemetry); -int transceiverResetWatchDogs(void); +int transceiverPetWatchDogs(void); int transceiverSoftReset(void); diff --git a/radsat-sk/operation/utility/RErrorManager.c b/radsat-sk/operation/utility/RErrorManager.c index e40cfef4..fae94882 100644 --- a/radsat-sk/operation/utility/RErrorManager.c +++ b/radsat-sk/operation/utility/RErrorManager.c @@ -12,6 +12,7 @@ #include #include +#include /*************************************************************************************************** diff --git a/radsat-sk/src/main.c b/radsat-sk/src/main.c index d72c9c77..6f240394 100644 --- a/radsat-sk/src/main.c +++ b/radsat-sk/src/main.c @@ -33,6 +33,7 @@ #include #include #include +#include /*************************************************************************************************** @@ -105,8 +106,11 @@ int main(void) { if (error != SUCCESS) { debugPrint("main(): failed during system initialization.\n"); - // TODO: report to system manager + + errorReportModule(moduleMain,error); + } +} #ifdef TEST @@ -389,35 +393,34 @@ void MissionInitTask(void* parameters) { // initialize the Hardware Abstraction Library (HAL) drivers error = initDrivers(); if (error != SUCCESS) { - // TODO: report to system manager + errorReportModule(moduleMain,error); debugPrint("MissionInitTask(): failed to initialize Drivers.\n"); } // initialize external components and the Satellite Subsystem Interface (SSI) error = initSubsystems(); if (error != SUCCESS) { - // TODO: report to system manager + errorReportModule(moduleMain,error); debugPrint("MissionInitTask(): failed to initialize Subsystems.\n"); } // initialize the internal OBC watchdog, and start a task that automatically pets it error = initObcWatchdog(); if (error != SUCCESS) { - // TODO: report to system manager + errorReportComponent(componentHalWdogTask,error); debugPrint("MissionInitTask(): failed to initialize Obc Watchdog.\n"); } - // initialize the RTC and RTT to the default time error = initTime(); if (error != SUCCESS) { - // TODO: report to system manager + errorReportComponent(componentHalTime,error); debugPrint("MissionInitTask(): failed to initialize the time.\n"); } // initialize the FreeRTOS Tasks used for typical mission operation initMissionTasks(); if (error != SUCCESS) { - // TODO: report to system manager + errorReportComponent(componentHalFreeRtos,error); debugPrint("MissionInitTask(): failed to initialize FreeRTOS Mission Tasks.\n"); } diff --git a/radsat-sk/src/tasks/RDosimeterCollectionTask.c b/radsat-sk/src/tasks/RDosimeterCollectionTask.c index 52e173f9..9f9b21c3 100644 --- a/radsat-sk/src/tasks/RDosimeterCollectionTask.c +++ b/radsat-sk/src/tasks/RDosimeterCollectionTask.c @@ -36,17 +36,18 @@ void DosimeterCollectionTask(void* parameters) { while (1) { - // TODO: check flags (once they exist) to prevent running this task during communication mode + + if(!(comunicationMode())) { + debugPrint("DosimeterCollectionTask(): About to collect Dosimeter payload data.\n"); - debugPrint("DosimeterCollectionTask(): About to collect Dosimeter payload data.\n"); + // collect all readings from dosimeter + error = dosimeterCollectData(); - // collect all readings from dosimeter - error = dosimeterCollectData(); + // if an error was detected, try again once more (if it fails again, no data will be taken this time) + if (error != 0) + dosimeterCollectData(); + } - // if an error was detected, try again once more (if it fails again, no data will be taken this time) - if (error != 0) - dosimeterCollectData(); - - vTaskDelay(DOSIMETER_COLLECTION_TASK_DELAY_MS); + vTaskDelay(DOSIMETER_COLLECTION_TASK_DELAY_MS); } } diff --git a/radsat-sk/src/tasks/RSatelliteWatchdogTask.c b/radsat-sk/src/tasks/RSatelliteWatchdogTask.c index 633294f9..ba81843e 100644 --- a/radsat-sk/src/tasks/RSatelliteWatchdogTask.c +++ b/radsat-sk/src/tasks/RSatelliteWatchdogTask.c @@ -5,10 +5,16 @@ */ #include +#include #include +#include +#include +#include +#include #include #include +#include /*************************************************************************************************** @@ -18,6 +24,30 @@ /** Satellite Watchdog Task delay (in ms). */ #define SATELLITE_WATCHDOG_TASK_DELAY_MS (15) +#define WATCHDOG_RESET_TIME_MS ((uint32_t)30*1000) ///> 30 seconds + + + +/** Abstraction of the states of operation */ +typedef enum _oper_state_t { + stateNormalMode = 0, ///> All tasks free to run + stateSafeMode = 1, ///> No Downlinking or payload collection + stateActiveFullCommunicationMode = 2, ///> No tasks allowed except for WDOG Petting + stateActiveHalfCommunicationMode = 3, ///> No tasks or downlinking allowed except for WDOG Petting +} oper_state_t; + + +/** Wrapper structure for states of operation */ +typedef struct _operation_state_t { + oper_state_t mode; ///> The current state of operation +} operation_state_t; + + +/** Operation structure */ +static operation_state_t state = { 3 }; + + + /*************************************************************************************************** FREERTOS TASKS @@ -28,12 +58,112 @@ void SatelliteWatchdogTask(void* parameters) { // ignore the input parameter (void)parameters; + int error = 0; + int communicationFlag = 1; + int safeFlag = 1; + uint32_t old_time = 0; + uint32_t current_time = 0; + while (1) { - // TODO: implement petting satellite watchdogs - debugPrint("SatelliteWatchdogTask(): About to pet external satellite watchdogs.\n"); + + //pet watchdogs for all components + current_time = xTaskGetTickCount(); + + if ((current_time - old_time) > WATCHDOG_RESET_TIME_MS) { + + debugPrint("SatelliteWatchdogTask(): About to pet external satellite watchdogs.\n"); + + error = batteryPetWatchDog(); + + if (error != SUCCESS) { + errorReportModule(moduleBattery,error); + } + + error = transceiverPetWatchDogs(); + + if (error != SUCCESS) { + errorReportModule(moduleTransceiver,error); + } + + error = pdbPetWatchdog(); + + if (error != SUCCESS) { + errorReportModule(modulePdb,error); + } + + old_time = current_time; + } + + // TODO: implement petting camera watchdog + + // Set the comunication flag depending on current state + if (communicationPassModeActive()) { + communicationFlag = 1; + } + else { + communicationFlag = 0; + } + + // Set the safe flag depending on current state + batteryIsNotSafe(&safeFlag); + + + if (communicationFlag == 0 && safeFlag == 0) { + state.mode = 0; + } + else if (communicationFlag == 0 && safeFlag == 1){ + state.mode = 1; + } + else if (communicationFlag == 1 && safeFlag == 0){ + state.mode = 2; + } + else if (communicationFlag == 1 && safeFlag == 1){ + state.mode = 3; + } + + + vTaskDelay(SATELLITE_WATCHDOG_TASK_DELAY_MS); } } + + +/*************************************************************************************************** + PUBLIC API +***************************************************************************************************/ + +/** + * Indicate if the Satellite is currently in a communications mode. + * + * @returns 1 (true) if Satellite is uplinking or downlinking; 0 (false) otherwise. + */ +uint8_t comunicationMode(void){ + + if (operation_state_t.mode == 2 || operation_state_t.mode == 3) { + return 1; + } + else{ + return 0; + } + +} + + +/** + * Indicate if the Satellite is currently in a safe mode. + * + * @returns 1 (true) check if the safe flag is rased meaning the current battery voltage is under 6.5V ; 0 (false) otherwise. + */ +uint8_t safeMode(void){ + + if (operation_state_t.mode == 1 || operation_state_t.mode == 3) { + return 1; + } + else{ + return 0; + } + +} diff --git a/radsat-sk/src/tasks/RSatelliteWatchdogTask.h b/radsat-sk/src/tasks/RSatelliteWatchdogTask.h index 9a1a1c0f..2b0aedd6 100644 --- a/radsat-sk/src/tasks/RSatelliteWatchdogTask.h +++ b/radsat-sk/src/tasks/RSatelliteWatchdogTask.h @@ -6,6 +6,7 @@ #ifndef RSATELLITEWATCHDOGTASK_H_ #define RSATELLITEWATCHDOGTASK_H_ +#include /*************************************************************************************************** @@ -15,4 +16,13 @@ void SatelliteWatchdogTask(void* parameters); +/*************************************************************************************************** + PUBLIC API +***************************************************************************************************/ + +uint8_t comunicationMode(void); +uint8_t safeMode(void); + + + #endif /* RSATELLITEWATCHDOGTASK_H_ */ diff --git a/radsat-sk/src/tasks/RTelemetryCollectionTask.c b/radsat-sk/src/tasks/RTelemetryCollectionTask.c index 0c7d6606..b3c2451a 100644 --- a/radsat-sk/src/tasks/RTelemetryCollectionTask.c +++ b/radsat-sk/src/tasks/RTelemetryCollectionTask.c @@ -4,8 +4,18 @@ * @author Tyrel Kostyk (tck290) */ + #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include @@ -22,6 +32,16 @@ #define TELEMETRY_COLLECTION_TASK_DELAY_MS (MS_PER_HOUR / TELEMETRY_READINGS_PER_HOUR) +static battery_telemetry battery_telemetry_R; + +static antenna_telemetry antenna_telemetry_R; + +static transceiver_telemetry transceiver_telemetry_R; + +static eps_telemetry pdb_telemetry_R; + +static obc_telemetry obc_telemetry_R; + /*************************************************************************************************** FREERTOS TASKS ***************************************************************************************************/ @@ -30,13 +50,70 @@ void TelemetryCollectionTask(void* parameters) { // ignore the input parameter (void)parameters; + int error = 0; while (1) { - // TODO: implement telemetry collection + // TODO: implement telemetry collection for camera debugPrint("TelemetryCollectionTask(): About to collect satellite telemetry data.\n"); + if(!(comunicationMode())) { + + error = antennaTelemetry(&antenna_telemetry_R); + if (error != SUCCESS) { + errorReportModule(moduleAntenna,error); + } + + error = batteryTelemetry(&battery_telemetry_R); + if (error != SUCCESS) { + errorReportModule(moduleBattery,error); + } + + error = transceiverTelemetry(&transceiver_telemetry_R); + if (error != SUCCESS) { + errorReportModule(moduleTransceiver,error); + } + error = pdbTelemetry(&pdb_telemetry_R); + if (error != SUCCESS) { + errorReportModule(modulePdb,error); + } + + error = obcTelemetry(&obc_telemetry_R); + if (error != SUCCESS) { + errorReportModule(moduleObc,error); + } + + + error = fileTransferAddMessage(&antenna_telemetry_R, sizeof(antenna_telemetry_R),file_transfer_message_AntennaTelemetry_tag ); + if (error != SUCCESS) { + errorReportModule(moduleFileTransferService,error); + } + + error = fileTransferAddMessage(&battery_telemetry_R, sizeof(battery_telemetry_R),file_transfer_message_BatteryTelemetry_tag ); + if (error != SUCCESS) { + errorReportModule(moduleFileTransferService,error); + } + + error = fileTransferAddMessage(&transceiver_telemetry_R, sizeof(transceiver_telemetry_R),file_transfer_message_TransceiverTelemetry_tag ); + if (error != SUCCESS) { + errorReportModule(moduleFileTransferService,error); + } + + error = fileTransferAddMessage(&pdb_telemetry_R, sizeof(pdb_telemetry_R),file_transfer_message_EpsTelemetry_tag ); + if (error != SUCCESS) { + errorReportModule(moduleFileTransferService,error); + } + + error = fileTransferAddMessage(&obc_telemetry_R, sizeof(obc_telemetry_R),file_transfer_message_ObcTelemetry_tag ); + if (error != SUCCESS) { + errorReportModule(moduleFileTransferService,error); + } + + + + } + vTaskDelay(TELEMETRY_COLLECTION_TASK_DELAY_MS); } }