-
Notifications
You must be signed in to change notification settings - Fork 0
Serial watchdog false positives when idle - implement keepalive #59
Description
Problem
When the phone is idle (no keypad, coins, or hook events), neither the Pi nor the Arduino sends anything on the serial link. The serial watchdog in millennium_client_check_serial only counted reads as activity, so after 30 seconds it falsely marked the link dead and triggered a reconnect. Reconnect sends 'f' to re-init the coin validator, which spins the motor.
We fixed part of this in PR #58 by:
- Treating writes as activity
- Increasing the watchdog timeout to 300 seconds
But nothing writes to the serial while idle either - display and coin validator commands only happen on user interaction. So after 5 minutes of true inactivity, the watchdog can still false-positive.
Proposed solution
Implement a periodic keepalive - a low-overhead message exchanged between Pi and Arduino (e.g. every 30–60 seconds) that:
- Resets the watchdog's activity timer
- Confirms the link is alive
- Does not trigger the coin validator motor or other side effects
Options to explore:
- Pi sends a harmless command (e.g. display no-op or a dedicated keepalive byte); Arduino sends a simple ack
- Arduino-initiated keepalive (requires display firmware change)
- A minimal polling protocol that both sides understand
Current workaround
The watchdog is disabled until this is resolved (see SERIAL_WATCHDOG_ENABLED in millennium_sdk.h).