Skip to content

Support single-port modems in Open()#42

Open
JimScope wants to merge 1 commit intoxlab:masterfrom
JimScope:support-single-port-modems
Open

Support single-port modems in Open()#42
JimScope wants to merge 1 commit intoxlab:masterfrom
JimScope:support-single-port-modems

Conversation

@JimScope
Copy link

Summary

  • When NotifyPort == CommandPort, alias notifyPort to cmdPort in Open() so that sanityCheck passes

Motivation

Many budget GSM/LTE modems (e.g. SIM800, Quectel EC25 in single-port mode) expose only one serial port. Currently, if NotifyPort is set equal to CommandPort, Open() skips opening the notification port, leaving notifyPort as nil. This causes sanityCheck to return ErrClosed, making Send() and Init() fail.

Change

In Open(), after the dual-port branch, add:

```go
} else if d.NotifyPort != "" {
d.notifyPort = d.cmdPort
}
```

This aliases the notification port to the command port fd, allowing sanityCheck to pass. Callers should not call Watch() in this configuration, since reading from the same fd in two goroutines would cause race conditions.

Backward Compatibility

No behavioral change for existing dual-port configurations. Only affects the case where NotifyPort == CommandPort, which previously failed with ErrClosed.

Many budget GSM/LTE modems expose only a single serial port for
both commands and notifications, unlike Huawei devices that provide
separate command and notification ports.

When NotifyPort is set to the same value as CommandPort, Open()
now assigns notifyPort = cmdPort so that sanityCheck passes.
Callers should skip Watch() in this configuration to avoid
read conflicts on the shared file descriptor.
JimScope added a commit to JimScope/vendel that referenced this pull request Mar 23, 2026
Mark both xlab/at vendor patches as temporary with links to the
upstream PRs that will make them unnecessary:
- commands.go: Export Dev field (xlab/at#43)
- at.go: Single-port support (xlab/at#42)
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