Dispenser re-initialization after errors #29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
After a dispense error,
PuloonDispenser.close()is called which setsinitialized = falseand closes the serial port. But nothing ever re-initializes the dispenser. The next dispense attempt will fail because the serial port is closed.In brain.js (
lib/brain.js:4072-4087), the catch handler checks!this.billDispenser.initializedand re-initializes after a 200ms delay:Current behavior
this.close()→initialized = false, serial port closeddispenser.dispense()on closed port → crash or silent failureRequired behavior
After a dispense error, the dispenser must be re-initialized before the next attempt. Options:
Option A (lazy re-init): Check
initializedbefore eachdispenseCash()call inhal.ts. If not initialized, re-init with the stored config.Option B (eager re-init): Re-initialize immediately after error with a delay (matching brain.js pattern).
Option A is simpler and matches how brain.js works (the re-init happens at the next dispense, not immediately).
Implementation
In
hal.ts:dispenseCash(), before callingdispenser.dispense():This requires
PuloonDispenser.init()to allow re-initialization (resetinitializingflag afterclose()).Impact
Blocker for hardware testing. A single dispense error permanently disables cash-out until app restart.