mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-17 05:38:33 +03:00
various printf/debug output improvements
... among those is a rotor (\|/-) that is printed by the main loop, so one can observe if the main loop is still executing or the system is somehow stuck.
This commit is contained in:
@@ -141,8 +141,8 @@ uint32_t ISO7816_SendChar( uint8_t CharToSend, Usart_info *usart )
|
||||
while((us_base->US_CSR & (US_CSR_TXRDY)) == 0) {
|
||||
i++;
|
||||
if (!(i%1000000)) {
|
||||
printf("s: %x\n", us_base->US_CSR);
|
||||
printf("s: %x\n", us_base->US_RHR & 0xFF);
|
||||
printf("s: %x ", us_base->US_CSR);
|
||||
printf("s: %x\r\n", us_base->US_RHR & 0xFF);
|
||||
us_base->US_CR = US_CR_RSTTX;
|
||||
us_base->US_CR = US_CR_RSTRX;
|
||||
}
|
||||
@@ -152,6 +152,8 @@ uint32_t ISO7816_SendChar( uint8_t CharToSend, Usart_info *usart )
|
||||
/* Transmit a char */
|
||||
us_base->US_THR = CharToSend;
|
||||
|
||||
TRACE_ERROR("Sx%02X\r\n", CharToSend);
|
||||
|
||||
status = (us_base->US_CSR&(US_CSR_OVRE|US_CSR_FRAME|
|
||||
US_CSR_PARE|US_CSR_TIMEOUT|US_CSR_NACK|
|
||||
(1<<10)));
|
||||
|
||||
@@ -495,7 +495,7 @@ static void add_tpdu_byte(struct card_handle *ch, uint8_t byte)
|
||||
if (!ch->uart_rx_ctx) {
|
||||
rctx = ch->uart_rx_ctx = req_ctx_find_get(0, RCTX_S_FREE, RCTX_S_UART_RX_BUSY);
|
||||
if (!ch->uart_rx_ctx) {
|
||||
TRACE_DEBUG("Received UART byte but unable to allocate Rx Buf\r\n");
|
||||
TRACE_ERROR("Received UART byte but ENOMEM\r\n");
|
||||
return;
|
||||
}
|
||||
rd = (struct cardemu_usb_msg_rx_data *) ch->uart_rx_ctx->data;
|
||||
@@ -845,7 +845,7 @@ void card_emu_io_statechg(struct card_handle *ch, enum card_io io, int active)
|
||||
break;
|
||||
case CARD_IO_RST:
|
||||
if (active == 0 && ch->in_reset) {
|
||||
TRACE_DEBUG("RST released\r\n");
|
||||
TRACE_INFO("RST released\r\n");
|
||||
if (ch->vcc_active && ch->clocked) {
|
||||
/* enable the TC/ETU counter once reset has been released */
|
||||
tc_etu_enable(ch->tc_chan);
|
||||
@@ -854,7 +854,7 @@ void card_emu_io_statechg(struct card_handle *ch, enum card_io io, int active)
|
||||
card_set_state(ch, ISO_S_IN_ATR);
|
||||
}
|
||||
} else if (active && !ch->in_reset) {
|
||||
TRACE_DEBUG("RST asserted\r\n");
|
||||
TRACE_INFO("RST asserted\r\n");
|
||||
tc_etu_disable(ch->tc_chan);
|
||||
}
|
||||
ch->in_reset = active;
|
||||
@@ -902,6 +902,7 @@ void tc_etu_wtime_half_expired(void *handle)
|
||||
/* hardware driver informs us that one (more) ETU has expired */
|
||||
void tc_etu_wtime_expired(void *handle)
|
||||
{
|
||||
TRACE_ERROR("wtime_exp\r\n");
|
||||
}
|
||||
|
||||
/* shortest ATR found in smartcard_list.txt */
|
||||
|
||||
@@ -103,7 +103,7 @@ extern int main( void )
|
||||
|
||||
SIMtrace_USB_Initialize();
|
||||
|
||||
printf("%s", "USB init\n\r");
|
||||
TRACE_INFO("USB init...\n\r");
|
||||
while(USBD_GetState() < USBD_STATE_CONFIGURED){
|
||||
if(i >= MAX_USB_ITER*3) {
|
||||
TRACE_ERROR("Resetting board (USB could not be configured)\n");
|
||||
@@ -112,16 +112,21 @@ extern int main( void )
|
||||
i++;
|
||||
}
|
||||
|
||||
TRACE_DEBUG("calling configure of all configurations...\n\r");
|
||||
for (i = 1; i < sizeof(config_func_ptrs)/sizeof(config_func_ptrs[0]); ++i)
|
||||
{
|
||||
config_func_ptrs[i].configure();
|
||||
}
|
||||
|
||||
TRACE_DEBUG("calling init of config %u...\n\r", simtrace_config);
|
||||
config_func_ptrs[simtrace_config].init();
|
||||
last_simtrace_config = simtrace_config;
|
||||
|
||||
printf("%s", "Start\n\r");
|
||||
TRACE_DEBUG("entering main loop...\n\r");
|
||||
while(1) {
|
||||
const char rotor[] = { '-', '\\', '|', '/' };
|
||||
putchar('\b');
|
||||
putchar(rotor[i++ % ARRAY_SIZE(rotor)]);
|
||||
|
||||
if (USBD_GetState() < USBD_STATE_CONFIGURED) {
|
||||
|
||||
@@ -130,15 +135,14 @@ extern int main( void )
|
||||
}
|
||||
}
|
||||
else if (isUsbConnected == 0) {
|
||||
printf("USB is now configured\n\r");
|
||||
TRACE_INFO("USB is now configured\n\r");
|
||||
LED_Set(LED_NUM_GREEN);
|
||||
LED_Clear(LED_NUM_RED);
|
||||
|
||||
isUsbConnected = 1;
|
||||
}
|
||||
|
||||
|
||||
if (last_simtrace_config != simtrace_config) {
|
||||
TRACE_INFO("USB config chg %u -> %u\r\n", last_simtrace_config, simtrace_config);
|
||||
config_func_ptrs[last_simtrace_config].exit();
|
||||
config_func_ptrs[simtrace_config].init();
|
||||
last_simtrace_config = simtrace_config;
|
||||
|
||||
Reference in New Issue
Block a user