Skip to content

Instantly share code, notes, and snippets.

@ZachMassia ZachMassia/serial.go
Last active Dec 20, 2015

Embed
What would you like to do?
type Message struct {
type string
midiData [3]byte
sysexData[255]byte
sysexLen int
}
func NewBoard() *Board {
b := &Board{}
// Start the message loops
out := Read()
messages := Parse(out)
go HandleMessages(messages)
return b
}
func Read() <-chan byte {
buf := make([]byte, 1)
out := make(chan byte)
go func() {
for {
Read(buf)
out <- buf[0]
}
}()
return out
}
func Parse(in <-chan byte) <-chan Message {
out := make(chan Message)
go func() {
for inByte := range in {
// parse into message
out <- parseMsg
}
}()
return out
}
func HandleMessages(in <-chan Message) {
for {
// handle messages
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.