Linux – PullMonkey Blog http://pullmonkey.com Fri, 27 Jul 2012 15:39:59 +0000 en-US hourly 1 https://wordpress.org/?v=5.6 Using Ruby to read from a MagTek USB Card Reader http://pullmonkey.com/2012/07/27/using-ruby-to-read-from-a-magtek-usb-card-reader/ Fri, 27 Jul 2012 15:39:59 +0000 http://pullmonkey.com/?p=57712 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.

]]>
Signature Pad in Linux http://pullmonkey.com/2012/07/26/signature-pad-in-linux/ Thu, 26 Jul 2012 16:57:56 +0000 http://pullmonkey.com/?p=57708 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).

]]>
Using HTTPI with Curb to do multipart file uploads with spnego http://pullmonkey.com/2012/07/25/using-httpi-with-curb-to-do-multipart-file-uploads-with-spnego/ http://pullmonkey.com/2012/07/25/using-httpi-with-curb-to-do-multipart-file-uploads-with-spnego/#comments Wed, 25 Jul 2012 22:25:11 +0000 http://pullmonkey.com/?p=57705 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.

]]>
http://pullmonkey.com/2012/07/25/using-httpi-with-curb-to-do-multipart-file-uploads-with-spnego/feed/ 2
Azilink is working again ! http://pullmonkey.com/2011/11/15/azilink-is-working-again/ http://pullmonkey.com/2011/11/15/azilink-is-working-again/#comments Tue, 15 Nov 2011 05:04:40 +0000 http://pullmonkey.com/?p=57655 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.

]]>
http://pullmonkey.com/2011/11/15/azilink-is-working-again/feed/ 1
Ubuntu – The disk drive for X is not ready yet or not present http://pullmonkey.com/2011/05/19/ubuntu-the-disk-drive-for-x-is-not-ready-yet-or-not-present/ http://pullmonkey.com/2011/05/19/ubuntu-the-disk-drive-for-x-is-not-ready-yet-or-not-present/#comments Thu, 19 May 2011 03:33:12 +0000 http://pullmonkey.com/?p=57603 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

]]>
http://pullmonkey.com/2011/05/19/ubuntu-the-disk-drive-for-x-is-not-ready-yet-or-not-present/feed/ 2
USB drive disconnecting and reconnecting randomly http://pullmonkey.com/2011/01/05/usb-drive-disconnecting-and-reconnecting-randomly/ Wed, 05 Jan 2011 00:27:26 +0000 http://pullmonkey.com/?p=57559 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
]]>