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.
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
Describe the problem
Failed to reopen the port with error 'Serial port busy'
To reproduce
Reproduce steps:
Start the program to open the port, then kill it
Restart the program, got this error:
The code to open the port:
Please double-check that you have reported each of the following
before submitting the issue.
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