Skip to content

Commit

Permalink
add CLI command to check FPGA done* (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittich authored Feb 1, 2020
1 parent 588e082 commit 9f6de3c
Showing 1 changed file with 62 additions and 33 deletions.
95 changes: 62 additions & 33 deletions projects/cm_mcu/CommandLineTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,45 +709,74 @@ static BaseType_t ff_ctl(char *m, size_t s, const char *mm)
// right now.
static BaseType_t fpga_ctl(char *m, size_t s, const char *mm)
{
int copied = 0;
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);
int8_t *p1;
BaseType_t p1l;
int argc = 0;
p1 = FreeRTOS_CLIGetParameter(mm, 1, &p1l);
if ( p1 != NULL ) {
++argc;
p1[p1l] = 0x00; // terminate strings
}
if ( argc == 1 ) {
if ( strncmp(p1, "done",4) == 0 ) { // print out value of done pins
int ku_done_ = read_gpio_pin(_K_FPGA_DONE);
int vu_done_ = read_gpio_pin(_V_FPGA_DONE);
//int copied =
snprintf(m, s, "KU_DONE* = %d\r\nVU_DONE* = %d\r\n", ku_done_, vu_done_);
return pdFALSE;
}
else {
snprintf(m, s, "%s: invalid command %s\r\n", __func__, p1);
return pdFALSE;
}

copied += snprintf(m+copied, s-copied, "FPGA monitors\r\n");
copied += snprintf(m+copied, s-copied, "%s\r\n", fpga_args.commands[0].name);
}
else if (argc != 0 ) {
// error, invalid
snprintf(m,s, "%s: invalid argument count %d\r\n", __func__);
return pdFALSE;
}
else {
int copied = 0;
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);
}

for ( ; whichfpga < howmany; ++whichfpga ) {
float val = fpga_args.pm_values[whichfpga];
int tens = val;
int frac = ABS((val - tens)*100.0);

copied += snprintf(m+copied, s-copied, "%5s: %02d.%02d",
fpga_args.devices[whichfpga].name, tens, frac);
if ( whichfpga%2 == 1 )
copied += snprintf(m+copied, s-copied, "\r\n");
else
copied += snprintf(m+copied, s-copied, "\t");
if ( (s-copied ) < 20 ) {
++whichfpga;
return pdTRUE;
copied += snprintf(m+copied, s-copied, "FPGA monitors\r\n");
copied += snprintf(m+copied, s-copied, "%s\r\n", fpga_args.commands[0].name);
}

for ( ; whichfpga < howmany; ++whichfpga ) {
float val = fpga_args.pm_values[whichfpga];
int tens = val;
int frac = ABS((val - tens)*100.0);

copied += snprintf(m+copied, s-copied, "%5s: %02d.%02d",
fpga_args.devices[whichfpga].name, tens, frac);
if ( whichfpga%2 == 1 )
copied += snprintf(m+copied, s-copied, "\r\n");
else
copied += snprintf(m+copied, s-copied, "\t");
if ( (s-copied ) < 20 ) {
++whichfpga;
return pdTRUE;
}

}
if ( whichfpga%2 ==1 ) {
m[copied++] = '\r';
m[copied++] = '\n';
m[copied] = '\0';
}
whichfpga = 0;
return pdFALSE;
}
if ( whichfpga%2 ==1 ) {
m[copied++] = '\r';
m[copied++] = '\n';
m[copied] = '\0';
}
whichfpga = 0;
return pdFALSE;
}

// this command takes no arguments since there is only one command
Expand Down Expand Up @@ -1217,7 +1246,7 @@ CLI_Command_Definition_t fpga_command = {
.pcCommand="fpga",
.pcHelpString="fpga\r\n Displays a table showing the state of FPGAs.\r\n",
.pxCommandInterpreter = fpga_ctl,
0
-1
};
static
CLI_Command_Definition_t sensor_summary_command = {
Expand Down

0 comments on commit 9f6de3c

Please sign in to comment.