Fujitsu Lifebook B3020D Touchscreen and Linux

(I actually did this at the tail end of 2009, then I revised the python script it in 2010. I've been thinking of attacking the problem with un-smooth lines when the cursor is dragged...)

A friend gave me one of these Fujitsu B3020D Lifebooks. It's quite beat up. No, really, the screen is cracked in the lower left corner and a failing hard drive or bad RAM requires that I reboot the thing periodically. It's currently running Windows 7 and Skype with a Zoom adapter so I can plug cordless telephone bases into it. But before that, it was running Ubuntu. It ran Ubuntu for a good week to a week and a half. The touchscreen didn't work on it, and the screen was cracked even then, but it wasn't a bad little system. The battery life was good, the wireless worked without having to fight with it, and I thought it would be fun to reverse engineer the touchscreen and write some kind of mouse driver.

It didn't take me long to see that the touchscreen is actually exposed to the system as a serial device. That's damn cool. If you just start cating out the serial ports at the console and then touching the screen, you'll eventually see it spew a bunch of numbers. That's how I figured out which serial port it was using. After that you can pretty much tell what the values mean just by trial and error. There's a byte that indicates the type of event (push/release/drag) and then a series of bytes indicating the x and y coordinates. I suggest piping the output of cat through xxd in order to see the byte values in hex. For example: cat /dev/ttyS2 | xxd -

I don't recall from memory what the different byte values were, but you can kind of tell from the python script I wrote for it. This script reads the touch screen and will tell X11 to move the mouse around the screen and click the left mouse button in pretty much the way you would expect it. However, if you run the gimp or some other paint program, you'll notice that touching and dragging results in a rather imperfect line. Instead of nice diagonal lines, you get these crazy little semi-circles. If I ever get a second system set up to run my Skype phone (or can borrow another one of these laptops,) I'll revisit the script and see if I can fix it, but otherwise it works okay.

Here's the script via pastebin: touchmy.py

SEN-08634 Magnetic Card Reader/Writer

The SEN-08634 Magnetic Card Reader/Writer is exactly what it sounds like: it reads and writes to magnetic strip cards. SparkFun has them.

This device will connect to your host as a serial device (/dev/ttyUSB0, for example) but if you try to cat it out, it will immediately return. The damn thing doesn't buffer! Well, okay, that's not true, it will buffer, but it throws the buffer away after a very short period of time. So, if you wanted to use the device with some clever bash scripting, you would have to do something like while [ "1" ] ; do echo -n `cat /dev/ttyUSB0` ; done

I didn't actually try that command while I had the device, it didn't occur to me until just now.

Anyway, I borrowed one of these and wrote a python script that can use it. It reads high coercivity cards and reads and writes low coercivity cards, but that's about the only thing that works. For some reason, all the commands that the documentation claims should work don't return anything. My script is heavily commented and I don't recommend simply running it unless you're ready to lose the data on whatever card you swipe through it. The main body of the script will attempt to write hello world to track 1 and then a couple strings of numbers to track 2 and 3. It will not backup what's on the card before writing. That didn't occur to me either. I don't have the device any more, so I'm not going to update the script.

Here's the script via pastebin: magstripe.py.
If you want to see documentation for it, you can do something like this: doxygen -g magstrip.doxy ; doxygen magstrip.doxy