-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid serial port error trying to open CH343G based serial port #158
Comments
Check this to see if it helps: |
On Windows 11 (10.0.22621 Build 22621) i have the same error, but it works on ARM64 (Raspberry Pi 3B). I have a CH341 USB adapter. |
I have the same issue after updating to Windows 11. |
Up! |
Did it work normally with other terminal emulators? like putty? |
Yes it works perfectly with putty. |
@mateo08c @nnnpa31 @xray-bit @Heckelbert |
It works! However, even with a defer and a call close function it still won't reopen for me afterward. package main
import (
"fmt"
"go.bug.st/serial"
"go.bug.st/serial/enumerator"
"log"
)
func main() {
ports, err := enumerator.GetDetailedPortsList()
if err != nil {
log.Fatal(err)
}
if len(ports) == 0 {
fmt.Println("No serial ports found!")
return
}
for _, port := range ports {
fmt.Printf("Found port: %s\n", port.Name)
if port.IsUSB {
fmt.Printf(" USB ID %s:%s\n", port.VID, port.PID)
fmt.Printf(" USB serial %s\n", port.SerialNumber)
}
}
open, err := serial.Open("COM11", &serial.Mode{
BaudRate: 9600,
DataBits: 8,
Parity: serial.NoParity,
StopBits: serial.OneStopBit,
})
if err != nil {
fmt.Println(err)
return
}
defer open.Close()
buf := make([]byte, 1024)
for {
n, err := open.Read(buf)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Read %d bytes: %s\n", n, string(buf[:n]))
}
} First run:
Second run:
|
I have also encountered the same problem, is there a solution. |
When does it happen
This error is reported when I open
/dev/ttyCH343USB0
.What module
The device model is
CH343G
.System and version information
Ubuntu 22.04, Go 1.20
Code
What's return
More infomation
The same code and device can run on Windows, just replace
/dev/ttyCH343USB0
withCOM7
.I don't know what other information I need to provide about this. If you need it, please let me know and I will provide it as soon as possible.
Update: I can use the same settings to open it in the serial module of other languages.
The text was updated successfully, but these errors were encountered: