initial checkin of the gemtag support
authorhackbard <hackbard>
Sat, 25 Feb 2006 18:19:44 +0000 (18:19 +0000)
committerhackbard <hackbard>
Sat, 25 Feb 2006 18:19:44 +0000 (18:19 +0000)
gemtag/Makefile [new file with mode: 0644]
gemtag/gemtag.c [new file with mode: 0644]
gemtag/gemtag.h [new file with mode: 0644]

diff --git a/gemtag/Makefile b/gemtag/Makefile
new file mode 100644 (file)
index 0000000..c7866af
--- /dev/null
@@ -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 (file)
index 0000000..28538c7
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * (C) 2006 by Frank Zirkelbach <hackbard@hackdaworld.org>
+ *
+ *  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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <usb.h>
+#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;i<numconf;i++) {
+               numint=gemtag->config[i].bNumInterfaces;
+               printf("config %u [nr %u] has %u interfaces\n",
+                      i,gemtag->config[i].bConfigurationValue,
+                      numint);
+               for(j=0;j<numint;j++) {
+                       printf("config %u interface %u has %u altsettings\n",
+                              i,j,gemtag->config[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 (file)
index 0000000..6e01bd2
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * (C) 2006 by Frank Zirkelbach <hackbard@hackdaworld.org>
+ *
+ *  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