-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Description
Hello, I tried exactly as the example (example the port name and add function read for recv data). I successfully write Byte array to port but failed to read from it. it alway return an error which called "read /dev/tty.usbserial1: interrupted system call". i've tried serveral time but Disappointing results. any suggestions? looking forward to your reply.
I running it on macOS sierra 10.12.6, here is the code:
`import (
"fmt"
"github.com/jacobsa/go-serial/serial"
"log"
"testing"
)
func TestSerialData(t *testing.T) {
// Set up options.
options := serial.OpenOptions{
PortName: "/dev/tty.usbserial1",
BaudRate: 19200,
DataBits: 8,
StopBits: 1,
MinimumReadSize: 4,
}
// Open the port.
port, err := serial.Open(options)
if err != nil {
log.Fatalf("serial.Open: %v", err)
}
// Make sure to close it later.
defer port.Close()
// Write 4 bytes to the port.
b := []byte{0x00, 0x01, 0x02, 0x03}
w, err := port.Write(b)
if err != nil {
log.Fatalf("port.Write: %v", err)
}
fmt.Println("Wrote", w, "bytes.")
buf := make([]byte, 128)
r, err := port.Read(buf)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Read", r, "bytes.")
}`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels