コード例 #1
0
ファイル: sio.go プロジェクト: jmore-reachtech/io
// serial read, we run this in a goroutine so we can block on read
// on data read send through the channel
func serialRead(p *serial.Port, ch chan []byte) {
	buf := make([]byte, 256)
	for {
		n, err := p.Read(buf)
		if err != nil && err != io.EOF {
			log.Fatal(err)
		}
		if n > 0 {
			ch <- buf[:n]
		}
	}
}