serialport

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: MIT Imports: 3 Imported by: 0

README

Serial Port

serialport is a small library which allows you to send or received data from hardware

go get github.com/gopkg-utils/serialport

For example:

func main() {
    sp, err := serialport.Open("COM1", 9600, 8, 1)
    if err != nil {
        fmt.Println(err)
    } else {
        sp.Received(0x0a, func(data []byte) {
            fmt.Printf("%s", data)
        })
    }

    fmt.Scanln()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ISerialPort added in v1.0.1

type ISerialPort interface {
	Send(data []byte) error
	Received(delim byte, callback func(data []byte))
	Close() error
}

func Open

func Open(portName string, baudRate int, dataBits byte, stopBits byte) (ISerialPort, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL