From: hackbard Date: Sat, 25 Feb 2006 18:19:44 +0000 (+0000) Subject: initial checkin of the gemtag support X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=c8c92a9a0bb6354e1740a838b3f51000b59f4e97;p=rfid%2Flibrfid.git initial checkin of the gemtag support --- diff --git a/gemtag/Makefile b/gemtag/Makefile new file mode 100644 index 0000000..c7866af --- /dev/null +++ b/gemtag/Makefile @@ -0,0 +1,7 @@ +all: gemtag + +gemtag: gemtag.o + $(CC) -lusb -o $@ $^ + +clean: + rm -f gemtag *.o diff --git a/gemtag/gemtag.c b/gemtag/gemtag.c new file mode 100644 index 0000000..28538c7 --- /dev/null +++ b/gemtag/gemtag.c @@ -0,0 +1,106 @@ +/* + * (C) 2006 by Frank Zirkelbach + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +#include +#include "gemtag.h" + +/* variables */ + +struct gemtag_handle { + struct usb_dev_handle *handle; +}; + +/* functions */ + +struct usb_device *find_device(unsigned short vendor, unsigned short device) { + + struct usb_bus *bus; + struct usb_device *dev; + + bus=usb_get_busses(); + while(bus) { + dev=bus->devices; + while(dev) { + if(dev->descriptor.idVendor==vendor && + dev->descriptor.idProduct==device) + return dev; + dev=dev->next; + } + bus=bus->next; + } + return NULL; +} + +struct gemtag_handle *gemtag_open(void) { + struct usb_device *gemtag; + unsigned char rbuf[16]; + unsigned int rlen; + unsigned int i,numconf; + unsigned int j,numint; + struct gemtag_handle *gh; + + rlen=sizeof(rbuf); + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + gemtag=find_device(USB_VENDOR_GEMTAG, USB_DEVICE_X501); + if(!gemtag) return NULL; + + gh=malloc(sizeof(struct gemtag_handle)); + if(!gh) return NULL; + + memset(gh,0,sizeof(struct gemtag_handle)); + + numconf=gemtag->descriptor.bNumConfigurations; + printf("found gemtag, %u configurations\n",numconf); + for(i=0;iconfig[i].bNumInterfaces; + printf("config %u [nr %u] has %u interfaces\n", + i,gemtag->config[i].bConfigurationValue, + numint); + for(j=0;jconfig[i].interface[j].num_altsetting); + } + } + + gh->handle=usb_open(gemtag); + if(!gh->handle) + goto out_free; + +out_free: + free(gh); + return NULL; +} + +int main(int argc, char **argv) { + + struct gemtag_handle *gh; + + gh=gemtag_open(); + + return 1; +} + diff --git a/gemtag/gemtag.h b/gemtag/gemtag.h new file mode 100644 index 0000000..6e01bd2 --- /dev/null +++ b/gemtag/gemtag.h @@ -0,0 +1,24 @@ +/* + * (C) 2006 by Frank Zirkelbach + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GEMTAG_H +#define _GEMTAG_H + +#define USB_VENDOR_GEMTAG 0x1394 +#define USB_DEVICE_X501 0x0501 + +#endif