1 /* CM5121 backend for OpenCT virtual slot */
5 #include <librfid/rfid_asic.h>
6 #include <openct/openct.h>
8 /* FIXME: get rid of this global crap. In fact this needs to become part of
9 * struct rfid_reader_handle */
10 static ct_lock_handle lock;
13 /* this is the sole function required by rfid_reader_cm5121.c */
15 PC_to_RDR_Escape(void *handle,
16 const unsigned char *tx_buf, unsigned int tx_len,
17 unsigned char *rx_buf, unsigned int *rx_len)
20 ct_handle *h = (ct_handle *) handle;
22 rc = ct_card_transact(h, 1, tx_buf, tx_len, rx_buf, *rx_len);
32 int cm5121_source_init(struct rfid_asic_transport_handle *rath)
36 unsigned char atr[64];
38 h = ct_reader_connect(0);
42 printf("acquiring card lock\n");
43 rc = ct_card_lock(h, slot, IFD_LOCK_EXCLUSIVE, &lock);
45 fprintf(stderr, "error, no card lock\n");
49 rc = ct_card_reset(h, slot, atr, sizeof(atr));
51 fprintf(stderr, "error, can't reset virtual card\n");