Open nnnpa31 opened 1 year ago
Check this to see if it helps: https://github.com/bugst/go-serial/blob/master/serial_linux.go#L12
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. The same code did run on Windows 10 just fine.
Up!
Did it work normally with other terminal emulators? like putty? Is there an easy/cheap way to get one of those CH343G boards to try?
Did it work normally with other terminal emulators? like putty? Is there an easy/cheap way to get one of those CH343G boards to try?
Yes it works perfectly with putty.
@mateo08c @nnnpa31 @xray-bit @Heckelbert
I've updated the library with better error reporting, could you retry with the latest v1.6.2
and paste the error here?
At least we could understand where the InvalidSerialPort error is raised...
@mateo08c @nnnpa31 @xray-bit @Heckelbert I've updated the library with better error reporting, could you retry with the latest
v1.6.2
and paste the error here? At least we could understand where the InvalidSerialPort error is raised...
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:
Read 1 bytes:
Read 1 bytes:
Read 1 bytes:
Read 31 bytes: test, 32768k bytes found.
INFO
Read 1 bytes: :
Read 31 bytes: Self tests complete.
INFO: Do
Read 1 bytes: w
Read 27 bytes: nloading switch software.
Read 1 bytes: E
Read 20 bytes: PROM download (Y) ?
Read 1 bytes: �
Read 31 bytes: ���♠Initial download successful
Read 1 bytes: .
Read 2 bytes:
Read 1 bytes: F
Read 31 bytes: O: Initialising Flash File Syst
Read 1 bytes: e
Read 3 bytes: m.
Read 1 bytes:
Read 2 bytes:
...etc
Second run:
Found port: COM5
Found port: COM3
Found port: COM4
Found port: COM8
Found port: COM10
Found port: COM6
Found port: COM11
USB ID 1A86:7523
USB serial
Invalid serial port
I have also encountered the same problem, is there a solution.
I have also encountered the same problem, is there a solution.
Using 3.3.2011.11
has restored normal operation, but why?
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.