diff --git a/README.md b/README.md index 9b6f4ce..fcb17aa 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config.py b/config.py index 8cb4909..d1ddf43 100644 --- a/config.py +++ b/config.py @@ -29,7 +29,7 @@ }, "pos": { "serial": { - "port": "/dev/ttyUSB0", + "port": "/dev/ttyKASSA", "baudrate": 19200, }, }, diff --git a/config.yaml.example b/config.yaml.example index 4be949e..3601400 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -23,7 +23,7 @@ stickers: pos: serial: - port: /dev/ttyUSB0 + port: /dev/ttyKASSA baudrate: 19200 logging: diff --git a/tests/js/browser-smoke.test.js b/tests/js/browser-smoke.test.js index bc24b04..81318da 100644 --- a/tests/js/browser-smoke.test.js +++ b/tests/js/browser-smoke.test.js @@ -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) { @@ -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>/);
assert(match, result.stdout);
@@ -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>/);
assert(match, result.stdout);
diff --git a/tests/test_config.py b/tests/test_config.py
index fec84b7..64d47ab 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -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):
diff --git a/udev/99-kassa.rules b/udev/99-kassa.rules
new file mode 100644
index 0000000..87f0aa3
--- /dev/null
+++ b/udev/99-kassa.rules
@@ -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"