summaryrefslogtreecommitdiff
path: root/src/ccid/rfid_reader_cm5121_ccid_direct.c
blob: 9879ccf24a77116014a1dfc59bf8db74d4f3b5d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* CM5121 backend for 'internal' CCID driver */
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

#include <librfid/rfid.h>

#ifndef LIBRFID_FIRMWARE

#include <librfid/rfid_asic.h>

#include "ccid-driver.h"

/* this is the sole function required by rfid_reader_cm5121.c */
int 
PC_to_RDR_Escape(void *handle, 
		 const unsigned char *tx_buf, size_t tx_len,
		 unsigned char *rx_buf, size_t *rx_len)
{
	int rc;
        ccid_driver_t ch = handle;
        size_t maxrxlen = *rx_len;

        rc = ccid_transceive_escape (ch, tx_buf, tx_len,
                                     rx_buf, maxrxlen, rx_len);

	return rc;
}

int cm5121_source_init(struct rfid_asic_transport_handle *rath)
{
	int rc;

        rc = ccid_open_reader(&rath->data, NULL);
        if (rc) {
                fprintf (stderr, "failed to open CCID reader: %#x\n", rc);
                return -1;
        }
	return 0;
}

#endif /* LIBRFID_FIRMWARE */
personal git repositories of Harald Welte. Your mileage may vary