1 /* librfid - core reader handling
2 * (C) 2005-2006 by Harald Welte <laforge@gnumonks.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <librfid/rfid.h>
24 #include <librfid/rfid_reader.h>
25 #include <librfid/rfid_reader_cm5121.h>
26 #include <librfid/rfid_reader_openpcd.h>
27 #include <librfid/rfid_reader_spidev.h>
29 static const struct rfid_reader *rfid_readers[] = {
32 [RFID_READER_CM5121] = &rfid_reader_cm5121,
34 [RFID_READER_OPENPCD] = &rfid_reader_openpcd,
37 [RFID_READER_SPIDEV] = &rfid_reader_spidev,
41 struct rfid_reader_handle *
42 rfid_reader_open(void *data, unsigned int id)
44 const struct rfid_reader *p;
46 if (id >= ARRAY_SIZE(rfid_readers)) {
47 DEBUGP("unable to find matching reader\n");
59 rfid_reader_transceive(struct rfid_reader_handle *rh,
60 enum rfid_frametype frametype,
61 const unsigned char *tx_buf, unsigned int len,
62 unsigned char *rx_buf, unsigned int *rx_len,
63 u_int64_t timeout, unsigned int flags)
65 return rh->reader->transceive(rh, frametype, tx_buf, len, rx_buf,
66 rx_len, timeout, flags);
70 rfid_reader_close(struct rfid_reader_handle *rh)
72 rh->reader->close(rh);
76 rfid_reader_getopt(struct rfid_reader_handle *rh, int optname,
77 void *optval, unsigned int *optlen)
79 return rh->reader->getopt(rh, optname, optval, optlen);
82 int rfid_reader_setopt(struct rfid_reader_handle *rh, int optname,
83 const void *optval, unsigned int optlen)
85 return rh->reader->setopt(rh, optname, optval, optlen);