Bluetooth Serial Port To NXT in Linux

I finally got around to playing with the NXT in linux with ruby-nxt. Since ruby-nxt currently only supports a serial port connection (hopefully a native bluetooth module will be ready soon), you have to use rfcomm to setup a serial device. Here’s how you do it (using ubuntu 6.06 and a linksys usb adapter)…

First you have to find the mac address of your NXT with the following command:

abuser@wraith:/etc/bluetooth$ hcitool scan
Scanning ...
        00:16:53:04:B3:46       NXT

Then sudo vim /etc/bluetooth/rfcomm.conf and add an entry like this:

rfcomm0 {
        bind yes;
        # Bluetooth address of the device
        device 00:16:53:04:B3:46;
        # RFCOMM channel for the connection
        channel 1;
        # Description of the connection
        comment "NXT";
}

Then restart bluetooth with a sudo /etc/init.d/bluez-utils restart.

Then to verify it’s setup, run rfcomm and you should see output like this:

abuser@wraith:/etc/bluetooth$ rfcomm
rfcomm0: 00:16:53:04:B3:46 channel 1 clean

You should now have a /dev/rfcomm0 that you can use with ruby-nxt. The first time you run a ruby-nxt program, it might pop up a message for the PIN, just enter 1234.

If you want to setup a connection FROM the NXT to your computer, (where your computer is a slave to the NXT where you can send BT messages from a program running on the NXT to your computer) follow these instructions.

Similar instructions for windows here and osx here.

Filed under  //   lego   linux   mindstorms  

Comments [0]

mod_fcgid Slow Startup on Ubuntu Fix

I recently switched to using modfcgid instead of modfastcgi. So far its nice and fast… except for the first hit after a period of inactivity. This is because fcgid kills off idle processes and it takes an annoyingly long time to start one up on this server. It turns out there is an option to set a minimum number of processes, however the version of mod_fcgid on Ubuntu Breezy doesn’t have it. Here’s how I installed it:

sudo apt-get install apache2-dev

Download mod_fcgid 1.09 or greater

Edit it’s Makefile and change top_dir = /usr/share/apache2

make

cp .libs/mod_fcgid.so /usr/lib/apache2/modules

Edit /etc/apache2/mods-available/fcgid.conf and add a line that says DefaultMinClassProcessCount 3 and restart apache.

The first hit after a restart will be slow, but from then on it will maintain at least DefaultMinClassProcessCount processes.

Filed under  //   linux  

Comments [0]