Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/20yyq/serial

serial port
https://github.com/20yyq/serial

golang ioctl linux serial serialport series windows

Last synced: 12 days ago
JSON representation

serial port

Awesome Lists containing this project

README

        

# serial
serial port
## 简介

项目实现了Linux系统多个架构、Windows系统的串行设备的数据读写功能。并能实现对当前建立连接的设备进行再次重新配置参数进行重新运行。

# 例子
```go
func main() {
c := serial.Config{Baud: 115200, ReadTime: time.Hour}
conn, err := serial.New("COM9", c)
if err != nil {
fmt.Println("conn new error:", err)
return
}
b := make([]byte, 1024)
for {
n, err := conn.Read(b)
if err != nil {
fmt.Println("conn.Read error:", err)
break
}
fmt.Println("Read byte:", b[:n])
}
quit := make(chan os.Signal)
signal.Notify(quit, os.Interrupt)
<-quit
}
```