fix: cache relay-board drivers so Denkovi/USB-serial boards stay connected

The station-control code rebuilt a fresh driver on every status poll and every
relay set. Stateful boards (Denkovi FTDI D2XX, USB-serial) hold an OS handle only
one opener can own, so the first poll opened the board and leaked the handle, and
every poll after failed with 'device in use' — the relays greyed out a second
after Save and auto-control never switched. Drivers are now cached per device and
reused, closed on config change. Adds a Test-connection button + detect feedback
in the device editor (reported by VK4MA).
This commit is contained in:
2026-07-21 09:31:08 +02:00
parent 615df0dc10
commit 880ecdbbb5
10 changed files with 174 additions and 14 deletions
+13
View File
@@ -121,6 +121,19 @@ func (d *denkovi) Set(ctx context.Context, relay int, on bool) error {
return d.writeLocked()
}
// Close releases the FTDI handle so the board can be reopened later (only one
// handle may hold a D2XX device at a time).
func (d *denkovi) Close() error {
d.mu.Lock()
defer d.mu.Unlock()
if d.opened {
procClose.Call(d.h)
d.opened = false
d.h = 0
}
return nil
}
func (d *denkovi) Status(ctx context.Context) ([]bool, error) {
d.mu.Lock()
defer d.mu.Unlock()