2.1 KiB
inventory
A demo inventory application for the Psion Workabout MX: scan UPC barcodes, and (Phase 2) keep stock counts in a database file, adding stock or consuming it by scanning.
Written in PLIB C, built with the TopSpeed compiler (tsc /m scan).
Phases
- Phase 1 (this commit): scan and validate. Reads barcodes from the scanner
and prints each one, flagging whether it is a valid UPC-A.
Modules:
upc(validation),bcode(scanner input),scan(the demo). - Phase 2 (next): inventory database. A DBF file keyed on UPC holding a
quantity and a name. Scan to add stock (increment, or create on first sight),
scan to consume by a quantity unit. Built on the SIBO
Dbf*API.
Build
tsc /m scan
Produces scan.img. scan.pr compiles upc.c, bcode.c and scan.c and
links them.
How the scanner is read
On the Workabout the barcode module decodes the label in hardware and sends the
result as an RS232 stream, so there is no special barcode driver call: the app
opens the serial port and reads it. The scanner is on the top internal slot,
which is port D, so the device is TTY:D (bcode.c).
The scan loop is asynchronous: it waits on the scanner and the keyboard at the same time, so a scan is processed immediately and Esc quits at any point.
Things to confirm on the device
Because this cannot be compiled or run off-device, these points are written to the SDK docs but may need adjusting once you build and test:
- Serial line settings.
bcodeOpenopensTTY:Dwith the default mode. If the scanner needs a specific baud/parity/framing, configure the channel withp_iow(chan, P_FSET, &config)(E_CONFIG,p_config.h) after opening. - Terminator.
BCODE_TERMinbcode.his set to CR (0x0D), the common case. Change it if your scanner suffixes LF or something else. - Esc key code.
KEY_ESCinscan.cis27; adjust if the console delivers a different code. CON:async read. Phase 1 reads single keystrokes asynchronously fromCON:; if that behaves differently on your unit, the keyboard handling inscan.cis where to look.