Skip to content

Commit

Permalink
Src: Beacon: Limiting the number of deployment executions
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm8 committed Mar 22, 2019
1 parent 913af6f commit 98a6dec
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
4 changes: 3 additions & 1 deletion firmware/fsat_beacon_msp430/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.2.15
* \version 0.2.16
*
* \date 08/06/2017
*
Expand Down Expand Up @@ -145,6 +145,8 @@

#define BEACON_ANTENNA_INIT_TIMEOUT_MS 100

#define BEACON_ANTENNA_MAX_DEPLOYMENTS 10

//########################################################
//-- CPU -------------------------------------------------
//########################################################
Expand Down
3 changes: 2 additions & 1 deletion firmware/fsat_beacon_msp430/config/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.2.11
* \version 0.2.16
*
* \date 18/03/2019
*
Expand Down Expand Up @@ -60,6 +60,7 @@
#define MEMORY_ADR_PARAM_OBDH_IS_DEAD_PKT (uint8_t *)(FLASH_SEG_D_ADR + 36)
#define MEMORY_ADR_PARAM_PARAMS_SAVED (uint8_t *)(FLASH_SEG_D_ADR + 40)
#define MEMORY_ADR_PARAM_PARAMS_DEPLOU_HIB_EXECUTED (uint8_t *)(FLASH_SEG_D_ADR + 44)
#define MEMORY_ADR_PARAM_DEPLOYMENT_ATTEMPTS (uint8_t *)(FLASH_SEG_D_ADR + 48)

#endif // MEMORY_H_

Expand Down
19 changes: 18 additions & 1 deletion firmware/fsat_beacon_msp430/src/beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.2.11
* \version 0.2.16
*
* \date 08/06/2017
*
Expand Down Expand Up @@ -638,6 +638,18 @@ void beacon_antenna_deployment()
{
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Executing the deployment routines...\n\r");

if (beacon.deployment_attempts >= BEACON_ANTENNA_MAX_DEPLOYMENTS)
{
debug_print_event_from_module(DEBUG_WARNING, BEACON_MODULE_NAME, "Enough deployment attempts executed (");
debug_print_dec(beacon.deployment_attempts);
debug_print_msg(")! Skipping the deployment routine...\n\r");

beacon.hibernation = false;
beacon.deployment_executed = true;

return;
}

// If it is the first deployment attempt, wait 45 minutes before trying to deploy
if (!beacon.deploy_hibernation_executed)
{
Expand Down Expand Up @@ -671,6 +683,8 @@ void beacon_antenna_deployment()

antenna_deploy();

beacon.deployment_attempts++;

beacon.hibernation = false;
beacon.deployment_executed = true;
}
Expand Down Expand Up @@ -700,6 +714,7 @@ void beacon_load_params()
beacon.energy_level = SATELLITE_ENERGY_LEVEL_5;
beacon.deploy_hibernation_executed = false;
beacon.last_energy_level_set = time_get_seconds();
beacon.deployment_attempts = 0;

beacon.eps.time_last_valid_pkt = time_get_seconds();
beacon.eps.errors = 0;
Expand All @@ -715,6 +730,7 @@ void beacon_load_params()
beacon.energy_level = flash_read_single(BEACON_PARAM_ENERGY_LEVEL_MEM_ADR);
beacon.last_energy_level_set = flash_read_long(BEACON_PARAM_LAST_ENERGY_LEVEL_SET_MEM_ADR);
beacon.deploy_hibernation_executed = flash_read_single(BEACON_PARAM_PARAMS_DEPLOU_HIB_EXECUTED_MEM_ADR);
beacon.deployment_attempts = flash_read_single(BEACON_PARAM_DEPLOYMENT_ATTEMPTS_MEM_ADR);

beacon.eps.time_last_valid_pkt = flash_read_long(BEACON_PARAM_EPS_LAST_TIME_VALID_PKT_MEM_ADR);
beacon.eps.errors = flash_read_single(BEACON_PARAM_EPS_ERRORS_MEM_ADR);
Expand All @@ -736,6 +752,7 @@ void beacon_save_params()
flash_write_single(beacon.energy_level, BEACON_PARAM_ENERGY_LEVEL_MEM_ADR);
flash_write_long(beacon.last_energy_level_set, BEACON_PARAM_LAST_ENERGY_LEVEL_SET_MEM_ADR);
flash_write_single(beacon.deploy_hibernation_executed ? 1 : 0, BEACON_PARAM_PARAMS_DEPLOU_HIB_EXECUTED_MEM_ADR);
flash_write_single(beacon.deployment_attempts, BEACON_PARAM_DEPLOYMENT_ATTEMPTS_MEM_ADR);

flash_write_long(beacon.eps.time_last_valid_pkt, BEACON_PARAM_EPS_LAST_TIME_VALID_PKT_MEM_ADR);
flash_write_single(beacon.eps.errors, BEACON_PARAM_EPS_ERRORS_MEM_ADR);
Expand Down
3 changes: 2 additions & 1 deletion firmware/fsat_beacon_msp430/src/beacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.2.11
* \version 0.2.16
*
* \date 08/06/2017
*
Expand Down Expand Up @@ -55,6 +55,7 @@ typedef struct
bool transmitting; /**< If true, the beacon is transmitting packets, otherwise, not. */
bool deployment_executed; /**< If true, the antenna deployment was executed since the last beacon reset. */
bool deploy_hibernation_executed; /**< If true, the mandatory deployment hibernation was executed. */
uint8_t deployment_attempts; /**< Number of executed deployment attempts. */
uint8_t energy_level; /**< Energy level of the satellite. */
uint32_t last_radio_reset_time; /**< Time stamp of the last radio reset. */
uint32_t last_system_reset_time; /**< Time stamp of the last system reset. */
Expand Down
3 changes: 2 additions & 1 deletion firmware/fsat_beacon_msp430/src/beacon_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.2.11
* \version 0.2.16
*
* \date 07/03/2019
*
Expand Down Expand Up @@ -58,6 +58,7 @@
#define BEACON_PARAM_OBDH_IS_DEAD_PKT_MEM_ADR MEMORY_ADR_PARAM_OBDH_IS_DEAD_PKT
#define BEACON_PARAM_PARAMS_SAVED_MEM_ADR MEMORY_ADR_PARAM_PARAMS_SAVED
#define BEACON_PARAM_PARAMS_DEPLOU_HIB_EXECUTED_MEM_ADR MEMORY_ADR_PARAM_PARAMS_DEPLOU_HIB_EXECUTED
#define BEACON_PARAM_DEPLOYMENT_ATTEMPTS_MEM_ADR MEMORY_ADR_PARAM_DEPLOYMENT_ATTEMPTS

#endif // BEACON_CONFIG_H_

Expand Down
4 changes: 2 additions & 2 deletions firmware/fsat_beacon_msp430/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.2.15
* \version 0.2.16
*
* \date 08/02/2019
*
Expand All @@ -36,7 +36,7 @@
#ifndef VERSION_H_
#define VERSION_H_

#define FIRMWARE_VERSION "0.2.15"
#define FIRMWARE_VERSION "0.2.16"

#define FIRMWARE_STATUS "Development"

Expand Down

0 comments on commit 98a6dec

Please sign in to comment.