Package serial provides a binding to libserialport for serial port functionality. Serial ports are commonly used with embedded systems, such as the Arduino platform.
package main
import (
"github.com/mikepb/go-serial"
"log"
)
func main() {
options := serial.RawOptions
options.BitRate = 115200
p, err := options.Open("/dev/tty")
if err != nil {
log.Panic(err)
}
// optional, will automatically close when garbage collected
defer p.Close()
buf := make([]byte, 1)
if c, err := p.Read(buf); err != nil {
log.Panic(err)
} else {
log.Println(buf)
}
}
https://godoc.org/github.com/mikepb/go-serial
Copyright 2014 Michael Phan-Ba
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.
Files from the libserialport library are licensed under the GNU Lesser General Public License. These files include in the header the notice that follows.
This file is part of the libserialport project.
Copyright (C) 2010-2012 Bert Vermeulen <[email protected]>
Copyright (C) 2010-2012 Uwe Hermann <[email protected]>
Copyright (C) 2013-2014 Martin Ling <[email protected]>
Copyright (C) 2013 Matthias Heidbrink <[email protected]>
Copyright (C) 2014 Aurelien Jacobs <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.