diff --git a/radsat-sk/operation/subsystems/RAntenna.c b/radsat-sk/operation/subsystems/RAntenna.c index e52186a5..bca92afe 100644 --- a/radsat-sk/operation/subsystems/RAntenna.c +++ b/radsat-sk/operation/subsystems/RAntenna.c @@ -130,24 +130,27 @@ int antennaDeploymentAttempt(void) { // TODO: record errors (if present) to System Manager return error; } - - // Disarm A Side Antenna system - error = IsisAntS_setArmStatus(ANTENNA_INDEX, isisants_sideA, isisants_disarm); - - // Check if disarm failed - if(error != 0) { - - // TODO: record errors (if present) to System Manager - return error; - } } } // Increment deployment attempts for side A antennaDeploymentAttempts += 1; + + // Wait between deployment attempts to ensure disarming doesn't happen too quickly + vTaskDelay(INTER_DEPLOYMENT_DELAY_MS); } - // reset_t attempt counter for Side B + // Disarm A Side Antenna system + error = IsisAntS_setArmStatus(ANTENNA_INDEX, isisants_sideA, isisants_disarm); + + // Check if disarm failed + if(error != 0) { + + // TODO: record errors (if present) to System Manager + return error; + } + + // reset attempt counter for Side B antennaDeploymentAttempts = 0; // B Side deployment Attempt @@ -209,21 +212,23 @@ int antennaDeploymentAttempt(void) { // TODO: record errors (if present) to System Manager return error; } - - //disarm B Side Antenna system - error = IsisAntS_setArmStatus(ANTENNA_INDEX, isisants_sideB, isisants_disarm); - - // Check if disarm failed - if(error != 0) { - - // TODO: record errors (if present) to System Manager - return error; - } } - } // Increment deployment attempts for side B antennaDeploymentAttempts += 1; + + // Wait between deployment attempts to ensure disarming doesn't happen too quickly + vTaskDelay(INTER_DEPLOYMENT_DELAY_MS); + } + + //disarm B Side Antenna system + error = IsisAntS_setArmStatus(ANTENNA_INDEX, isisants_sideB, isisants_disarm); + + // Check if disarm failed + if(error != 0) { + + // TODO: record errors (if present) to System Manager + return error; } diff --git a/radsat-sk/operation/subsystems/RAntenna.h b/radsat-sk/operation/subsystems/RAntenna.h index 751d0e65..3306747e 100644 --- a/radsat-sk/operation/subsystems/RAntenna.h +++ b/radsat-sk/operation/subsystems/RAntenna.h @@ -28,6 +28,9 @@ /** Max Time allowed for a deployment for an Antenna in seconds */ #define MAX_DEPLOYMENT_TIMEOUT 60 +/** Time delay between deployment attempts in milliseconds */ +#define INTER_DEPLOYMENT_DELAY_MS 2*1000 + /** Antenna Deployment status Struct */ typedef struct _antenna_deployment_status_t { int DeployedAntennaOne; diff --git a/radsat-sk/src/main.c b/radsat-sk/src/main.c index 60188658..968c6bc2 100644 --- a/radsat-sk/src/main.c +++ b/radsat-sk/src/main.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -114,11 +115,10 @@ int main(void) { #else /* TEST */ - // TODO: Antenna Diagnostic & Deployment (if necessary) - // TODO: Satellite Diagnostic Check (if applicable - may be done later instead) // initialize the Mission Initialization Task + // Antenna Deployment happens in here. error = xTaskCreate(MissionInitTask, (const signed char*)"Mission Initialization Task", DEFAULT_TASK_STACK_SIZE, @@ -220,6 +220,22 @@ static int initTime(void) { } +/** + * Attempt to deploy the antenna. + */ +static int attemptAntennaDeployment(void) { + + int error = SUCCESS; + + error = antennaDeploymentAttempt(); + if (error != SUCCESS) + debugPrint("attemptAntennaDeployment(): failed to deploy antenna.\n"); + + return error; +} + + + /** * Initialize external subsystem modules and the Satellite Subsystem Interface library. */ @@ -234,6 +250,13 @@ static int initSubsystems(void) { return error; } + // initialize the antenna module + error = antennaInit(); + if (error != SUCCESS){ + debugPrint("initSubsystems(): failed to initialized Antenna subsystem.\n"); + return error; + } + // TODO: initialize the other subsystems that require explicit initialization return error; @@ -414,6 +437,13 @@ void MissionInitTask(void* parameters) { debugPrint("MissionInitTask(): failed to initialize the time.\n"); } + // attempt to deploy the antenna + error = attemptAntennaDeployment(); + if (error != SUCCESS) { + // TODO: report system manager + debugPrint("attemptAntennaDeployment(): failed to deploy the antenna.\n"); + } + // initialize the FreeRTOS Tasks used for typical mission operation initMissionTasks(); if (error != SUCCESS) {