From e3e3fa87a3f04582e62d217a27d38f613fdc4817 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 10 Sep 2009 09:16:44 +0000 Subject: [PATCH] moved mifare-read to seperate directory cleaned up mifare-read Makefile --- Makefile | 7 ---- mifare-read.c | 92 --------------------------------------------- mifare-read/Makefile | 30 +++++++++++++++ mifare-read/mifare-read.c | 92 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 99 deletions(-) delete mode 100755 Makefile delete mode 100644 mifare-read.c create mode 100755 mifare-read/Makefile create mode 100644 mifare-read/mifare-read.c diff --git a/Makefile b/Makefile deleted file mode 100755 index b852cc6..0000000 --- a/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -## realraum tuer daemon - -all: mifare-read - -mifare-read: mifare-read.c - $(CC) $(CFLAGS) -lrfid -o $@ $< - diff --git a/mifare-read.c b/mifare-read.c deleted file mode 100644 index 80cb57e..0000000 --- a/mifare-read.c +++ /dev/null @@ -1,92 +0,0 @@ -/* mifare-tool - a small command-line tool for librfid mifare testing - * - * (C) 2006 by Harald Welte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -struct rfid_reader_handle *rh = NULL; -struct rfid_layer2_handle *l2h = NULL; - -void sigHandler(int sig) -{ - printf("sig handler called\n"); - -/* rfid_layer2_close(l2h); */ -/* rfid_layer2_fini(l2h); */ - - rfid_reader_close(rh); - exit(0); -} - -int l2_init(int layer2) -{ - int rc; - - l2h = rfid_layer2_init(rh, layer2); - if (!l2h) { - fprintf(stderr, "error during layer2(%d)_init (0=14a,1=14b,3=15)\n",layer2); - return -1; - } - - rc = rfid_layer2_open(l2h); - if (rc < 0) { -// fprintf(stderr, "error during layer2_open\n"); - return rc; - } - - return 0; -} - -int main(int argc, char **argv) -{ - unsigned int uid, uid_len; - - rfid_init(); - rh = rfid_reader_open(NULL, RFID_READER_OPENPCD); - if (!rh) { - fprintf(stderr, "No OpenPCD found\n"); - exit(1); - } - - (void) signal(SIGHUP, sigHandler); - (void) signal(SIGINT, sigHandler); - (void) signal(SIGTERM, sigHandler); - - while(l2_init(RFID_LAYER2_ISO14443A) < 0); - - uid_len = sizeof(uid); - uid = 0; - if(rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID, &uid, &uid_len) >= 0) - printf("UID=%08X\n",uid); - fflush(stdout); - -/* rfid_layer2_close(l2h); */ -/* rfid_layer2_fini(l2h); */ - - rfid_reader_close(rh); - exit(0); -} - diff --git a/mifare-read/Makefile b/mifare-read/Makefile new file mode 100755 index 0000000..a48ba7a --- /dev/null +++ b/mifare-read/Makefile @@ -0,0 +1,30 @@ +## +## mifare-read +## +## Copyright (C) 2009 Christian Pointner +## +## This file is part of mifare-read. +## +## mifare-read is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License version 3 as +## published by the Free Software Foundation. +## +## mifare-read is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with mifare-read. If not, see . +## + +EXECUTABLE := mifare-read + +all: $(EXECUTABLE) + +mifare-read: mifare-read.c + $(CC) $(CFLAGS) -lrfid -o $@ $< + +clean: + rm -f $(EXECUTABLE) + diff --git a/mifare-read/mifare-read.c b/mifare-read/mifare-read.c new file mode 100644 index 0000000..80cb57e --- /dev/null +++ b/mifare-read/mifare-read.c @@ -0,0 +1,92 @@ +/* mifare-tool - a small command-line tool for librfid mifare testing + * + * (C) 2006 by Harald Welte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +struct rfid_reader_handle *rh = NULL; +struct rfid_layer2_handle *l2h = NULL; + +void sigHandler(int sig) +{ + printf("sig handler called\n"); + +/* rfid_layer2_close(l2h); */ +/* rfid_layer2_fini(l2h); */ + + rfid_reader_close(rh); + exit(0); +} + +int l2_init(int layer2) +{ + int rc; + + l2h = rfid_layer2_init(rh, layer2); + if (!l2h) { + fprintf(stderr, "error during layer2(%d)_init (0=14a,1=14b,3=15)\n",layer2); + return -1; + } + + rc = rfid_layer2_open(l2h); + if (rc < 0) { +// fprintf(stderr, "error during layer2_open\n"); + return rc; + } + + return 0; +} + +int main(int argc, char **argv) +{ + unsigned int uid, uid_len; + + rfid_init(); + rh = rfid_reader_open(NULL, RFID_READER_OPENPCD); + if (!rh) { + fprintf(stderr, "No OpenPCD found\n"); + exit(1); + } + + (void) signal(SIGHUP, sigHandler); + (void) signal(SIGINT, sigHandler); + (void) signal(SIGTERM, sigHandler); + + while(l2_init(RFID_LAYER2_ISO14443A) < 0); + + uid_len = sizeof(uid); + uid = 0; + if(rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID, &uid, &uid_len) >= 0) + printf("UID=%08X\n",uid); + fflush(stdout); + +/* rfid_layer2_close(l2h); */ +/* rfid_layer2_fini(l2h); */ + + rfid_reader_close(rh); + exit(0); +} + -- 1.7.10.4