diff --git a/driver.go b/driver.go index 71d9ff99..db37b17b 100644 --- a/driver.go +++ b/driver.go @@ -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) { diff --git a/platforms/neurosky/neurosky_driver.go b/platforms/neurosky/neurosky_driver.go index 0d3513ac..be7ae9e1 100644 --- a/platforms/neurosky/neurosky_driver.go +++ b/platforms/neurosky/neurosky_driver.go @@ -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)) } } }