From 52d554657cbe7a37026f388099c4419c8ce9921a Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 20 Mar 2016 13:38:05 +0100 Subject: [PATCH] card_emu: Avoid PTS related race-condition We should not set the new Fi/Di values before we actually transmitted the PTSS PCK at the old baud rate first. --- firmware/src_simtrace/card_emu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/src_simtrace/card_emu.c b/firmware/src_simtrace/card_emu.c index 5f0ee7ca..6593daa3 100644 --- a/firmware/src_simtrace/card_emu.c +++ b/firmware/src_simtrace/card_emu.c @@ -440,8 +440,6 @@ static int tx_byte_pts(struct card_handle *ch) break; case PTS_S_WAIT_RESP_PCK: byte = ch->pts.resp[_PCK]; - /* update baud rate generator with Fi/Di */ - emu_update_fidi(ch); break; default: TRACE_ERROR("get_byte_pts() in invalid state %u\r\n", @@ -456,6 +454,8 @@ static int tx_byte_pts(struct card_handle *ch) switch (ch->pts.state) { case PTS_S_WAIT_RESP_PCK: + /* update baud rate generator with Fi/Di */ + emu_update_fidi(ch); /* Wait for the next TPDU */ card_set_state(ch, ISO_S_WAIT_TPDU); set_pts_state(ch, PTS_S_WAIT_REQ_PTSS);