-
Notifications
You must be signed in to change notification settings - Fork 220
Open
Labels
Description
Describe the problem
Failed to reopen the port with error 'Serial port busy'
To reproduce
Reproduce steps:
- Create pts paris with socat
socat -d -d PTY,link=/tmp/ttyV0,raw,echo=0 PTY,link=/tmp/ttyV1,raw,echo=0
-
Start the program to open the port, then kill it
-
Restart the program, got this error:
WRN Open failed error="Serial port busy" Port=/tmp/ttyV0
The code to open the port:
type SerOption struct {
PortName string
BaudRate uint
}
type SerFile struct {
file serial.Port
}
func OpenSerFile(option *SerOption) (*SerFile, error) {
mode := serial.Mode{
BaudRate: int(option.BaudRate),
DataBits: 8,
Parity: serial.NoParity,
StopBits: serial.OneStopBit,
}
file, err := serial.Open(option.PortName, &mode)
if err != nil {
return nil, err
}
file.SetDTR(false)
file.SetRTS(false)
return &SerFile{file}, nil
}
Please double-check that you have reported each of the following
before submitting the issue.
- I've provided the FULL source code that causes the problem
- I've provided all the actions required to reproduce the problem
Expected behavior
Open the port successfully after restart
Operating system and version
Linux
Please describe your hardware setup
socat pts pair
Additional context
No response
Issue checklist
- I searched for previous requests in the issue tracker
- My request contains all necessary details