Monday, 15 January 2018

Linux Driver for Ultraship U2 Scales

We use MyWeigh Ultraship U2 postal scales in our warehouse. They have given excellent service, and this is in no small part due to the USB connectivity they offer.

As no drivers were available for Ubuntu Linux, we developed our own. We're happy to share our code here, but cannot provide full installation instructions.

CAUTION: We purchased a second set of Ultraship scales, but found the USB connection was fundamentally different to the scales we already had. Our driver only works with scales having a device signature of 04D9:E002.

Overview

We setup the scales with a UDEV rule, then use a PERL driver to read the scales and simulate keypresses using xautomation. We simply add the PERL driver as a start up application in Unity. There may be some issues if multiple users are logged in simultaneously, but this is not a scenario we needed to cater for.

The Driver


Pre-requisites

$ sudo apt-get install xautomation

/etc/udev/rules.d/90_ultraship.rules

SUBSYSTEM=="hidraw", DEVPATH=="*04D9:E002*", SYMLINK+="ultraship", MODE="0666"

/ultraship/driver.pl

#!/usr/bin/perl

use Time::HiRes qw(gettimeofday);
$t=gettimeofday;

$xte = `which xte`;
$xte =~ s/\n//g;
if (!$xte) { die "This script requires xautomation to run"; }

while () {
 if (open(my $scales,'<','/dev/ultraship')) {
  while (read $scales,$rawdata,8) {
   $time_gap=gettimeofday-$t;
   if ($time_gap>0.3) { # prevents double send
    if ($rawdata=~'^([+|-])(\s+)(\d+)$') {
     $weight=$3.$g;
    } else {
     $weight="SET SCALE TO GRAMS";
    }
    system($xte.' "str '.$weight.'"');
    system($xte.' "key Return"'); 
   }
   $t=gettimeofday;
  }
 } else {
  sleep 3;
 }
 close $scales;
}

exit;

start up command 

perl /ultraship/driver.pl

alternative start up command

perl /ultraship/driver.pl -g

Tuesday, 13 May 2014

Burn Baby Burn

Although we had no specific concerns, we recently decided to beef up our backup regime by burning a regular offline backup of our critical business data.

It occurred to us that we only had one DVD Writer in the business, and that was on a development server, so we needed to get some new hardware.

USB DVD Writer


As seasoned Linux users will be aware, although many peripheral devices are not advertised as being Linux compatible, many do work without issue. However, it usually pays to do a bit of research before parting with hard-earned cash.

Our choice of USB DVD writer was the LiteOn EUAU108-11 and although it's not the cheapest USB DVD writer on the market, at £25 delivered it's still at a non bank-breaking price point. Our purchasing decision was influenced by LiteOn's claim of Liunx compatibility as well as the sleek appearance of the unit. I mean, who doesn't like a bit of sleek?

Ok, I'll cut to the chase. Does it cut the mustard? And is it really Linux compatible? In our experience, yes and yes. We've been using it for four months with a standard Ubuntu 13.10 installation, and so far it's not missed a beat, not even the slightest niggle. It's true that the USB connection is ridiculously short, but we had a small extension knocking around the office, so no problems there.

Hands Off


It's important to consider the security of all business data. We use encrypted drive partitions to protect our day to day working data, but once data is burned onto DVD media this clearly doesn't help. Although the discs won't be left lying around on desks we did decide to do a simple encryption of the backup data before burning.

As is often the case in the Linux world, it seemed that the easiest and most effective option was to open up the command prompt.

Encrypting

$ openssl aes-256-cbc -salt -in backup-2014-05-13.tar.gz -out backup-2014-05-13.tar.gz.encrypted
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:

Decrypting

$ openssl aes-256-cbc -d -salt -in backup-2014-05-13.tar.gz.encrypted -out backup-2014-05-13.tar.gz.unencrypted

Automation


Although we find burning backup DVDs to be quite a simple process, it is definately a manual process. I can see that there may be some desire to automate it in the future. As far as we can see, there's no networked DVD writers available, but maybe we can cobble one together? How hard could that possibly be? Ahem.