Skip to content

Add setResponseTimeout() for configurable response timeout#207

Open
karolyczovek wants to merge 2 commits into4-20ma:masterfrom
karolyczovek:configurable-response-timeout
Open

Add setResponseTimeout() for configurable response timeout#207
karolyczovek wants to merge 2 commits into4-20ma:masterfrom
karolyczovek:configurable-response-timeout

Conversation

@karolyczovek
Copy link

Description

The response timeout is currently a fixed 2000 ms (ku16MBResponseTimeout). When no slave is present, each request blocks for 2 s, which can make the main loop unresponsive (e.g. serial input lag) when doing multiple reads per cycle.

This change adds setResponseTimeout(uint16_t ms) so the timeout can be set after begin(). Default remains 2000 ms. A private member _u16ResponseTimeoutMs is initialized to ku16MBResponseTimeout in the constructor. Existing code is unchanged; call setResponseTimeout(500) (or similar) to fail sooner when no device responds.

Backward compatible: if setResponseTimeout() is never called, behaviour is identical to before.

Issues Resolved

None (new feature; no existing issue).

Check List

General

  • Code follows coding style defined in STYLE.md
  • Doxygen comments are included inline with code
  • No unnecessary whitespace; check with git diff --check before committing.

The following have been modified to reflect new features, if warranted

  • README.md
  • keywords.txt (use tabs as whitespace separators)
  • library.properties
  • examples/ – update or create new ones, as warranted

The following have NOT been modified

  • doc/
  • .ruby-gemset
  • .ruby-version
  • CHANGELOG.md
  • Gemfile
  • LICENSE
  • VERSION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant