apr_status_t at_run(at_t *AT, const at_test_t *test) { int dummy = 0, fbuf[AT_NELTS], sbuf[AT_NELTS], tbuf[AT_NELTS]; jmp_buf j; AT->current = 0; AT->prior += AT->plan; AT->name = test->name; AT->plan = test->plan; if (test->fatals) AT->fatal = at_list(AT->pool, test->fatals, fbuf); else AT->fatal = &dummy; if (test->skips) AT->skip = at_list(AT->pool, test->skips, sbuf); else AT->skip = &dummy; if (test->todos) AT->todo = at_list(AT->pool, test->todos, tbuf); else AT->todo = &dummy; AT->abort = &j; if (setjmp(j) == 0) { test->func(AT); return APR_SUCCESS; } AT->abort = NULL; return APR_EGENERAL; }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(at_test_process, ev, data) { PROCESS_BEGIN(); struct at_cmd *a; /* Initialize the driver, default is UART0 */ at_init(0); /* Register a list of commands, is mandatory to start with "AT" */ at_register(&at_cmd_test, &at_test_process, "AT", 2, 2, at_cmd_test_callback); at_register(&at_cmd_board, &at_test_process, "AT&V", 4, 4, at_cmd_board_callback); at_register(&at_cmd_led, &at_test_process, "AT&LED", 6, 10, at_cmd_leds_callback); at_register(&at_cmd_addr, &at_test_process, "AT&A", 4, 4, at_cmd_address_callback); at_register(&at_cmd_gpio, &at_test_process, "AT&GPIO=", 8, 12, at_cmd_gpio_callback); at_register(&at_cmd_read, &at_test_process, "AT&READ=", 8, 10, at_cmd_read_callback); at_register(&at_cmd_adc, &at_test_process, "AT&ADC=", 7, 8, at_cmd_adc_callback); at_register(&at_cmd_flop, &at_test_process, "AT&FLOP=", 8, 10, at_cmd_flop_callback); at_register(&at_cmd_reset, &at_test_process, "AT&RESET=", 9, 10, at_cmd_reset_callback); at_register(&at_cmd_sha256, &at_test_process, "AT&SHA256=", 10, 64, at_cmd_sha256_callback); /* Print the command list */ PRINTF("AT command list:\n"); for(a = at_list(); a != NULL; a = list_item_next(a)) { PRINTF("* HDR %s LEN %u MAX %u\n", a->cmd_header, a->cmd_hdr_len, a->cmd_max_len); } /* * When an AT command is received over the serial line, the registered * callbacks will be invoked, let the process spin until then */ while(1) { PROCESS_YIELD(); } PROCESS_END(); }