static void run_wait_event_unblock(shell_t *shell, char *tag, listener_t *listener) { char *s = listener_raised(listener); if ( debug_flag ) { /* For speedup in non-debug mode */ debug("Wait conditions unblocked: %s\n", s); } /* Replicate message to WAIT synchronization output */ if ( run_wait_output != NULL ) { fputs(s, run_wait_output); fputs(_LF, run_wait_output); } /* Dump event to result file */ run_prompt_cr(shell); result_puts(result_header_engine(tag)); result_puts("CONTINUE "); result_puts(s); result_puts("\n"); run_prompt(shell); free(s); }
static int run_wait_event_process(shell_t *shell, int fd, char **pbuf) { periph_item_t *item = periph_fd_retrieve(run_periph, fd); char *buf; /* Should never occur... */ if ( item == NULL ) { shell_error(shell, "!! PANIC !! Unable to retrieve peripheral from fd=%d\n", fd); return -1; } #ifdef DEBUG_SELECT if ( debug_flag ) { /* For speedup in non-debug mode */ debug("Something to read from '%s' (fd=%d)\n", item->id, fd); } #endif /* Fetch data from peripheral: buf will be set to NULL if no complete message is available */ run_prompt_cr(shell); if ( result_dump_periph(item, &buf) == -1 ) return -1; run_prompt(shell); /* Check awaited patterns if a complete message arrived */ if ( buf != NULL ) { trig_update(item, buf); } if ( pbuf != NULL ) *pbuf = buf; return 0; }
static int run_prologue(shell_t *shell, void *arg) { int input_fd = shell_get_fd(shell); int ret; /* Display prompt if interactive mode */ run_prompt(shell); /* Wait for input while accepting events */ while ( (ret = run_wait_input(shell, input_fd)) == 0 ); if ( ret == -1 ) return -1; return 0; }
int main(int argc, char **argv) { init_all(argc, argv); if (source.type == SOURCE_TYPE_FILE) { run_file(); } else { // SOURCE_TYPE_PROMPT run_prompt(); } cleanup(); return 0; }
static void run_wait_event_timeout(shell_t *shell, char *tag) { /* A wait timeout occured */ if ( debug_flag ) { /* For speedup in non-debug mode */ debug("Timeout!\n"); } /* Send blank message to WAIT synchronization output */ if ( run_wait_output != NULL ) { fputs(_LF, run_wait_output); } /* Dump event to result file */ run_prompt_cr(shell); result_dump_engine(tag, "TIMEOUT %ld.%03ld s", run_wait_timeout / 1000, run_wait_timeout % 1000); run_prompt(shell); }
static int run_wait_event_disconnect(periph_item_t *item, shell_t *shell) { /* Close peripheral connection */ if ( periph_close(run_periph, item) == -1 ) { shell_error(shell, "!! PANIC !! Cannot close peripheral '%s'\n", item->id); return -1; } /* Report connections status for newly connected peripherals */ run_prompt_cr(shell); result_dump_engine(TAG_CLOSE, periph_item_info(item)); /* Remove peripheral from WITH specifications */ if ( item == run_with ) { run_with = NULL; result_dump_engine(TAG_WITH, "NULL"); } run_prompt(shell); return 0; }