go 串口通讯

 


go get github.com/tarm/goserial

 

package main

import (
    "log"

    serial "github.com/tarm/goserial"
)

func main() {
    //设置串口号和波特率
    s := &serial.Config{Name: "com1", Baud: 9600}

    //打开串口
    _, err := serial.OpenPort(s)
    if err != nil {
        log.Fatal(err)
    }

}

 

posted @ 2020-05-22 15:45  富坚老贼  阅读(1650)  评论(0编辑  收藏  举报