diff options
author | Harald Welte <laforge@osmocom.org> | 2019-10-11 10:35:33 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2019-11-24 23:12:04 +0100 |
commit | d401b121369f8ac7b6b09b859771579bfb1892de (patch) | |
tree | e951cbb52a9aad6bbab16ce11c268aff0d0a9e94 | |
parent | 389a4040d5772407085a5fac6ada6dbf33dd94c6 (diff) |
card_emu_tests: Cosmetic changes (re-order code; more comments)
Change-Id: I36aefc824187ee99d83a451d869b137c13334d91
-rw-r--r-- | firmware/test/card_emu_tests.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/firmware/test/card_emu_tests.c b/firmware/test/card_emu_tests.c index fe1739b..a5ba62e 100644 --- a/firmware/test/card_emu_tests.c +++ b/firmware/test/card_emu_tests.c @@ -13,7 +13,9 @@ #define PHONE_INT 2 #define PHONE_DATAOUT 3 -/* stub functions required by card_emu.c */ +/*********************************************************************** + * stub functions required by card_emu.c + ***********************************************************************/ void card_emu_uart_wait_tx_idle(uint8_t uart_chan) { @@ -30,6 +32,7 @@ int card_emu_uart_update_fidi(uint8_t uart_chan, unsigned int fidi) static uint8_t tx_debug_buf[1024]; static unsigned int tx_debug_buf_idx; +/* the card emulator wants to send some data to the host [reader] */ int card_emu_uart_tx(uint8_t uart_chan, uint8_t byte) { printf("UART_TX(%02x)\n", byte); @@ -37,13 +40,6 @@ int card_emu_uart_tx(uint8_t uart_chan, uint8_t byte) return 1; } -static void reader_check_and_clear(const uint8_t *data, unsigned int len) -{ - assert(len == tx_debug_buf_idx); - assert(!memcmp(tx_debug_buf, data, len)); - tx_debug_buf_idx = 0; -} - void card_emu_uart_enable(uint8_t uart_chan, uint8_t rxtx) { char *rts; @@ -95,7 +91,21 @@ void tc_etu_disable(uint8_t chan_nr) printf("tc_etu_disable(tc_chan=%u)\n", chan_nr); } -const uint8_t atr[] = { 0x3b, 0x02, 0x14, 0x50 }; + + +/*********************************************************************** + * test helper functions + ***********************************************************************/ + + +static void reader_check_and_clear(const uint8_t *data, unsigned int len) +{ + assert(len == tx_debug_buf_idx); + assert(!memcmp(tx_debug_buf, data, len)); + tx_debug_buf_idx = 0; +} + +static const uint8_t atr[] = { 0x3b, 0x02, 0x14, 0x50 }; static int verify_atr(struct card_handle *ch) { @@ -130,6 +140,7 @@ static void io_start_card(struct card_handle *ch) verify_atr(ch); } +/* emulate the host/reader sending some bytes to the [emulated] card */ static void reader_send_bytes(struct card_handle *ch, const uint8_t *bytes, unsigned int len) { unsigned int i; |