Skip to content

vinhjaxt/serial

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

110 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serial

Golang package for serial port

GoDoc

A Go package that allow you to read and write from the serial port.

This is a forked repo written by @tarm.

Install

go get github.com/vinhjaxt/serial

Usage

package main
 
import (
	"time"
	"github.com/vinhjaxt/serial"
)

func main() {
    sp := serial.New()
    err := sp.Open("COM1", 9600)
    if err != nil {
        panic(err)
    }
    defer sp.Close()
    sp.Println("AT")
    sp.WaitForRegexTimeout("OK.*", time.Second * 10)
}

NonBlocking Mode

By default the returned serial port reads in blocking mode. Which means Read() will block until at least one byte is returned. If that's not what you want, specify a positive ReadTimeout and the Read() will timeout returning 0 bytes if no bytes are read. Please note that this is the total timeout the read operation will wait and not the interval timeout between two bytes.

	sp := serial.New()
    err := sp.Open("COM1", 9600, time.Second * 5)

About

Golang package for serial port

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 100.0%