From 868b6d0c68f52385f7924e7d63eb1a5e92642f3a Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 23 Mar 2012 00:03:45 +0100 Subject: simtrace: introduce statistics the statistics count various events like overruns, parity errors, missing rctx and can dump those stats via USB as well as on the serial console. --- firmware/src/simtrace/main_simtrace.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'firmware/src/simtrace/main_simtrace.c') diff --git a/firmware/src/simtrace/main_simtrace.c b/firmware/src/simtrace/main_simtrace.c index 0f2bfc5..6f82d96 100644 --- a/firmware/src/simtrace/main_simtrace.c +++ b/firmware/src/simtrace/main_simtrace.c @@ -33,6 +33,7 @@ #include #include #include +#include enum simtrace_md { SIMTRACE_MD_OFF, @@ -117,6 +118,24 @@ static void simtrace_set_mode(enum simtrace_md mode) } } +static int simtrace_usb_in(struct req_ctx *rctx) +{ + struct openpcd_hdr *poh = (struct openpcd_hdr *) &rctx->data[0]; + struct simtrace_stats *stats_in; + struct simtrace_stats *stats = (struct simtrace_stats *) poh->data; + + switch (poh->cmd) { + case SIMTRACE_MSGT_STATS: + stats_in = iso_uart_stats_get(); + memcpy(stats, stats_in, sizeof(*stats)); + req_ctx_set_state(rctx, RCTX_STATE_UDP_EP2_PENDING); + break; + default: + req_ctx_set_state(rctx, RCTX_STATE_FREE); + break; + } +} + void _init_func(void) { /* low-level hardware initialization */ @@ -126,6 +145,7 @@ void _init_func(void) sim_switch_init(); usbtest_init(); + usb_hdlr_register(&simtrace_usb_in, OPENPCD_CMD_CLS_ADC); /* high-level protocol */ //opicc_usbapi_init(); @@ -150,7 +170,7 @@ static void help(void) "l: set nRST to low (active)\r\n" "h: set nRST to high (inactive)\r\n" "o: set nRST to input\r\n" - "r: set Rx mode for UART\r\n" + "t: ISO UART statistics\r\n" "s: disconnect SIM bus switch\r\n" "S: connect SIM bus switch\r\n"); } @@ -167,6 +187,9 @@ int _main_dbgu(char key) case 'S': simtrace_set_mode(SIMTRACE_MD_SNIFFER); break; + case 't': + iso_uart_stats_dump(); + break; case 'r': iso_uart_rx_mode(); break; -- cgit v1.2.3