From faca8db78913203a6b8b470e4f3ec3f368408273 Mon Sep 17 00:00:00 2001 From: Grace Yi Date: Mon, 1 Nov 2021 12:12:43 -0600 Subject: [PATCH 1/4] Add EPS startup telemetry --- hardware_interface/include/eps.h | 82 ++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/hardware_interface/include/eps.h b/hardware_interface/include/eps.h index 2ad9d97..c340496 100644 --- a/hardware_interface/include/eps.h +++ b/hardware_interface/include/eps.h @@ -13,7 +13,7 @@ */ /** * @file eps.h - * @author Andrew Rooney, Dustin Wagner + * @author Andrew Rooney, Dustin Wagner, Grace Yi * @date 2020-12-28 */ #ifndef EX2_SERVICES_PLATFORM_OBC_EPS_H_ @@ -24,7 +24,7 @@ /* Binary Commands to EPS */ -#define SET_TELEMETRY_PERIOD 255 +#define SET_TELEMETRY_PERIOD 255 #define EPS_REQUEST_TIMEOUT 1000 #define EPS_INSTANTANEOUS_TELEMETRY 7 #define EPS_POWER_CONTROL 14 @@ -57,53 +57,73 @@ typedef struct __attribute__((packed)) { } get_gs_wd_time_left_resp_t; struct __attribute__((packed)) eps_instantaneous_telemetry { - uint8_t cmd; //value 0 - int8_t status; //0 –on success + uint8_t cmd; // value 0 + int8_t status; // 0 �on success double timestampInS; // with ms precision uint32_t uptimeInS; - uint32_t bootCnt; // system startup count - uint32_t wdt_gs_time_left; //seconds + uint32_t bootCnt; // system startup count + uint32_t wdt_gs_time_left; // seconds uint32_t wdt_gs_counter; - uint16_t mpptConverterVoltage[4]; //mV - uint16_t curSolarPanels[8]; //mA - uint16_t vBatt; //mV - uint16_t curSolar; //mA - uint16_t curBattIn; //mA - uint16_t curBattOut; //mA - uint16_t curOutput[18]; //mA - uint16_t AOcurOutput[2]; //mA - uint16_t OutputConverterVoltage[8]; //mV + uint16_t mpptConverterVoltage[4]; // mV + uint16_t curSolarPanels[8]; // mA + uint16_t vBatt; // mV + uint16_t curSolar; // mA + uint16_t curBattIn; // mA + uint16_t curBattOut; // mA + uint16_t curOutput[18]; // mA + uint16_t AOcurOutput[2]; // mA + uint16_t OutputConverterVoltage[8]; // mV uint8_t outputConverterState; - uint32_t outputStatus; //18-bits - uint32_t outputFaultStatus; //18-bits + uint32_t outputStatus; // 18-bits + uint32_t outputFaultStatus; // 18-bits uint16_t protectedOutputAccessCnt; - uint16_t outputOnDelta[18]; //seconds - uint16_t outputOffDelta[18]; //seconds + uint16_t outputOnDelta[18]; // seconds + uint16_t outputOffDelta[18]; // seconds uint8_t outputFaultCnt[18]; - int8_t temp[14]; //1-4 –MPPT converter temp, 5-8 –output converter temp, 9 –on-board battery temp, 10–12 –external battery pack temp, 13-14 -output expander temp - uint8_t battMode; //0 –critical, 1 –safe, 2 –normal, 3 –full - uint8_t mpptMode; //0 –HW, 1 –manual, 2 –auto, 3 –auto with timeout - uint8_t batHeaterMode; //0 –manual, 1 –auto - uint8_t batHeaterState; //0 –off, 1 –on + int8_t temp[14]; // 1-4 �MPPT converter temp, 5-8 �output converter temp, 9 �on-board battery temp, 10�12 + // �external battery pack temp, 13-14 -output expander temp + uint8_t battMode; // 0 �critical, 1 �safe, 2 �normal, 3 �full + uint8_t mpptMode; // 0 �HW, 1 �manual, 2 �auto, 3 �auto with timeout + uint8_t batHeaterMode; // 0 �manual, 1 �auto + uint8_t batHeaterState; // 0 �off, 1 �on uint16_t PingWdt_toggles; // Total number of power channel toggles caused by failed ping watchdog uint8_t PingWdt_turnOffs; // Total number of power channel offs caused by failed ping watchdog }; -enum eps_mode { - critical = 0, - safe = 1, - normal = 2, - full = 3 +struct __attribute__((packed)) eps_startup_telemetry { + uint8_t cmd; // value 1 + double timestamp; // with ms precision + uint32_t last_reset_reason_reg; //Last reset reason register value, see below + uint32_t bootCnt; // total system boot count + uint8_t FallbackConfigUsed; + uint8_t rtcInit; + uint8_t rtcClkSourceLSE; + uint8_t flashAppInit; + int8_t Fram4kPartitionInit; + int8_t Fram520kPartitionInit; + int8_t intFlashPartitionInit; + int8_t FSInit; + int8_t FTInit; + int8_t supervisorInit; + uint8_t uart1App; + uint8_t uart2App; + int8_t tmp107Init; }; +enum eps_mode { critical = 0, safe = 1, normal = 2, full = 3 }; + typedef struct eps_instantaneous_telemetry eps_instantaneous_telemetry_t; +typedef struct eps_startup_telemetry eps_startup_telemetry_t; typedef enum eps_mode eps_mode_e; SAT_returnState eps_refresh_instantaneous_telemetry(); +SAT_returnState eps_refresh_startup_telemetry(); eps_instantaneous_telemetry_t get_eps_instantaneous_telemetry(); -void EPS_getHK(eps_instantaneous_telemetry_t* telembuf); +eps_startup_telemetry_t get_eps_startup_telemetry(); +void EPS_getHK(eps_instantaneous_telemetry_t *telembuf, eps_startup_telemetry_t *telem_startup_buf); eps_mode_e get_eps_batt_mode(); -void prv_instantaneous_telemetry_letoh (eps_instantaneous_telemetry_t *telembuf); +void prv_instantaneous_telemetry_letoh(eps_instantaneous_telemetry_t *telembuf); +void prv_startup_telemetry_letoh(eps_startup_telemetry_t *telem_startup_buf); // If changing the two functions below, update system tasks, too. uint8_t eps_get_pwr_chnl(uint8_t pwr_chnl_port); int8_t eps_set_pwr_chnl(uint8_t pwr_chnl_port, bool status); From 418aff2b13d1bffa0ad608b385dee32391cb6a80 Mon Sep 17 00:00:00 2001 From: Grace Yi Date: Mon, 1 Nov 2021 12:13:21 -0600 Subject: [PATCH 2/4] Add EPS startup telemetry --- hardware_interface/source/eps.c | 141 ++++++++++++++++++++++++-------- 1 file changed, 106 insertions(+), 35 deletions(-) diff --git a/hardware_interface/source/eps.c b/hardware_interface/source/eps.c index d5049c9..b33b5fd 100644 --- a/hardware_interface/source/eps.c +++ b/hardware_interface/source/eps.c @@ -13,7 +13,7 @@ */ /** * @file eps.c - * @author Andrew Rooney, Dustin Wagner + * @author Andrew Rooney, Dustin Wagner, Grace Yi * @date 2020-12-28 */ @@ -24,23 +24,26 @@ */ #include -#include -#include #include #include #include
+#include +#include -#include "services.h" #include "eps.h" +#include "services.h" -void prv_instantaneous_telemetry_letoh (eps_instantaneous_telemetry_t *telembuf); -static inline void prv_set_instantaneous_telemetry (eps_instantaneous_telemetry_t telembuf); +void prv_instantaneous_telemetry_letoh(eps_instantaneous_telemetry_t *telembuf); +void prv_startup_telemetry(eps_startup_telemetry_t *telem_startup_buf); +static inline void prv_set_instantaneous_telemetry(eps_instantaneous_telemetry_t telembuf); +static inline void prv_set_startup_telemetry(eps_startup_telemetry_t telem_startup_buf); static inline void prv_get_lock(eps_t *eps); static inline void prv_give_lock(eps_t *eps); -static eps_t* prv_get_eps(); +static eps_t *prv_get_eps(); struct eps_t { eps_instantaneous_telemetry_t hk_telemetery; + eps_startup_telemetry_t hk_startup_telemetry; SemaphoreHandle_t eps_lock; }; @@ -53,9 +56,8 @@ SAT_returnState eps_refresh_instantaneous_telemetry() { eps_instantaneous_telemetry_t telembuf; int res = csp_ping(EPS_APP_ID, 10000, 100, CSP_O_NONE); - csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_INSTANTANEOUS_TELEMETRY, - 10000, &cmd, sizeof(cmd), &telembuf, - sizeof(eps_instantaneous_telemetry_t), CSP_O_CRC32); + csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_INSTANTANEOUS_TELEMETRY, 10000, &cmd, sizeof(cmd), + &telembuf, sizeof(eps_instantaneous_telemetry_t), CSP_O_CRC32); // data is little endian, must convert to host order // refer to the NanoAvionics datasheet for details prv_instantaneous_telemetry_letoh(&telembuf); @@ -63,6 +65,19 @@ SAT_returnState eps_refresh_instantaneous_telemetry() { return SATR_OK; } +SAT_returnState eps_refresh_startup_telemetry() { + uint8_t cmd = 1; // ' subservice' command defined in ICD Section 24.2.2 + eps_startup_telemetry_t telem_startup_buf; + + csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_INSTANTANEOUS_TELEMETRY, 10000, &cmd, sizeof(cmd), + &telem_startup_buf, sizeof(eps_startup_telemetry_t), CSP_O_CRC32); + // data is little endian, must convert to host order + // refer to the NanoAvionics datasheet for details + prv_startup_telemetry_letoh(&telem_startup_buf); + prv_set_startup_telemetry(telem_startup_buf); + return SATR_OK; +} + eps_instantaneous_telemetry_t get_eps_instantaneous_telemetry() { eps_instantaneous_telemetry_t telembuf; eps_t *eps; @@ -74,6 +89,17 @@ eps_instantaneous_telemetry_t get_eps_instantaneous_telemetry() { return telembuf; } +eps_startup_telemetry_t get_eps_startup_telemetry() { + eps_startup_telemetry_t telem_startup_buf; + eps_t *eps; + eps = prv_get_eps(); + prv_get_lock(eps); + configASSERT(eps); + telem_startup_buf = eps->hk_startup_telemetry; + prv_give_lock(eps); + return telem_startup_buf; +} + /** * @brief * Electronic Power System get Housekeeping data @@ -88,12 +114,13 @@ eps_instantaneous_telemetry_t get_eps_instantaneous_telemetry() { * but currently no return * */ -void EPS_getHK(eps_instantaneous_telemetry_t* telembuf) { +void EPS_getHK(eps_instantaneous_telemetry_t *telembuf, eps_startup_telemetry_t *telem_startup_buf) { eps_t *eps; eps = prv_get_eps(); prv_get_lock(eps); configASSERT(eps); + //General telemetry (defined in ICD Section 24.2.1) telembuf->cmd = eps->hk_telemetery.cmd; telembuf->status = eps->hk_telemetery.status; telembuf->timestampInS = eps->hk_telemetery.timestampInS; @@ -117,13 +144,13 @@ void EPS_getHK(eps_instantaneous_telemetry_t* telembuf) { telembuf->PingWdt_turnOffs = eps->hk_telemetery.PingWdt_turnOffs; uint8_t i; - for (i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { telembuf->AOcurOutput[i] = eps->hk_telemetery.AOcurOutput[i]; } - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { telembuf->mpptConverterVoltage[i] = eps->hk_telemetery.mpptConverterVoltage[i]; } - for (i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { telembuf->curSolarPanels[i] = eps->hk_telemetery.curSolarPanels[i]; telembuf->OutputConverterVoltage[i] = eps->hk_telemetery.OutputConverterVoltage[i]; } @@ -137,34 +164,51 @@ void EPS_getHK(eps_instantaneous_telemetry_t* telembuf) { telembuf->temp[i] = eps->hk_telemetery.temp[i]; } + //Startup telemetry (defined in ICD Section 24.2.2) + telem_startup_buf->timestamp = eps->hk_startup_telemetry.timestamp; + telem_startup_buf->last_reset_reason_reg = eps->hk_startup_telemetry.last_reset_reason_reg; + telem_startup_buf->bootCnt = eps->hk_startup_telemetry.bootCnt; + telem_startup_buf->FallbackConfigUsed = eps->hk_startup_telemetry.FallbackConfigUsed; + telem_startup_buf->rtcInit = eps->hk_startup_telemetry.rtcInit; + telem_startup_buf->rtcClkSourceLSE = eps->hk_startup_telemetry.rtcClkSourceLSE; + telem_startup_buf->flashAppInit = eps->hk_startup_telemetry.flashAppInit; + telem_startup_buf->Fram4kPartitionInit = eps->hk_startup_telemetry.Fram4kPartitionInit; + telem_startup_buf->Fram520kPartitionInit = eps->hk_startup_telemetry.Fram520kPartitionInit; + telem_startup_buf->intFlashPartitionInit = eps->hk_startup_telemetry.intFlashPartitionInit; + telem_startup_buf->FSInit = eps->hk_startup_telemetry.FSInit; + telem_startup_buf->FTInit = eps->hk_startup_telemetry.FTInit; + telem_startup_buf->supervisorInit = eps->hk_startup_telemetry.supervisorInit; + telem_startup_buf->uart1App = eps->hk_startup_telemetry.uart1App; + telem_startup_buf->uart2App = eps->hk_startup_telemetry.uart2App; + telem_startup_buf->tmp107Init = eps->hk_startup_telemetry.tmp107Init; + prv_give_lock(eps); } eps_mode_e get_eps_batt_mode() { eps_refresh_instantaneous_telemetry(); eps_instantaneous_telemetry_t eps = get_eps_instantaneous_telemetry(); - return (eps_mode_e) eps.battMode; + return (eps_mode_e)eps.battMode; } /* Gets the status of the power channel */ -uint8_t eps_get_pwr_chnl(uint8_t pwr_chnl_port){ +uint8_t eps_get_pwr_chnl(uint8_t pwr_chnl_port) { eps_refresh_instantaneous_telemetry(); eps_instantaneous_telemetry_t eps = get_eps_instantaneous_telemetry(); uint32_t outputStatus = eps.outputStatus; // a codeword that has the status of all channels - uint8_t pwr_chnl_status = (uint8_t) (outputStatus >> (pwr_chnl_port - 1)) & 1; // chnl_port : 1-18 + uint8_t pwr_chnl_status = (uint8_t)(outputStatus >> (pwr_chnl_port - 1)) & 1; // chnl_port : 1-18 return pwr_chnl_status; } /* Sends a command to eps to set the status of a power channel */ -int8_t eps_set_pwr_chnl(uint8_t pwr_chnl_port, bool status){ +int8_t eps_set_pwr_chnl(uint8_t pwr_chnl_port, bool status) { int8_t response[2]; uint8_t cmd[5] = {0}; - cmd[0] = 0; //single output control + cmd[0] = 0; // single output control cmd[1] = pwr_chnl_port; cmd[2] = status; // delay = 0 so cmd{4] = cmd[5] = 0 - csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_POWER_CONTROL, - 10000, &cmd, sizeof(cmd), &response, + csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_POWER_CONTROL, 10000, &cmd, sizeof(cmd), &response, sizeof(response), CSP_O_CRC32); return response[1]; } @@ -175,27 +219,23 @@ int8_t eps_set_pwr_chnl(uint8_t pwr_chnl_port, bool status){ * csp_endian also returns a wrong value. The reason is probably the limitations * of MCU on processing double precision floats. */ -inline double __attribute__ ((__const__)) csp_letohd(double d) { +inline double __attribute__((__const__)) csp_letohd(double d) { union v { - double d; - uint64_t i; + double d; + uint64_t i; }; union v val; val.d = d; - val.i = (((val.i & 0xff00000000000000LL) >> 56) | - ((val.i & 0x00000000000000ffLL) << 56) | - ((val.i & 0x00ff000000000000LL) >> 40) | - ((val.i & 0x000000000000ff00LL) << 40) | - ((val.i & 0x0000ff0000000000LL) >> 24) | - ((val.i & 0x0000000000ff0000LL) << 24) | - ((val.i & 0x000000ff00000000LL) >> 8) | - ((val.i & 0x00000000ff000000LL) << 8)); + val.i = (((val.i & 0xff00000000000000LL) >> 56) | ((val.i & 0x00000000000000ffLL) << 56) | + ((val.i & 0x00ff000000000000LL) >> 40) | ((val.i & 0x000000000000ff00LL) << 40) | + ((val.i & 0x0000ff0000000000LL) >> 24) | ((val.i & 0x0000000000ff0000LL) << 24) | + ((val.i & 0x000000ff00000000LL) >> 8) | ((val.i & 0x00000000ff000000LL) << 8)); return val.d; } /*------------------------------Private-------------------------------------*/ -static eps_t* prv_get_eps() { +static eps_t *prv_get_eps() { if (!prvEps.eps_lock) { prvEps.eps_lock = xSemaphoreCreateMutex(); } @@ -213,7 +253,7 @@ static inline void prv_give_lock(eps_t *eps) { xSemaphoreGive(eps->eps_lock); } -static inline void prv_set_instantaneous_telemetry (eps_instantaneous_telemetry_t telembuf) { +static inline void prv_set_instantaneous_telemetry(eps_instantaneous_telemetry_t telembuf) { eps_t *eps = prv_get_eps(); prv_get_lock(eps); eps->hk_telemetery = telembuf; @@ -221,7 +261,7 @@ static inline void prv_set_instantaneous_telemetry (eps_instantaneous_telemetry_ return; } -void prv_instantaneous_telemetry_letoh (eps_instantaneous_telemetry_t *telembuf) { +void prv_instantaneous_telemetry_letoh(eps_instantaneous_telemetry_t *telembuf) { uint8_t i; for (i = 0; i < 2; i++) { telembuf->AOcurOutput[i] = csp_letoh16(telembuf->AOcurOutput[i]); @@ -254,3 +294,34 @@ void prv_instantaneous_telemetry_letoh (eps_instantaneous_telemetry_t *telembuf) telembuf->PingWdt_toggles = csp_letoh16(telembuf->PingWdt_toggles); telembuf->timestampInS = csp_letohd(telembuf->timestampInS); } + +static inline void prv_set_startup_telemetry(eps_startup_telemetry_t telem_startup_buf) { + eps_t *eps = prv_get_eps(); + prv_get_lock(eps); + eps->hk_startup_telemetry = telem_startup_buf; + prv_give_lock(eps); + return; +} + +void prv_startup_telemetry_letoh(eps_startup_telemetry_t *telem_startup_buf) { + uint8_t i; + + telem_startup_buf->timestamp = csp_letoh16(telem_startup_buf->timestamp); + telem_startup_buf->last_reset_reason_reg = csp_letoh16(telem_startup_buf->last_reset_reason_reg); + telem_startup_buf->bootCnt = csp_letoh16(telem_startup_buf->bootCnt); + telem_startup_buf->FallbackConfigUsed = csp_letoh16(telem_startup_buf->FallbackConfigUsed); + telem_startup_buf->rtcInit = csp_letoh32(telem_startup_buf->rtcInit); + telem_startup_buf->rtcClkSourceLSE = csp_letoh32(telem_startup_buf->rtcClkSourceLSE); + telem_startup_buf->flashAppInit = csp_letoh32(telem_startup_buf->flashAppInit); + telem_startup_buf->Fram4kPartitionInit = csp_letoh32(telem_startup_buf->Fram4kPartitionInit); + telem_startup_buf->Fram520kPartitionInit = csp_letoh32(telem_startup_buf->Fram520kPartitionInit); + telem_startup_buf->intFlashPartitionInit = csp_letoh32(telem_startup_buf->intFlashPartitionInit); + telem_startup_buf->FSInit = csp_letoh16(telem_startup_buf->FSInit); + telem_startup_buf->FTInit = csp_letohd(telem_startup_buf->FTInit); + telem_startup_buf->supervisorInit = csp_letohd(telem_startup_buf->supervisorInit); + telem_startup_buf->uart1App = csp_letohd(telem_startup_buf->uart1App); + telem_startup_buf->uart2App = csp_letohd(telem_startup_buf->uart2App); + telem_startup_buf->tmp107Init = csp_letohd(telem_startup_buf->tmp107Init); + +} + From 3f3e365362673c7256df395306d911b3cdef2292 Mon Sep 17 00:00:00 2001 From: Grace Yi Date: Fri, 12 Nov 2021 12:17:48 -0700 Subject: [PATCH 3/4] edit code based on flatsat testing results --- hardware_interface/include/eps.h | 19 ++++++++++--------- hardware_interface/source/eps.c | 26 +++++++------------------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/hardware_interface/include/eps.h b/hardware_interface/include/eps.h index c340496..63b02cf 100644 --- a/hardware_interface/include/eps.h +++ b/hardware_interface/include/eps.h @@ -58,7 +58,7 @@ typedef struct __attribute__((packed)) { struct __attribute__((packed)) eps_instantaneous_telemetry { uint8_t cmd; // value 0 - int8_t status; // 0 �on success + int8_t status; // 0 on success double timestampInS; // with ms precision uint32_t uptimeInS; uint32_t bootCnt; // system startup count @@ -80,25 +80,26 @@ struct __attribute__((packed)) eps_instantaneous_telemetry { uint16_t outputOnDelta[18]; // seconds uint16_t outputOffDelta[18]; // seconds uint8_t outputFaultCnt[18]; - int8_t temp[14]; // 1-4 �MPPT converter temp, 5-8 �output converter temp, 9 �on-board battery temp, 10�12 - // �external battery pack temp, 13-14 -output expander temp - uint8_t battMode; // 0 �critical, 1 �safe, 2 �normal, 3 �full - uint8_t mpptMode; // 0 �HW, 1 �manual, 2 �auto, 3 �auto with timeout - uint8_t batHeaterMode; // 0 �manual, 1 �auto - uint8_t batHeaterState; // 0 �off, 1 �on + int8_t temp[14]; // 1-4 MPPT converter temp, 5-8 output converter temp, 9 on-board battery temp, 10-12 + // external battery pack temp, 13-14 -output expander temp + uint8_t battMode; // 0 critical, 1 safe, 2 normal, 3 full + uint8_t mpptMode; // 0 HW, 1 manual, 2 auto, 3 auto with timeout + uint8_t batHeaterMode; // 0 manual, 1 auto + uint8_t batHeaterState; // 0 off, 1 on uint16_t PingWdt_toggles; // Total number of power channel toggles caused by failed ping watchdog uint8_t PingWdt_turnOffs; // Total number of power channel offs caused by failed ping watchdog }; struct __attribute__((packed)) eps_startup_telemetry { - uint8_t cmd; // value 1 + uint8_t cmd; + int8_t status; double timestamp; // with ms precision uint32_t last_reset_reason_reg; //Last reset reason register value, see below uint32_t bootCnt; // total system boot count uint8_t FallbackConfigUsed; uint8_t rtcInit; uint8_t rtcClkSourceLSE; - uint8_t flashAppInit; +// uint8_t flashAppInit; int8_t Fram4kPartitionInit; int8_t Fram520kPartitionInit; int8_t intFlashPartitionInit; diff --git a/hardware_interface/source/eps.c b/hardware_interface/source/eps.c index b33b5fd..5524833 100644 --- a/hardware_interface/source/eps.c +++ b/hardware_interface/source/eps.c @@ -165,13 +165,15 @@ void EPS_getHK(eps_instantaneous_telemetry_t *telembuf, eps_startup_telemetry_t } //Startup telemetry (defined in ICD Section 24.2.2) + telem_startup_buf->cmd = eps->hk_startup_telemetry.cmd; + telem_startup_buf->status = eps->hk_startup_telemetry.status; telem_startup_buf->timestamp = eps->hk_startup_telemetry.timestamp; telem_startup_buf->last_reset_reason_reg = eps->hk_startup_telemetry.last_reset_reason_reg; telem_startup_buf->bootCnt = eps->hk_startup_telemetry.bootCnt; telem_startup_buf->FallbackConfigUsed = eps->hk_startup_telemetry.FallbackConfigUsed; telem_startup_buf->rtcInit = eps->hk_startup_telemetry.rtcInit; telem_startup_buf->rtcClkSourceLSE = eps->hk_startup_telemetry.rtcClkSourceLSE; - telem_startup_buf->flashAppInit = eps->hk_startup_telemetry.flashAppInit; + //telem_startup_buf->flashAppInit = eps->hk_startup_telemetry.flashAppInit; telem_startup_buf->Fram4kPartitionInit = eps->hk_startup_telemetry.Fram4kPartitionInit; telem_startup_buf->Fram520kPartitionInit = eps->hk_startup_telemetry.Fram520kPartitionInit; telem_startup_buf->intFlashPartitionInit = eps->hk_startup_telemetry.intFlashPartitionInit; @@ -306,22 +308,8 @@ static inline void prv_set_startup_telemetry(eps_startup_telemetry_t telem_start void prv_startup_telemetry_letoh(eps_startup_telemetry_t *telem_startup_buf) { uint8_t i; - telem_startup_buf->timestamp = csp_letoh16(telem_startup_buf->timestamp); - telem_startup_buf->last_reset_reason_reg = csp_letoh16(telem_startup_buf->last_reset_reason_reg); - telem_startup_buf->bootCnt = csp_letoh16(telem_startup_buf->bootCnt); - telem_startup_buf->FallbackConfigUsed = csp_letoh16(telem_startup_buf->FallbackConfigUsed); - telem_startup_buf->rtcInit = csp_letoh32(telem_startup_buf->rtcInit); - telem_startup_buf->rtcClkSourceLSE = csp_letoh32(telem_startup_buf->rtcClkSourceLSE); - telem_startup_buf->flashAppInit = csp_letoh32(telem_startup_buf->flashAppInit); - telem_startup_buf->Fram4kPartitionInit = csp_letoh32(telem_startup_buf->Fram4kPartitionInit); - telem_startup_buf->Fram520kPartitionInit = csp_letoh32(telem_startup_buf->Fram520kPartitionInit); - telem_startup_buf->intFlashPartitionInit = csp_letoh32(telem_startup_buf->intFlashPartitionInit); - telem_startup_buf->FSInit = csp_letoh16(telem_startup_buf->FSInit); - telem_startup_buf->FTInit = csp_letohd(telem_startup_buf->FTInit); - telem_startup_buf->supervisorInit = csp_letohd(telem_startup_buf->supervisorInit); - telem_startup_buf->uart1App = csp_letohd(telem_startup_buf->uart1App); - telem_startup_buf->uart2App = csp_letohd(telem_startup_buf->uart2App); - telem_startup_buf->tmp107Init = csp_letohd(telem_startup_buf->tmp107Init); - -} + telem_startup_buf->timestamp = csp_letohd(telem_startup_buf->timestamp); + telem_startup_buf->last_reset_reason_reg = csp_letoh32(telem_startup_buf->last_reset_reason_reg); + telem_startup_buf->bootCnt = csp_letoh32(telem_startup_buf->bootCnt); +} From 606e3f4b9e8a25b6edf79f87c9f4ac9461e45a76 Mon Sep 17 00:00:00 2001 From: Grace Yi Date: Fri, 12 Nov 2021 14:17:56 -0700 Subject: [PATCH 4/4] substitute 10000with EPS_REQUEST_TIMEOUT --- hardware_interface/source/eps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hardware_interface/source/eps.c b/hardware_interface/source/eps.c index 5524833..d913f5f 100644 --- a/hardware_interface/source/eps.c +++ b/hardware_interface/source/eps.c @@ -54,9 +54,9 @@ static eps_t prvEps; SAT_returnState eps_refresh_instantaneous_telemetry() { uint8_t cmd = 0; // 'subservice' command eps_instantaneous_telemetry_t telembuf; - int res = csp_ping(EPS_APP_ID, 10000, 100, CSP_O_NONE); + int res = csp_ping(EPS_APP_ID, EPS_REQUEST_TIMEOUT, 100, CSP_O_NONE); - csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_INSTANTANEOUS_TELEMETRY, 10000, &cmd, sizeof(cmd), + csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_INSTANTANEOUS_TELEMETRY, EPS_REQUEST_TIMEOUT, &cmd, sizeof(cmd), &telembuf, sizeof(eps_instantaneous_telemetry_t), CSP_O_CRC32); // data is little endian, must convert to host order // refer to the NanoAvionics datasheet for details @@ -69,7 +69,7 @@ SAT_returnState eps_refresh_startup_telemetry() { uint8_t cmd = 1; // ' subservice' command defined in ICD Section 24.2.2 eps_startup_telemetry_t telem_startup_buf; - csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_INSTANTANEOUS_TELEMETRY, 10000, &cmd, sizeof(cmd), + csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_INSTANTANEOUS_TELEMETRY, EPS_REQUEST_TIMEOUT, &cmd, sizeof(cmd), &telem_startup_buf, sizeof(eps_startup_telemetry_t), CSP_O_CRC32); // data is little endian, must convert to host order // refer to the NanoAvionics datasheet for details @@ -210,7 +210,7 @@ int8_t eps_set_pwr_chnl(uint8_t pwr_chnl_port, bool status) { cmd[1] = pwr_chnl_port; cmd[2] = status; // delay = 0 so cmd{4] = cmd[5] = 0 - csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_POWER_CONTROL, 10000, &cmd, sizeof(cmd), &response, + csp_transaction_w_opts(CSP_PRIO_LOW, EPS_APP_ID, EPS_POWER_CONTROL, EPS_REQUEST_TIMEOUT, &cmd, sizeof(cmd), &response, sizeof(response), CSP_O_CRC32); return response[1]; }