hybridgroup / gobot

Golang framework for robotics, drones, and the Internet of Things (IoT)
https://gobot.io
Other
8.98k stars 1.04k forks source link

Sphero Bluetooth Busy Resource (Mac) #91

Closed nathany closed 9 years ago

nathany commented 10 years ago

If I Ctrl-C the sample program and then go run it again, it would regularly panic on startup with an error that the resource is busy. Running it a second time would usually work fine.

I never experienced this problem on Windows.

Is there some sort of cleanup that isn't happening properly?

Unfortunately I don't own a Sphero (1.0) yet, so if you need more information, it may take me a little while to get. Mac OS X 10.9.3, both dev/master branches tested.

solojavier commented 10 years ago

Could you provide what version of gobot are you using for reference?

nathany commented 10 years ago

Tested with 0.7.x dev 30dc0f68016206917d286ee5d88d8659f5434894 and 0.6.2 86e32b9e9ea08d83cdec64a3f664f330570bb034.

zankich commented 10 years ago

I'll check this out, thanks for reporting the issue!

nathany commented 10 years ago

Trying with a Sphero 2.0 (Firmware 3.59) and the issue isn't happening.

I do see "resource is busy" error if the Sphero 2 has gone to sleep. Maybe the Sphero 1.0's were just going to sleep right away? (I'm not sure of the settings, but they weren't fully charged as well).

nathany commented 10 years ago

It does happen sometimes with Sphero 2.0 as well. Why does the library panic?

2014/08/16 20:24:37 Starting connection Sphero on port /dev/tty.Sphero-WOO-AMP-SPP...
panic: open /dev/tty.Sphero-WOO-AMP-SPP: resource busy

I suppose I can recover and exit cleanly from my calling code.

nathany commented 10 years ago

Using log.Fatal(err) is a little nicer than blowing up with a panic. sphero_adapter.go:28

nathany commented 10 years ago

But not recoverable by the app like with panic, so maybe the current error handling is best.

Just not sure if there is any way to avoid the error altogether.

krylovsk commented 10 years ago

I've also encountered some BT connectivity issues with sphero (2.0), but I wouldn't blame OS X/gobot for it. In fact, it works even better than with android (where sometimes I have to re-pair sphero to make it work after sleep). Panic is a little bit annoying indeed, but I think it makes sense, at least for the prototyping I did so far.

zankich commented 10 years ago

@krylovsk @nathany I'm currently working on completely overhauling the error handling, in the dev branch, because I do agree that throwing a panic is not the correct approach.

nathany commented 10 years ago

Thanks @zankich. Curious to see what you come up with.

solojavier commented 9 years ago

This has been addressed on dev branch : https://github.com/hybridgroup/gobot/blob/dev/platforms/sphero/sphero_adaptor.go#L28-L31

Can we close this issue @zankich @nathany ?

nathany commented 9 years ago

thanks.