Skip to content

Commit

Permalink
Mark stale monitoring data in CLI (#29)
Browse files Browse the repository at this point in the history
keep track of last update tick time for I2C based readouts and indicate when the last update was more than 60 seconds ago
  • Loading branch information
pwittich authored Nov 19, 2019
1 parent 696d850 commit d1b846f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
26 changes: 25 additions & 1 deletion projects/cm_mcu/CommandLineTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,14 @@ static BaseType_t mon_ctl(char *m, size_t s, const char *mm)
dcdc_args.n_commands-1);
return pdFALSE;
}

// update times, in seconds
TickType_t now = pdTICKS_TO_MS( xTaskGetTickCount())/1000;
TickType_t last = pdTICKS_TO_MS(dcdc_args.updateTick)/1000;
int copied = 0;
if ( (now-last) > 60 ) {
int mins = (now-last)/60;
copied += snprintf(m+copied, s-copied, "%s: stale data, last update %d minutes ago\r\n", __func__, mins);
}
copied += snprintf(m+copied, s-copied, "%s\r\n", dcdc_args.commands[i1].name);
for (int ps = 0; ps < dcdc_args.n_devices; ++ps) {
copied += snprintf(m+copied, s-copied, "SUPPLY %s\r\n",
Expand Down Expand Up @@ -621,6 +627,17 @@ static BaseType_t ff_ctl(char *m, size_t s, const char *mm)
int copied = 0;
static int whichff = 0;

if ( whichff == 0 ) {
// check for stale data
TickType_t now = pdTICKS_TO_MS( xTaskGetTickCount())/1000;
TickType_t last = pdTICKS_TO_MS(getFFupdateTick())/1000;
if ( (now-last) > 60 ) {
int mins = (now-last)/60;
copied += snprintf(m+copied, s-copied, "%s: stale data, last update %d minutes ago\r\n", __func__, mins);
}

}

if ( argc == 0 ) { // default command: temps

if ( whichff == 0 ) {
Expand Down Expand Up @@ -696,6 +713,13 @@ static BaseType_t fpga_ctl(char *m, size_t s, const char *mm)
static int whichfpga = 0;
int howmany = fpga_args.n_devices*fpga_args.n_pages;
if ( whichfpga == 0 ) {
TickType_t now = pdTICKS_TO_MS( xTaskGetTickCount())/1000;
TickType_t last = pdTICKS_TO_MS(getFFupdateTick())/1000;
if ( (now-last) > 60 ) {
int mins = (now-last)/60;
copied += snprintf(m+copied, s-copied, "%s: stale data, last update %d minutes ago\r\n", __func__, mins);
}

copied += snprintf(m+copied, s-copied, "FPGA monitors\r\n");
copied += snprintf(m+copied, s-copied, "%s\r\n", fpga_args.commands[0].name);
}
Expand Down
8 changes: 7 additions & 1 deletion projects/cm_mcu/FireFlyTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ int8_t getFFvalue(const uint8_t i)
return ff_temp[i];
}

static TickType_t ff_updateTick = 0;
TickType_t getFFupdateTick()
{
return ff_updateTick;
}

static
int write_ff_register(const char *name, uint8_t reg, uint16_t value, int size)
{
Expand Down Expand Up @@ -300,7 +306,7 @@ void FireFlyTask(void *parameters)
break;
}
}

ff_updateTick = xTaskGetTickCount();
// select the appropriate output for the mux
data[0] = 0x1U << ff_i2c_addrs[ff].mux_bit;
char tmp[64];
Expand Down
1 change: 1 addition & 0 deletions projects/cm_mcu/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ header file. */
#define CLI_UART UART4_BASE // Front panel
//#define CLI_UART UART1_BASE // Zynq

#define pdTICKS_TO_MS( xTicks ) ( ( ( TickType_t ) ( xTicks ) * 1000u ) / configTICK_RATE_HZ )

#ifdef __cplusplus
}
Expand Down
2 changes: 2 additions & 0 deletions projects/cm_mcu/MonitorTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void MonitorTask(void *parameters)

bool log = true;
int current_error_cnt = 0;
args->updateTick = xLastWakeTime; // initial value

for (;;) {
// check if the 3.3V is there or not. If it disappears then nothing works
Expand All @@ -105,6 +106,7 @@ void MonitorTask(void *parameters)
else {
good = true;
}
args->updateTick = xTaskGetTickCount(); // current time in ticks
// loop over devices
for ( uint8_t ps = 0; ps < args->n_devices; ++ ps ) {
if ( getPSStatus(5) != PWR_ON)
Expand Down
1 change: 1 addition & 0 deletions projects/cm_mcu/MonitorTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct MonitorTaskArgs_t {
const int n_pages;
tSMBus *smbus;
volatile tSMBusStatus *smbus_status;
volatile TickType_t updateTick;
};
// DC-DC converter
#define NSUPPLIES_PS (5) // 5 devices, 2 pages each
Expand Down
2 changes: 2 additions & 0 deletions projects/cm_mcu/Tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ extern QueueHandle_t xFFlyQueue;

const char* getFFname(const uint8_t i);
int8_t getFFvalue(const uint8_t i);
TickType_t getFFupdateTick();


int disable_xcvr_cdr(const char *name);

Expand Down

0 comments on commit d1b846f

Please sign in to comment.