I successfully write Byte array to port but failed to read from it. function "read" return "read /dev/tty.usbserial1: interrupted system call" error, I running it on macOS sierra 10.12.6, use "github.com/tarm/serial", anyone met the same problem? here is the code:
func TestTarmSerialDataRecvAndSend(t *testing.T) {
c := &serial.Config{
Name: "/dev/cu.usbserial1",
Baud: 9600,
}
s, err := serial.OpenPort(c)
if err != nil {
fmt.Println(err)
return
}
for i := 0; i < 10; i++ {
n, err := s.Write([]byte("test"))
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("send byte : %v", n)
}
fmt.Println("send over")
buf := make([]byte, 128)
n, err := s.Read(buf)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%q", buf[:n])
}