Skip to content
Hack42Public

About

Hack42 Bank Interface

Resources

Stars

12 stars

Watchers

1 watching

Forks

Latest commit

 

History

246 Commits

Folders and files

Repository files navigation

hackbank

The hackbank consist of a php front-end that communicates with a python back-end over mqtt.

Development set-up

You need python, paho-mqtt-client and apache+php.

To install the python dependencies, run 'pip install -r requirements.txt'.

Printer and cash drawer

The POS serial port defaults to /dev/ttyKASSA. Install the udev rule on the machine connected to the Prolific PL2303 USB serial adapter:

sudo install -m 0644 udev/99-kassa.rules /etc/udev/rules.d/99-kassa.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --action=add --subsystem-match=tty
sudo udevadm settle
ls -l /dev/ttyKASSA

Give the backend user membership of dialout and restart the backend. Set pos.serial.port: /dev/ttyKASSA in an existing config.yaml; local overrides remain supported. The adapter has no unique serial number, so this rule assumes only one 067b:2303 adapter is connected. With several identical adapters, narrow the rule to the appropriate USB port before installing it.

Store the receipt logo in the Epson

Receipts use NV logo 1 already stored in the printer (FS p 1 3, the existing LOGO constant). Upload a replacement once with:

# Stop the kassa backend before uploading.
.venv/bin/python load_printer_logo.py images/hack42.png --write --test-print

The script reads pos.serial from config.yaml (default /dev/ttyKASSA, 19200 baud). Use --config, --port, or --baudrate to override it. Without --write it only prepares the image; --output logo.bin exports the FS q command for offline inspection. --test-print prints the stored logo after uploading. Restart the backend afterwards.

The default stored width is 192 dots; LOGO prints at twice the stored width and height, so the printed width is at most 384 dots. --width changes the stored width. Images retain their aspect ratio; transparent pixels and padding become white. Only near-white pixels (all RGB channels at least 245) remain white; every other color becomes solid black, without dithering. Stored logos persist after power-off; receipt generation does not upload the image again.

Epson's FS q command replaces all existing NV logos/graphics and resets the printer. Run the script only when changing the logo, with the backend stopped, and keep the printer powered on until it finishes. A successful serial write cannot confirm that the printer accepted the logo; verify the test print. The printer must support the same legacy NV commands already used for the receipt header.

data

Data is stored in 'data'. In production it is also committed to git, but for local development it's probably better to use fake data and keep it out of git. To get started, copy the files from fakedata.

docker-compose

If you don't want to install apache and an mqtt server yourself you can use docker-compose for local development. Simply running docker-compose up will start an mqtt server on port 1883, an apache+php server serving the files in 'www' on port 4242, and hook them up to each other. All that's left is to run kassa.py and point your browser at http://localhost:4242

About

Hack42 Bank Interface

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages