messing around with usb_*
[rfid/librfid.git] / src / rfid_reader_cm5121_ccid_direct.c
1 /* CM5121 backend for 'internal' CCID driver */
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <stdio.h>
5
6 #include <librfid/rfid_asic.h>
7
8 #include "ccid/ccid-driver.h"
9
10 /* this is the sole function required by rfid_reader_cm5121.c */
11 int 
12 PC_to_RDR_Escape(void *handle, 
13                  const unsigned char *tx_buf, unsigned int tx_len,
14                  unsigned char *rx_buf, unsigned int *rx_len)
15 {
16         int rc;
17         ccid_driver_t ch = handle;
18         size_t maxrxlen = *rx_len;
19
20         rc = ccid_transceive_escape (ch, tx_buf, tx_len,
21                                      rx_buf, maxrxlen, rx_len);
22
23         return rc;
24 }
25
26 int cm5121_source_init(struct rfid_asic_transport_handle *rath)
27 {
28         int rc;
29
30         rc = ccid_open_reader(&rath->data, NULL);
31         if (rc) {
32                 fprintf (stderr, "failed to open CCID reader: %#x\n", rc);
33                 return -1;
34         }
35         return 0;
36 }