mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-25 17:58:32 +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) {
|
while((us_base->US_CSR & (US_CSR_TXRDY)) == 0) {
|
||||||
i++;
|
i++;
|
||||||
if (!(i%1000000)) {
|
if (!(i%1000000)) {
|
||||||
printf("s: %x\n", us_base->US_CSR);
|
printf("s: %x ", us_base->US_CSR);
|
||||||
printf("s: %x\n", us_base->US_RHR & 0xFF);
|
printf("s: %x\r\n", us_base->US_RHR & 0xFF);
|
||||||
us_base->US_CR = US_CR_RSTTX;
|
us_base->US_CR = US_CR_RSTTX;
|
||||||
us_base->US_CR = US_CR_RSTRX;
|
us_base->US_CR = US_CR_RSTRX;
|
||||||
}
|
}
|
||||||
@@ -152,6 +152,8 @@ uint32_t ISO7816_SendChar( uint8_t CharToSend, Usart_info *usart )
|
|||||||
/* Transmit a char */
|
/* Transmit a char */
|
||||||
us_base->US_THR = CharToSend;
|
us_base->US_THR = CharToSend;
|
||||||
|
|
||||||
|
TRACE_ERROR("Sx%02X\r\n", CharToSend);
|
||||||
|
|
||||||
status = (us_base->US_CSR&(US_CSR_OVRE|US_CSR_FRAME|
|
status = (us_base->US_CSR&(US_CSR_OVRE|US_CSR_FRAME|
|
||||||
US_CSR_PARE|US_CSR_TIMEOUT|US_CSR_NACK|
|
US_CSR_PARE|US_CSR_TIMEOUT|US_CSR_NACK|
|
||||||
(1<<10)));
|
(1<<10)));
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ static void add_tpdu_byte(struct card_handle *ch, uint8_t byte)
|
|||||||
if (!ch->uart_rx_ctx) {
|
if (!ch->uart_rx_ctx) {
|
||||||
rctx = ch->uart_rx_ctx = req_ctx_find_get(0, RCTX_S_FREE, RCTX_S_UART_RX_BUSY);
|
rctx = ch->uart_rx_ctx = req_ctx_find_get(0, RCTX_S_FREE, RCTX_S_UART_RX_BUSY);
|
||||||
if (!ch->uart_rx_ctx) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
rd = (struct cardemu_usb_msg_rx_data *) ch->uart_rx_ctx->data;
|
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;
|
break;
|
||||||
case CARD_IO_RST:
|
case CARD_IO_RST:
|
||||||
if (active == 0 && ch->in_reset) {
|
if (active == 0 && ch->in_reset) {
|
||||||
TRACE_DEBUG("RST released\r\n");
|
TRACE_INFO("RST released\r\n");
|
||||||
if (ch->vcc_active && ch->clocked) {
|
if (ch->vcc_active && ch->clocked) {
|
||||||
/* enable the TC/ETU counter once reset has been released */
|
/* enable the TC/ETU counter once reset has been released */
|
||||||
tc_etu_enable(ch->tc_chan);
|
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);
|
card_set_state(ch, ISO_S_IN_ATR);
|
||||||
}
|
}
|
||||||
} else if (active && !ch->in_reset) {
|
} else if (active && !ch->in_reset) {
|
||||||
TRACE_DEBUG("RST asserted\r\n");
|
TRACE_INFO("RST asserted\r\n");
|
||||||
tc_etu_disable(ch->tc_chan);
|
tc_etu_disable(ch->tc_chan);
|
||||||
}
|
}
|
||||||
ch->in_reset = active;
|
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 */
|
/* hardware driver informs us that one (more) ETU has expired */
|
||||||
void tc_etu_wtime_expired(void *handle)
|
void tc_etu_wtime_expired(void *handle)
|
||||||
{
|
{
|
||||||
|
TRACE_ERROR("wtime_exp\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* shortest ATR found in smartcard_list.txt */
|
/* shortest ATR found in smartcard_list.txt */
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ extern int main( void )
|
|||||||
|
|
||||||
SIMtrace_USB_Initialize();
|
SIMtrace_USB_Initialize();
|
||||||
|
|
||||||
printf("%s", "USB init\n\r");
|
TRACE_INFO("USB init...\n\r");
|
||||||
while(USBD_GetState() < USBD_STATE_CONFIGURED){
|
while(USBD_GetState() < USBD_STATE_CONFIGURED){
|
||||||
if(i >= MAX_USB_ITER*3) {
|
if(i >= MAX_USB_ITER*3) {
|
||||||
TRACE_ERROR("Resetting board (USB could not be configured)\n");
|
TRACE_ERROR("Resetting board (USB could not be configured)\n");
|
||||||
@@ -112,16 +112,21 @@ extern int main( void )
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE_DEBUG("calling configure of all configurations...\n\r");
|
||||||
for (i = 1; i < sizeof(config_func_ptrs)/sizeof(config_func_ptrs[0]); ++i)
|
for (i = 1; i < sizeof(config_func_ptrs)/sizeof(config_func_ptrs[0]); ++i)
|
||||||
{
|
{
|
||||||
config_func_ptrs[i].configure();
|
config_func_ptrs[i].configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE_DEBUG("calling init of config %u...\n\r", simtrace_config);
|
||||||
config_func_ptrs[simtrace_config].init();
|
config_func_ptrs[simtrace_config].init();
|
||||||
last_simtrace_config = simtrace_config;
|
last_simtrace_config = simtrace_config;
|
||||||
|
|
||||||
printf("%s", "Start\n\r");
|
TRACE_DEBUG("entering main loop...\n\r");
|
||||||
while(1) {
|
while(1) {
|
||||||
|
const char rotor[] = { '-', '\\', '|', '/' };
|
||||||
|
putchar('\b');
|
||||||
|
putchar(rotor[i++ % ARRAY_SIZE(rotor)]);
|
||||||
|
|
||||||
if (USBD_GetState() < USBD_STATE_CONFIGURED) {
|
if (USBD_GetState() < USBD_STATE_CONFIGURED) {
|
||||||
|
|
||||||
@@ -130,15 +135,14 @@ extern int main( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isUsbConnected == 0) {
|
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_Set(LED_NUM_GREEN);
|
||||||
LED_Clear(LED_NUM_RED);
|
LED_Clear(LED_NUM_RED);
|
||||||
|
|
||||||
isUsbConnected = 1;
|
isUsbConnected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (last_simtrace_config != simtrace_config) {
|
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[last_simtrace_config].exit();
|
||||||
config_func_ptrs[simtrace_config].init();
|
config_func_ptrs[simtrace_config].init();
|
||||||
last_simtrace_config = simtrace_config;
|
last_simtrace_config = simtrace_config;
|
||||||
|
|||||||
Reference in New Issue
Block a user