Skip to content

Commit

Permalink
Fix neurosky runtime error
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Jul 14, 2014
1 parent 8e68601 commit b71e886
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ func (d *Driver) Events() map[string]*Event {
}

func (d *Driver) Event(name string) *Event {
return d.events[name]
e, ok := d.events[name]
if ok {
return e
} else {
panic(fmt.Sprintf("Unknown Driver Event: %v", name))
}
}

func (d *Driver) AddEvent(name string) {
Expand Down
14 changes: 7 additions & 7 deletions platforms/neurosky/neurosky_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,29 @@ func (n *NeuroskyDriver) parsePacket(data []byte) {
b, _ := buf.ReadByte()
switch b {
case CodeEx:
gobot.Publish(n.Event("Extended"), nil)
gobot.Publish(n.Event("extended"), nil)
case CodeSignalQuality:
ret, _ := buf.ReadByte()
gobot.Publish(n.Event("Signal"), ret)
gobot.Publish(n.Event("signal"), ret)
case CodeAttention:
ret, _ := buf.ReadByte()
gobot.Publish(n.Event("Attention"), ret)
gobot.Publish(n.Event("attention"), ret)
case CodeMeditation:
ret, _ := buf.ReadByte()
gobot.Publish(n.Event("Meditation"), ret)
gobot.Publish(n.Event("meditation"), ret)
case CodeBlink:
ret, _ := buf.ReadByte()
gobot.Publish(n.Event("Blink"), ret)
gobot.Publish(n.Event("blink"), ret)
case CodeWave:
buf.Next(1)
var ret = make([]byte, 2)
buf.Read(ret)
gobot.Publish(n.Event("Wave"), ret)
gobot.Publish(n.Event("wave"), ret)
case CodeAsicEEG:
var ret = make([]byte, 25)
i, _ := buf.Read(ret)
if i == 25 {
gobot.Publish(n.Event("EEG"), n.parseEEG(ret))
gobot.Publish(n.Event("eeg"), n.parseEEG(ret))
}
}
}
Expand Down

0 comments on commit b71e886

Please sign in to comment.