Skip to content

Make serial port settle delay configurable#24

Merged
rustyeddy merged 4 commits intogtu7from
copilot/sub-pr-16-bb23bad1-1959-4c61-813c-573e18f9a60e
Jan 17, 2026
Merged

Make serial port settle delay configurable#24
rustyeddy merged 4 commits intogtu7from
copilot/sub-pr-16-bb23bad1-1959-4c61-813c-573e18f9a60e

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 16, 2026

Addresses hard-coded 10ms sleep after serial port configuration in configureTermios. The delay lacks documentation and cannot be adjusted for different hardware requirements or performance-sensitive applications.

Changes:

  • Added SettleDelay field to SerialConfig with behavior:
    • Zero value (unset) → defaults to 10ms for backward compatibility
    • Positive value → uses specified duration
    • Negative value → disables delay entirely
  • Documented why the delay exists (hardware stabilization after terminal reconfiguration)
  • Updated configureTermios to use configurable delay parameter

Usage:

// Use default 10ms delay
cfg := drivers.SerialConfig{Port: "/dev/ttyUSB0", Baud: 9600}

// Custom delay for specific hardware
cfg := drivers.SerialConfig{
    Port: "/dev/ttyUSB0", 
    Baud: 9600,
    SettleDelay: 50 * time.Millisecond,
}

// Disable delay for performance-sensitive applications
cfg := drivers.SerialConfig{
    Port: "/dev/ttyUSB0", 
    Baud: 9600,
    SettleDelay: -1,
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 16, 2026 17:57
Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 16, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • go.googlesource.com
    • Triggering command: /update-job-proxy /update-job-proxy fips140/sha512 (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-358bc12dffac -j DOCKER-ISOLATION-STAGE-2 ot_CA_-_R4.pem /opt/hostedtoolc-e test f7d2c7798f006b9d/usr/bin/git /tmp/go-build124config /opt/hostedtoolcextensions.objectformat test -e igiCert_High_Assurance_EV_Root_CA.pem /opt/hostedtoolc-e /usr/bin/test alse f7d2c7798f006b9d--wait (dns block)
  • gopkg.in
    • Triggering command: /update-job-proxy /update-job-proxy fips140/sha512 (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-358bc12dffac -j DOCKER-ISOLATION-STAGE-2 ot_CA_-_R4.pem /opt/hostedtoolc-e test f7d2c7798f006b9d/usr/bin/git /tmp/go-build124config /opt/hostedtoolcextensions.objectformat test -e igiCert_High_Assurance_EV_Root_CA.pem /opt/hostedtoolc-e /usr/bin/test alse f7d2c7798f006b9d--wait (dns block)
  • periph.io
    • Triggering command: /update-job-proxy /update-job-proxy fips140/sha512 (dns block)
    • Triggering command: /update-job-proxy /update-job-proxy -o br-358bc12dffac -j DOCKER-ISOLATION-STAGE-2 ot_CA_-_R4.pem /opt/hostedtoolc-e test f7d2c7798f006b9d/usr/bin/git /tmp/go-build124config /opt/hostedtoolcextensions.objectformat test -e igiCert_High_Assurance_EV_Root_CA.pem /opt/hostedtoolc-e /usr/bin/test alse f7d2c7798f006b9d--wait (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update Gtu7 sensor and serial drivers based on review feedback Make serial port settle delay configurable Jan 16, 2026
Copilot AI requested a review from rustyeddy January 16, 2026 18:01
@rustyeddy rustyeddy marked this pull request as ready for review January 17, 2026 16:16
Copilot AI review requested due to automatic review settings January 17, 2026 16:16
@rustyeddy rustyeddy merged commit d5c9358 into gtu7 Jan 17, 2026
2 checks passed
@rustyeddy rustyeddy deleted the copilot/sub-pr-16-bb23bad1-1959-4c61-813c-573e18f9a60e branch January 17, 2026 16:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the serial port settle delay configurable by adding a SettleDelay field to SerialConfig. The previously hard-coded 10ms delay after terminal configuration can now be customized or disabled based on hardware requirements.

Changes:

  • Added SettleDelay field to SerialConfig with documentation explaining its purpose and behavior (zero defaults to 10ms, negative disables)
  • Updated configureTermios to accept and apply the configurable settle delay
  • Cleaned up unused dependencies from go.mod and go.sum

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
drivers/serial.go Added SettleDelay field to SerialConfig with clear documentation
drivers/serial_linux.go Updated configureTermios signature and implementation to use configurable delay
go.mod Promoted golang.org/x/sys to direct dependency, removed unused dependencies
go.sum Synchronized with go.mod changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread go.mod
github.com/stretchr/testify v1.11.1
github.com/warthog618/go-gpiocdev v0.9.1
golang.org/x/image v0.23.0
golang.org/x/sys v0.29.0
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The promotion of golang.org/x/sys from an indirect to a direct dependency is appropriate since it's imported directly in drivers/serial_linux.go. However, the removal of github.com/maciej/bme280, github.com/nfnt/resize, and golang.org/x/image appears unrelated to the stated PR purpose of making the serial port settle delay configurable. Consider separating dependency cleanup into a separate PR for clearer change tracking.

Copilot uses AI. Check for mistakes.
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.

3 participants