Updates to documentation
This commit is contained in:
29
example_serialport_test.go
Normal file
29
example_serialport_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright 2014-2016 Cristian Maglie. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
|
||||
package serial_test
|
||||
|
||||
import "fmt"
|
||||
import "log"
|
||||
import "go.bug.st/serial"
|
||||
|
||||
func ExampleSerialPort_SetMode() {
|
||||
port, err := serial.OpenPort("/dev/ttyACM0", &serial.Mode{})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
mode := &serial.Mode{
|
||||
BaudRate: 9600,
|
||||
Parity: serial.PARITY_NONE,
|
||||
DataBits: 8,
|
||||
StopBits: serial.STOPBITS_ONE,
|
||||
}
|
||||
if err := port.SetMode(mode); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println("Port set to 9600 N81")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user