Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ 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:

```sh
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.

### data

Data is stored in 'data'. In production it is also committed to git, but for
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"pos": {
"serial": {
"port": "/dev/ttyUSB0",
"port": "/dev/ttyKASSA",
"baudrate": 19200,
},
},
Expand Down
2 changes: 1 addition & 1 deletion config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ stickers:

pos:
serial:
port: /dev/ttyUSB0
port: /dev/ttyKASSA
baudrate: 19200

logging:
Expand Down
36 changes: 23 additions & 13 deletions tests/js/browser-smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,27 @@ function chromiumCommand() {
}

function runChromium(command, url) {
return spawnSync(command, [
"--headless",
"--disable-gpu",
"--disable-dev-shm-usage",
"--no-sandbox",
"--allow-file-access-from-files",
"--dump-dom",
"--virtual-time-budget=3000",
url,
], {
encoding: "utf8",
timeout: 20000,
});
const profile = fs.mkdtempSync(path.join(os.tmpdir(), "kassa-chromium-"));
try {
return spawnSync(command, [
`--user-data-dir=${profile}`,
"--no-first-run",
"--no-default-browser-check",
"--headless",
"--disable-gpu",
"--disable-dev-shm-usage",
"--no-sandbox",
"--allow-file-access-from-files",
"--dump-dom",
"--virtual-time-budget=3000",
url,
], {
encoding: "utf8",
timeout: 40000,
});
} finally {
fs.rmSync(profile, {recursive: true, force: true});
}
}

function skipIfChromiumSandboxed(t, result) {
Expand Down Expand Up @@ -103,6 +111,7 @@ test("kassa index boots in a real browser", (t) => {
fs.unlinkSync(fixturePath);
if(skipIfChromiumSandboxed(t, result)) return;

assert.ifError(result.error);
assert.equal(result.status, 0, result.stderr);
const match = result.stdout.match(/<pre id="smoke-result">([^<]+)<\/pre>/);
assert(match, result.stdout);
Expand Down Expand Up @@ -148,6 +157,7 @@ test("kassa frontend posts keyboard and button input in a browser", (t) => {
fs.unlinkSync(fixturePath);
if(skipIfChromiumSandboxed(t, result)) return;

assert.ifError(result.error);
assert.equal(result.status, 0, result.stderr);
const match = result.stdout.match(/<pre id="smoke-result">([^<]+)<\/pre>/);
assert(match, result.stdout);
Expand Down
1 change: 1 addition & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def test_load_config_uses_defaults_when_missing(tmp_path):
assert config["mqtt"]["host"] == "localhost"
assert config["stickers"]["printer"]["port"] == 9100
assert config["logging"]["level"] == "INFO"
assert config["pos"]["serial"]["port"] == "/dev/ttyKASSA"


def test_load_config_merges_yaml_with_defaults(tmp_path):
Expand Down
3 changes: 3 additions & 0 deletions udev/99-kassa.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Printer and cash drawer USB serial adapter (Prolific PL2303).
# This adapter has no unique serial number; use only one matching adapter.
SUBSYSTEM=="tty", KERNEL=="ttyUSB*", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="ttyKASSA", GROUP="dialout", MODE="0660"
Loading