core: update Keyboard platform to simply return error

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2016-11-07 19:35:04 +01:00
parent af21d98074
commit 80cb23de32
3 changed files with 11 additions and 11 deletions

View File

@ -135,13 +135,13 @@ func configure() (err error) {
}
// restores the TTY to the original state
func restore() (errs []error) {
if _, err := stty("echo"); err != nil {
return []error{err}
func restore() (err error) {
if _, err = stty("echo"); err != nil {
return
}
if _, err := stty(originalState); err != nil {
return []error{err}
if _, err = stty(originalState); err != nil {
return
}
return

View File

@ -66,9 +66,9 @@ func (k *Driver) Connection() gobot.Connection { return nil }
// Start initializes keyboard by grabbing key events as they come in and
// publishing a key event
func (k *Driver) Start() (errs []error) {
if err := k.connect(k); err != nil {
return []error{err}
func (k *Driver) Start() (err error) {
if err = k.connect(k); err != nil {
return err
}
go k.listen(k)
@ -77,7 +77,7 @@ func (k *Driver) Start() (errs []error) {
}
// Halt stops camera driver
func (k *Driver) Halt() (errs []error) {
func (k *Driver) Halt() (err error) {
if originalState != "" {
return restore()
}

View File

@ -27,10 +27,10 @@ func TestKeyboardDriver(t *testing.T) {
func TestKeyboardDriverStart(t *testing.T) {
d := initTestKeyboardDriver()
gobottest.Assert(t, len(d.Start()), 0)
gobottest.Assert(t, d.Start(), nil)
}
func TestKeyboardDriverHalt(t *testing.T) {
d := initTestKeyboardDriver()
gobottest.Assert(t, len(d.Halt()), 0)
gobottest.Assert(t, d.Halt(), nil)
}