Saturday, December 3, 2016

Reading Magnetic Strips with Square Reader


To start off, I want to admit that I haven't gotten this to work just yet. However, before I get into what I found, I wanted to explain my goals and what I have discovered so far.
My hope was to use a Square card reader in conjunction with my macbook and some simple software to read magnetic strips on the various cards in my wallet. No nefarious motives, just for fun and my own edification. I was able to write a Java program that would interface with the macbook's default audio-in data line, but the macbook has some mechanism that handles which device you get to read from at that interface address. Basically, if it doesn't recognize the device (Square card reader in my case) it thinks you want audio from the internal microphone and so the mixer sends you data from the microphone. Now, if you plug in a headset, you get data from the headset, but at the same device address. It was at this point I realized I would have to do a little more digging on how to beat the mac at its trickery.
Turns out the macbook wasn't at fault at all. After some careful reading, I discovered that the Java APIs for getting audio are some what limited. This may not be the case for all environments, it is just what I have found(through StackOverflow and the like) to be the case for macs and the Java audio APIs.
Don't lose hope just yet! Someone has actually already accomplished this task with a nice graphical application named MagRead. Check it out here: MagRead
If I end up continuing this project, it looks like I'll need to go with a programming language less restrictive than Java. For now, my source for reading from the default audio device is up on my github at: Audio Reader Example
*Disclaimer: I do not own this image. The image was taken from www.cnet.com. If you own this image and do not want me using it, let me know and I can replace it.

No comments:

Post a Comment