card_emu: Only transmit NULL byte from the right state
The reader cannot accept a waiting time extension at any time. Rather,
it can only accept it if it is currently waiting for a procedure byte.
diff --git a/firmware/src_simtrace/card_emu.c b/firmware/src_simtrace/card_emu.c
index eea6fc4..81bd5e8 100644
--- a/firmware/src_simtrace/card_emu.c
+++ b/firmware/src_simtrace/card_emu.c
@@ -876,7 +876,21 @@
{
struct card_handle *ch = handle;
/* transmit NULL procedure byte well before waiting time expires */
- card_emu_uart_tx(ch->uart_chan, ISO7816_3_PB_NULL);
+ switch (ch->state) {
+ case ISO_S_IN_TPDU:
+ switch (ch->tpdu.state) {
+ case TPDU_S_WAIT_PB:
+ case TPDU_S_WAIT_TX:
+ putchar('N');
+ card_emu_uart_tx(ch->uart_chan, ISO7816_3_PB_NULL);
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
}
/* hardware driver informs us that one (more) ETU has expired */