backend_linux.go 569 B

1234567891011121314151617181920212223
  1. //go:build linux
  2. package app
  3. import (
  4. "time"
  5. "hth/internal/backend"
  6. "hth/internal/config"
  7. "hth/internal/profile"
  8. )
  9. func newSerialBackend(cfg *config.Config, p *profile.Profile) (backend.Backend, error) {
  10. inter := p.InterByteTimeout()
  11. if cfg.Serial.InterByteTimeoutMS > 0 {
  12. inter = time.Duration(cfg.Serial.InterByteTimeoutMS) * time.Millisecond
  13. }
  14. resp := p.GetResponseTimeout()
  15. if cfg.Serial.ResponseTimeoutMS > 0 {
  16. resp = time.Duration(cfg.Serial.ResponseTimeoutMS) * time.Millisecond
  17. }
  18. return backend.NewSerial(cfg.Serial.Path, inter, resp), nil
  19. }