Added healthchecks, and maybe got a bit lost

This commit is contained in:
2026-09-22 16:21:50 +01:00
parent 009609da93
commit 82972c9665
11 changed files with 241 additions and 84 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ func findDisplayPort() (*communication.WalkieTalkie, error) {
select {
case err = <-probeResult:
// Probe completed normally (could be success or error)
case <-time.After(2 * time.Second):
case <-time.After(1000 * time.Millisecond):
// Hard timeout reached
err = fmt.Errorf("probe completely hung/timed out: %s", port)
}
+1 -33
View File
@@ -11,7 +11,6 @@ import (
"sync"
"time"
"esdi/constants"
helper "esdi/helpers"
"esdi/peripheral"
"esdi/peripheral/communication"
@@ -34,6 +33,7 @@ const (
updateWindowCMDID types.Command = 6 // Change this to a move cmd instead
sendDataCMDID types.Command = 7
newLayoutCMDID types.Command = 8
healthCheckCMDID types.Command = 9
)
const (
@@ -149,9 +149,6 @@ func (cds *CDashDisplay) Close() error {
return nil
}
func (d *CDashDisplay) SendCommand() {
}
func (d *CDashDisplay) RegisterFieldMapping(fieldID telemetry.FieldID, winID int16) {
d.fieldToWindows[fieldID] = append(d.fieldToWindows[fieldID], winID)
}
@@ -438,32 +435,3 @@ func (d *CDashDisplay) SendData(data *telemetry.TelemetryData) error {
return nil
}
func (cds *CDashDisplay) setupForIracing() error {
err := cds.LoadLayout("layout.yaml")
if err != nil {
return err
}
return nil
}
func (cds *CDashDisplay) setupForBeamNG() error {
err := cds.LoadLayout("beamng.yaml")
if err != nil {
return err
}
return nil
}
func (cds *CDashDisplay) Setup(provider string) error {
switch provider {
case constants.IRacingProviderName:
return cds.setupForIracing()
case constants.BeamNGProviderName:
return cds.setupForBeamNG()
default:
return fmt.Errorf("unknown provider: %s", provider)
}
}
+12
View File
@@ -1,6 +1,7 @@
package cdashdisplay
import (
"esdi/peripheral/communication/packets"
"esdi/peripheral/devices"
"esdi/telemetry"
)
@@ -26,3 +27,14 @@ func (cds *CDashDisplay) RequiredFields() []telemetry.FieldID {
return fields
}
func (cds *CDashDisplay) HealthCheck() bool {
// Send the command
var health packets.HealthCheck
err := cds.WT.SendCommand(healthCheckCMDID, []byte{0x01, 0x02, 0x03, 0x04}, &health)
if err != nil {
return false
}
return true
}
+36
View File
@@ -0,0 +1,36 @@
package cdashdisplay
import (
"fmt"
"esdi/constants"
)
func (cds *CDashDisplay) setupForIracing() error {
err := cds.LoadLayout("layout.yaml")
if err != nil {
return err
}
return nil
}
func (cds *CDashDisplay) setupForBeamNG() error {
err := cds.LoadLayout("beamng.yaml")
if err != nil {
return err
}
return nil
}
func (cds *CDashDisplay) Setup(provider string) error {
switch provider {
case constants.IRacingProviderName:
return cds.setupForIracing()
case constants.BeamNGProviderName:
return cds.setupForBeamNG()
default:
return fmt.Errorf("unknown provider: %s", provider)
}
}
+4
View File
@@ -58,3 +58,7 @@ func (uid *UIDevice) RequiredFields() []telemetry.FieldID {
telemetry.RPM,
}
}
func (uid *UIDevice) HealthCheck() bool {
return true
}