Home
Name Modified Size InfoDownloads / Week
test.tcl 2009-11-03 825 Bytes
test.pl 2009-11-03 476 Bytes
README 2009-11-02 3.2 kB
Totals: 3 Items   4.5 kB 0
== HID Scale Driver ==
Date: 2009-11-01

Hi, if your looking for a driver or test programs for the UltraShipper U-2 from myweigh.com that works with Unix or Linux, you've come to the right place. 

Rather than explain the workings of the unit, you have three programs to choose from. (I'll explain it later, and in the programs.) Two programs work under TCL/TK, the third under Perl.

The three (3) programs are:

test.pl  - test the port for the scale in perl
test.tcl - test the port for the scale in tcl
t.tcl	- an example program that uses the include driver

hidscale.tcl - the Driver

=== Quick Start ===
The first two programs test the port given at the command line. 

Examples:

# sudo -E test.pl /dev/hidraw0
# sudo -E test.tcl /dev/hidraw0

Rules:
1. Must give port at command line.
2. Port must exist.
3. Port must be readable.

After starting the programm you will be prompted to push the "SEND" button on the scale. Pushing the "SEND" button fills the port buffer, which in turn is read (and displayed) by the program. Vala, done - you have the scale working and you now know the port which it is connnected to.

=== Some Notes ===

About the scale: I purchased the scale on ebay. After it arrived the included User's Manual told me of the website. There is no useful programming information available - either in the manual or at the website. 

http://www.myweigh.com/ultraship_u2_manual

Somehow, I did get information that the buffer was 8 bytes wide. This may have come from the Linux ``lsusb'' program. In any case, it worked. As such, the port test programs and the driver assume 8 bytes (or 8 octals) will be available to read.

In addition, because the scale is a USB device it's actual port may change if it is disconnected. The driver makes accomidation for this.

=== About the Driver ===

The inner workings of the driver are for the most part mundane. There is only one procedure to call named "USBHIDScaleSetup". The procedure requires only one parameter, a list of ports to use - even if that list has just one value,or port. Every port should list the full path - no root path is assumed. The list of ports is to facilitate ease of use. 

Once a port is successfully opened, it sets the global variable "HIDDevice" to the port it found,  and uses a standard "wait for read event" callback, then returns immediately. If it fails to open any of the ports in the list, it returns the string "no".

Once data is ready, the callback procedure stores the value as an ASCII string in the variable "USBHIDValue". 

By default, the next action is to "set" (overwrite any value of) the current "entry" widget. Then, by default, it generates a 'Tab' character event. Both actions can be changed. In addition, in the future the driver will be able to "insert" or "append", rather than just "set".

To short-circuit the aforementioned action, set the global variable "SetWidget" to zero (0). In this case, you will have to get results from the variable "USBHIDValue".

To change the generated character, set the global variable "PostKeyAction" to the desired key (Hint: See keysyms). 

To short-circuit the character event, that is don't generate any event, set "PostKeyAction" to "none", or set "SetPostKey" to zero (0).


Source: README, updated 2009-11-02