hybridgroup / cylon-sphero

Cylon adaptor for Sphero robot
http://cylonjs.com
Other
47 stars 16 forks source link

Program exits immediately #46

Closed caseyhoward closed 10 years ago

caseyhoward commented 10 years ago

Hi, all I'm trying to do is get a "hello world" going. I tried months ago and gave up, but I decided to try again and hit the same wall. Everything looks good. No bad output, but the program does nothing. I tried following your bluetooth instructions but they didn't work exactly as you had them. Here's what I had to run:

$ gort scan bluetooth
Scanning ...
    68:86:E7:03:C0:E0   Sphero-BPO
$ gort bluetooth pair 68:86:E7:03:C0:E0 hci0
Release
New device (/org/bluez/775/hci0/dev_68_86_E7_03_C0_E0)
$ gort bluetooth connect 68:86:E7:03:C0:E0 hci0
Connected /dev/rfcomm0 to 68:86:E7:03:C0:E0
Press CTRL-C to disconnect

After that I tried running the following program:

var port = '/dev/rfcomm0';
var Cylon = require('cylon');

console.log('outside robot');
Cylon.robot({
  connection: { name: 'sphero', adaptor: 'sphero', port: port},
  device: { name: 'sphero', driver: 'sphero' },

  work: function(my) {
    console.log('in work');
    every((1).second(), function() {
      console.log('rolling');
      my.sphero.roll(60, Math.floor(Math.random() * 360));
    });
  }
}).start();

The only thing the prints is "outside robot". It outputs the following: outside robot I, [2014-10-08T02:40:07.167Z] INFO -- : Initializing connections. I, [2014-10-08T02:40:07.167Z] INFO -- : Initializing connection 'sphero'. D, [2014-10-08T02:40:07.167Z] DEBUG -- : Loading adaptor 'sphero'. I, [2014-10-08T02:40:07.203Z] INFO -- : Registering Sphero adaptor for Robot 46939 I, [2014-10-08T02:40:07.203Z] INFO -- : Registering Sphero driver for Robot 46939 I, [2014-10-08T02:40:07.203Z] INFO -- : Initializing devices. I, [2014-10-08T02:40:07.203Z] INFO -- : Initializing device 'sphero'. D, [2014-10-08T02:40:07.204Z] DEBUG -- : Loading driver 'sphero'. I, [2014-10-08T02:40:07.205Z] INFO -- : Starting connections. I, [2014-10-08T02:40:07.205Z] INFO -- : Connecting to 'sphero' on port /org/biluez/775/hci0/dev_68_86_E7_03_C0_E0. I, [2014-10-08T02:40:07.205Z] INFO -- : Connecting to Sphero 'sphero'...

I tried both ports in the file. There are no ports sphero related in /dev. By the way, I have a very similar program written in go that actually works (I used /dev/rfcomm0). It would be nice if cylon worked too. I'm running out of ideas. Some help would be appreciated. Thanks.

deadprogram commented 10 years ago

Hi, @caseyhoward here are a couple things that might help. You need to leave the gort bluetooth connect command running, and then run your cylon program in another window using the port /dev/rfcomm0 or whichever is displayed by the connect. Otherwise the Bluetooth to serial connection is closed.

Additionally, make sure your current user has sufficient privileges to access that port. Your current user needs to be a member of the dialout group on most Linux distros. You can test by running your Cylon program using sudo and if it works, then it is a port permissions issue.

Hope that helps!

caseyhoward commented 10 years ago

sudo did the trick. I should have tried that sooner. Thanks!

caseyhoward commented 10 years ago

I did also try adding myself to the dialout group (as well as the tty and bluetooth groups) but I still can't run without sudo. It's not the worst thing in the world but I don't like having to use sudo. I don't have to use sudo when I run my go app. I've tried googling some and haven't been able to find anything. I'm running Linux Mint 17 by the way. If you have any other ideas please let me know. Thanks.