package tester import ( "errors" "time" ) // ErrNotConnected is returned by Read() when Connect() has not been called. var ErrNotConnected = errors.New("tester: not connected — call Connect() first") // CableType identifies the physical cable standard being tested. type CableType int const ( CableTypeUSB CableType = iota CableTypeDP CableTypeHDMI ) // TestResult captures all measurements from a single cable test run. type TestResult struct { CableType CableType USBVersion string DPVersion string HDMIVersion string SpeedGbps float64 MaxWatts int PinContinuity bool HasEMarker bool ResistanceOhm float64 } // LiveReading is a single sample from a streaming power/protocol meter (e.g. FNB58). type LiveReading struct { Voltage float64 CurrentAmps float64 PowerWatts float64 PDProtocol string Timestamp time.Time } // TesterDriver is the common interface for all discrete cable testers. // Connect must be called before Read. // Disconnect is idempotent. type TesterDriver interface { Connect() error Read() (TestResult, error) Disconnect() error } // StreamingTesterDriver extends TesterDriver for devices that continuously // emit live power/protocol readings (e.g. FNIRSI FNB58). // Stream() returns a read-only channel that emits LiveReading values and is // closed when the stream ends or Disconnect() is called. // Calling Stream() before Connect() returns a pre-closed channel. type StreamingTesterDriver interface { TesterDriver Stream() <-chan LiveReading }