PullMonkey Blog


27 Jul

Using Ruby to read from a MagTek USB Card Reader


Been playing around with a lot of USB devices lately, to get them to play nicely with some of our touch screen Rails apps.
One of the devices is a card reader - specifically a MagTek reader, and the same code works for the ELO reader.

I've tried a billion different ways to ensure we're reading in all the data. At first, I was just asking the usb stream to present me with a certain number of characters, b/c that's how all the examples do it.
But we're using a lot of different cards with the readers, so that didn't work too well. So now I just read one character at a time until we find the new line.
Here's the code to find the device, open it, close it and read from it, all whilst finding and converting the data as required.

So using this code, we take the swiped data and send it to our server for storage.


Comments Off on Using Ruby to read from a MagTek USB Card Reader Filed under: development, Linux, projects, ruby, tutorials Tags: , , , , , ,
26 Jul

Signature Pad in Linux


I'm using the topaz model T L462 HSB. It's nice now that it works. But what a PITA to get it going. The biggest problem with the device is the documentation. There is no low level documentation explaining the representation of the bytes coming in over usb. So you are stuck using their libraries which expose some poorly explained API.

Anyway, like I said, great when it works. So I'm working in linux which basically leaves me having to use java libs and a shared object file.

Here's my code:

It sits and waits until the sig pad gets some points on it. Once we have points it waits for a lapse in time where there is no change in the number of points.
Once we've decided that we have captured a signature, we store it to a file.
Then we shell out to a ruby script - see the httpi and curb article - which is how I get the file to our rails server for display and verification from the user.

Now, you'll need a few files. Most of which can be found in the java zip download from the vendor site.
From that zip, you should grab the following:
SigPlus2_60.jar
RXTXcomm.jar
libSigUsb.so - if you need the 64 bit version, go here - http://www.topazsystems.com/Software/libSigUsb7242012.zip

Then I just used eclipse to set everything up and build. Works well so far.
The only thing you may need to change is the model (I have mine set to SignatureGem1X5) and com port (I have mine set to HID1).


Comments Off on Signature Pad in Linux Filed under: development, Linux, projects, tutorials Tags: , , , ,
25 Jul

Using HTTPI with Curb to do multipart file uploads with spnego


It took a while to find a library that handled spnego requests, as opposed to shelling out to a curl --negotiate. Found httpi to work well with the curb adapter.
The problem was that the documentation didn't really explain how to do file uploads withing the httpi request block.
Wasn't too much of a big deal, but I thought it may save someone else some time.


15 Nov

Azilink is working again !


If the apk is not available for download yet, you can build it yourself with the fix from here.
Step 1 - Grab the source from svn -

svn checkout http://azilink.googlecode.com/svn/trunk/ azilink-read-only

Step 2 - Update the UdpDriver.java per this azilink issue.

Step 3 - Build and install the apk

# this will give you a build.xml file
android update project --target 2 --path /path/to/your/azilinkdownload/
# after plugging in your device and from your azilink project directory
ant debug install

Step 4 - Install Open VPN

sudo apt-get install openvpn

Step 5 - Grab the azilnk.ovpn file from the downloads section.
Place somewhere you won't lose it.

Step 6 - Copy this resolv.azilink file to the same place as the azilink.ovpn

Step 7 - Copy this azilink script to somewhere you can get to it

Step 8 - Start azilink on your phone.

Step 9 - Run the script from step 7.

That's it.


19 May

Ubuntu – The disk drive for X is not ready yet or not present


After an Ubuntu install go wrong my laptop started coming up with this error message:
The disk drive for X is not ready yet or not present
In my case, the laptop was having trouble with /dev/sda1, my root partition.
The Solution:
The error message above is met with two solutions, press S to skip or M to do a manual install. Press "M" for manual install.
Once you are the command prompt, your drive will have been mounted as read-only, change that like this:

mount /dev/sda1 -o rw,remount

Now that the drive is in read-write again (test with a simple touch /tmp/test), continue the installation with this:

dpkg --configure -a


05 Jan

USB drive disconnecting and reconnecting randomly


It was very strange, I got a new 2 TB external USB drive for Christmas and I noticed a number of windows (nautilus windows) opening up throughout the night.  So I would wake up to find 20 - 30 windows opened to the media mount directory (/media).  Overtime and watching the logs, I noticed that the new USB drive was disconnecting itself and then reconnecting.  As it would reconnect and mount, the new mount point /media/<some long character string> would pop open in a  nautilus window.  When the drive would eventually disconnect, the opened nautilus window would no longer have access to the data and would display contents from one directory up (/media).  After a couple days I finally found the answer and tried it and it worked as advertised.

For those having the same problem, this is where I found the solution you see below.

$ sudo sdparm --clear STANDBY -6 /dev/sdb
# note that your device could be something else, for example - /dev/sd<something>

And if you get an error, something like this:

change_mode_page: failed fetching page: Power condition

Then you should be able to use hdparm instead, like this:

sudo hdparm -S 0 /dev/sdb

Comments Off on USB drive disconnecting and reconnecting randomly Filed under: biking, Home, Linux, projects, tutorials Tags: , , , , , , , , ,