I've spent the past 2 days attempting to get some form of communication going with my Magtek Mini swipe reader. I've skimmed over the entire mailing list archives to see if I could find some answers as well as dozen of articles on the internet.
Out of all the articles that relate to what I'm attempting to do would have to be "Development of a User-Space Application for an HID Device, Using libhid <http://www.linuxjournal.com/article/8145>" over at Linux Journal. The only real difference is that he is using a bill validator. So now let me introduce the details... USB HID Swipe Reader, Technical Reference Manual<http://www.magtek.com/documentation/public/99875191-11.01.pdf>[PDF] Here is my Python script that I've been hacking around with to at least get something out of it. Which has seemed to have been unsuccessful with just about everything I tried, the only exception being interrupt_read which does at least clear out the buffer of the swipe reader after a card has been swiped. Sorry if its really hackish I've been frustrated and decided to take the brute force route. swipe_reader.py <http://privatepaste.com/7805xSQbGi> -------------------------------------------------- #!/usr/bin/env python import sys import struct #~ from libhid import * from libhid.hidwrap import * card_encode = {0: 'ISO/ABA', 1: 'AAMVA', 2: 'CADL', 3: 'Blank', 4: 'Other', 5: 'Undetermined', 6: 'None'} def main(): set_debug(HID_DEBUG_ALL) set_debug_stream(sys.stderr) set_usb_debug(0) hid = Interface(vendor_id=0x0801, product_id=0x0002) #~ hid.write_identification(sys.stdout) #~ hid.dump_tree(sys.stdout) for item1 in xrange(0x00, 0xff): for item2 in xrange(0x00, 0xff): try: hid.set_output_report([0xff000000 + item1, 0xff000000 + item2], '\x01\x02\x10\x00\x02') print item1, item2 except: pass #~ hid.set_output_report([0xff000001, 0xff000020], '\x01\x02\x10\x00\x02') #~ hid.interrupt_read(0xff000001, 5) #~ hid.get_input_report([0xff000001, 0xff000032], 512) #~ hid.get_feature_report([0xff000001, 0xff000032], 512) #~ hid.set_feature_report([0xff000001, 0xff000001], '\x02') #~ hid.interrupt_read(0xff000001, 512) #~ for item in xrange(256): #~ for item2 in xrange(256): #~ try: #~ hid.set_output_report([item, item2], chr(0x02)) #~ print '**************', item, item2 #~ hid.get_feature_report([item], 512) #~ print '**************', item, item2 #~ except: #~ pass cleanup() if __name__ == '__main__': main() -------------------------------------------------- Here are a lsusb -vvv <http://privatepaste.com/280Qc0PbZT> and dump_tree<http://privatepaste.com/f61ycUKlN6> dumps of the device lsusb -vvv <http://privatepaste.com/280Qc0PbZT> -------------------------------------------------- Bus 008 Device 006: ID 0801:0002 Mag-Tek Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0801 Mag-Tek idProduct 0x0002 bcdDevice 1.00 iManufacturer 1 Mag-Tek iProduct 2 USB Swipe Reader iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 34 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Devices bInterfaceSubClass 0 No Subclass bInterfaceProtocol 0 None iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.00 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 61 Report Descriptor: (length is 61) Item(Global): Usage Page, data= [ 0x00 0xff ] 65280 (null) Item(Local ): Usage, data= [ 0x01 ] 1 (null) Item(Main ): Collection, data= [ 0x01 ] 1 Application Item(Global): Logical Minimum, data= [ 0x00 ] 0 Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255 Item(Global): Report Size, data= [ 0x08 ] 8 Item(Local ): Usage, data= [ 0x20 ] 32 (null) Item(Local ): Usage, data= [ 0x21 ] 33 (null) Item(Local ): Usage, data= [ 0x22 ] 34 (null) Item(Local ): Usage, data= [ 0x28 ] 40 (null) Item(Local ): Usage, data= [ 0x29 ] 41 (null) Item(Local ): Usage, data= [ 0x2a ] 42 (null) Item(Local ): Usage, data= [ 0x38 ] 56 (null) Item(Global): Report Count, data= [ 0x07 ] 7 Item(Main ): Input, data= [ 0x02 ] 2 Data Variable Absolute No_Wrap Linear Preferred_State No_Null_Position Non_Volatile Bitfield Item(Local ): Usage, data= [ 0x30 ] 48 (null) Item(Global): Report Count, data= [ 0x6e ] 110 Item(Main ): Input, data= [ 0x02 0x01 ] 258 Data Variable Absolute No_Wrap Linear Preferred_State No_Null_Position Non_Volatile Buffered Bytes Item(Local ): Usage, data= [ 0x31 ] 49 (null) Item(Global): Report Count, data= [ 0x6e ] 110 Item(Main ): Input, data= [ 0x02 0x01 ] 258 Data Variable Absolute No_Wrap Linear Preferred_State No_Null_Position Non_Volatile Buffered Bytes Item(Local ): Usage, data= [ 0x32 ] 50 (null) Item(Global): Report Count, data= [ 0x6e ] 110 Item(Main ): Input, data= [ 0x02 0x01 ] 258 Data Variable Absolute No_Wrap Linear Preferred_State No_Null_Position Non_Volatile Buffered Bytes Item(Local ): Usage, data= [ 0x20 ] 32 (null) Item(Global): Report Count, data= [ 0x18 ] 24 Item(Main ): Feature, data= [ 0x02 0x01 ] 258 Data Variable Absolute No_Wrap Linear Preferred_State No_Null_Position Non_Volatile Buffered Bytes Item(Main ): End Collection, data=none Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Device Status: 0x0000 (Bus Powered) -------------------------------------------------- _______________________________________________ libhid-discuss mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss

