Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/20yyq/serial
- Owner: 20yyq
- License: bsd-2-clause
- Created: 2023-02-20T05:39:15.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-23T03:40:29.000Z (3 months ago)
- Last Synced: 2024-10-23T11:52:02.231Z (2 months ago)
- Topics: golang, ioctl, linux, serial, serialport, series, windows
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
}
```