Saturday, March 13, 2010

Access your firefox settings from everywhere

Do you use FireFox as your webbrowser and use it on different computers ?
Then probably you also have the problem that the history, booksmarks and saved passwords are not the same on all systems.

Since a few month there is a reliable solutions to this problem:

Mozilla Weave (Also available directly via Add-On page)

It's a firefox add on which keeps your settings in sync between as many systems as you want.

Just install the add on and then create a Weave account and all your settings are synched to the mozilla weave server. (Don't worry, privacy is granted and data is encrypted, or, if you are paranoid, you can even install your own weave server)

On the second system, just install the add on and enter your credentials and then select if you wish to merge or replace the settings from teh server.

That's it. I have been using it since version 0.5 and since version 0.9 it's realy stable and very usefull.
Actully I sync 4 Installations with weave:
1. The computer at work
2. The laptop at home running ubuntu
3. The same laptop at home running (once a month) Windows 7
4. The Desktop at home (most of the time used by my children)

And weave just works as it should.

Tuesday, March 9, 2010

Linux and epson DM-D110 Display

In a project we had to switch over from a Windows XP based environment to a Linux based Pos system.

All components did work just fine (almost out of the box).
The main problem was the LineDisplay used to display the information to the clients.

It is a Epson DM-D110 with USB interface.
There is no linux driver available for that device from epson :(

So the lsusb command did show this:

Bus 003 Device 003: ID 1208:0780

Ok, no driver loaded for that usb device. I did google arround, but did only find a reference in the openbravo project, about using the usbserial module for that device.
We did some tests, but where not able to get it working.

After some more googling and looking at the windows drivers we did find out, that the chipset was in fact a ftdi with customized vendor and device id.

So after some trial and error we got it working by loading the ftdi kernel module for that device.

modprobe ftdi_sio vendor=0x1208 product=0x0780

This did create a /dev/ttyUSB0 which we then could use to communicate with the device.
To automate the module loading on plug events, just create a new file in /etc/udev/rules.d

File: 50-udev-default.rules
SYSFS{idProduct}=="0780", SYSFS{idVendor}=="1208", RUN+="/sbin/modprobe -q ftdi_sio product=0x0780 vendor=0x1208"


This website has some more info on this:

http://www-user.tu-chemnitz.de/~sontag/sprog.html

For a solutions also working with 3.12 and newer kernels, please read on here.

Tuesday, March 2, 2010

Storing binary stuff in database with tomcat

When storing binary data in a database, usually you do the following:

PreparedStatement pStmt= conn.prepareStatement("insert into FileData (FileData, BinData) values (?,?)");
pStmt.setString(1, fileDataID);
pStmt.setBinaryStream(2, fInfo.getInputStream(), fInfo.getSize());
pStmt.executeUpdate();


That works fine, but sometimes you can get this error when using it
with tomcat connection pooling:


java.lang.AbstractMethodError: org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V


The reason for this is, that you passed the last parameter as a long, instead of a int.

This is the fix for it:
PreparedStatement pStmt= conn.prepareStatement("insert into FileData (FileData, BinData) values (?,?)");
pStmt.setString(1, fileDataID);
pStmt.setBinaryStream(2, fInfo.getInputStream(), (int)fInfo.getSize());
pStmt.executeUpdate();


Took half a day to figure out the problem.