Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

libserial

Build Status GoDoc GoReportCard codecov

Serial library for golang (no cgo)

Prerequisite

  • Go 1.9+ (for type alias)
  • Git (required by Go)

Supported Platform

  • darwin (tested on amd64, thanks to travis)
    • arm64 amd64 arm 386
  • linux (tested on amd64, thanks to travis)
    • all go supported arch
  • windows (not tested, see issue #1)
    • all go supported arch
  • freebsd (not tested)
    • all go supported arch
  • netbsd (not tested)
    • all go supported arch
  • openbsd (not tested)
    • all go supported arch

Usage

TL;DR: you can find a demo cli app in cmd/libserial/main.go

0.Get this package with go get or git clone

go get -u github.com/goiiot/libserial
# git clone https://github.com/goiiot/libserial

1.Import this package

import (
    // ...
    "github.com/goiiot/libserial"
)

2.Open serial connection and check error

// open serial port with default settings (9600 8N1)
conn, err := libserial.Open("/dev/serial0")

if err != nil {
    panic("hmm, how cloud it fail")
}

Note: You can add options when opening serial port, see godoc - Option

3.Read/Write data from serial connection

buf := make([]byte, 64)

_, err := conn.Read(buf[:])
if err != nil { }

_, err := conn.Write([]byte("{data}"))
if err != nil { }

Command line demo

You can download and install libserial to your $GOPATH/bin for quick demo test (GOPATH required)

go get -u github.com/goiiot/libserial/cmd/libserial

References

LICENSE

GitHub license

Copyright Go-IIoT (https://github.com/goiiot)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Serial library for Go (no cgo)

Topics

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.