card_emu: fix set_tpdu_state()

* don't enter a state we are already in
* enable the UART receiver not only when waiting for CLA, but also
  generally when we're waiting for more data from the reader
This commit is contained in:
Harald Welte
2015-11-14 20:58:48 +01:00
parent 2935b3c479
commit 05b41c62f6

View File

@@ -385,9 +385,14 @@ static void add_tpdu_byte(struct card_handle *ch, uint8_t byte)
static void set_tpdu_state(struct card_handle *ch, enum tpdu_state new_ts) static void set_tpdu_state(struct card_handle *ch, enum tpdu_state new_ts)
{ {
if (ch->tpdu.state == new_ts)
return;
TRACE_DEBUG("7816 TPDU state %u -> %u\n", ch->tpdu.state, new_ts); TRACE_DEBUG("7816 TPDU state %u -> %u\n", ch->tpdu.state, new_ts);
switch (new_ts) { switch (new_ts) {
case TPDU_S_WAIT_CLA: case TPDU_S_WAIT_CLA:
case TPDU_S_WAIT_RX:
card_emu_uart_enable(ch->uart_chan, ENABLE_RX); card_emu_uart_enable(ch->uart_chan, ENABLE_RX);
break; break;
case TPDU_S_WAIT_PB: case TPDU_S_WAIT_PB:
@@ -397,6 +402,7 @@ static void set_tpdu_state(struct card_handle *ch, enum tpdu_state new_ts)
card_emu_uart_enable(ch->uart_chan, ENABLE_TX); card_emu_uart_enable(ch->uart_chan, ENABLE_TX);
break; break;
} }
ch->tpdu.state = new_ts; ch->tpdu.state = new_ts;
} }