0

I have this magnetic card reader (generic). The manual is in Chinese, and I don't understand it. I have two Linux Machines, and if you plug it via USB, it powers on, and if you pass a card (with a text editor open), you get a code/string somewhat like this one:

1303031110012015¿999999999999999

Obviously, there is the card info somewhere (that's a cinema affiliation card), and I want to extract the info (like owner's name and other data for example) from that number. If I run lsusb, I get something like this:

Reader Unplugged

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 04f2:b293 Chicony Electronics Co., Ltd 
Bus 007 Device 003: ID 0cf3:3005 Atheros Communications, Inc. AR3011 Bluetooth

Reader Plugged

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 04f2:b293 Chicony Electronics Co., Ltd 
Bus 007 Device 003: ID 0cf3:3005 Atheros Communications, Inc. AR3011 Bluetooth
Bus 005 Device 005: ID 05fe:1010 Chic Technology Corp. Optical Wireless

I know some Python and Ruby, but don't know where to start. It would be great if some one can point me in the right direction. Can you? (It would be great to have a cross-platform driver for Windows, Linux and Mac.)

sawa
  • 165,429
  • 45
  • 277
  • 381
Jmlevick
  • 6,504
  • 9
  • 29
  • 35
  • When you plug it in do you also get a new entry in /dev/input/by-id/? – Keith Oct 24 '12 at 02:39
  • BTW, most cards simply have numbers (a record ID), and depend on an external database to get the other info you are asking for. – Keith Oct 24 '12 at 02:41
  • @Keith Yes, I get that entry in /dev/input/by-id/ And about the other comment, There have to be a ay to get the info, look for example this post: http://marker.to/bjAbN4 – Jmlevick Oct 24 '12 at 03:00
  • You show the USB device listing, not the list from that directory. If it is truly a HID device you have two choices. Use the low-level USB library and read the USB events, or use the "cooked" HID events from the input device. I can show you Python code to read the HID/input device. Or you can use pyusb if you want to use the USB level method. – Keith Oct 24 '12 at 03:08
  • Can you show me your code sample so I can decide? (I was reading about pyusb too :) ) Thank you. – Jmlevick Oct 24 '12 at 03:15
  • See HID code here: http://code.google.com/p/pycopia/source/browse/#svn%2Ftrunk%2Fcore%2Fpycopia%2FOS%2FLinux in the Input.py and event.py modules. – Keith Oct 24 '12 at 03:38
  • Thanks! I'll start reading and testing :) – Jmlevick Oct 24 '12 at 03:59

1 Answers1

0

You already have the driver, because the reader is a HID device pretending to be a keyboard. And the data on the card is exactly what you already posted. You're not going to extract a name or any other information from it; it's just a number — most likely an ID that's used to look up the other information in the shop's database, which you have no way of accessing.

hobbs
  • 223,387
  • 19
  • 210
  • 288
  • Disagree... I've been investigating and actually there are some ways to decompile the code into what I need, look for example: http://marker.to/bjAbN4 That's why I need the manual from this thing... I'll keep reading and also waiting, maybe someone has the right answer for the question. – Jmlevick Oct 24 '12 at 02:11