ruby-serialport/nxt on Windows
My MacBookPro has been acting up (randomly deciding not to boot) So I sent it back to Apple for repairs. In the meantime, I've been stuck in Windows which has kept me from working on ruby-nxt because the ruby-serialport module requires compilation. This is not an easy thing to accomplish in Windows. I tried in vain to get it to compile using the free MSVC++ Express version. Apparently MSVC++ version 6 is required. However, I did manage to get it working using Cygwin.
Cygwin is a Linux-like environment for Windows. It's a little confusing to install and just plain feels weird, but it gets the job done. Basically when you install Cygwin, navigate down the tree of packages and install the following under Devel: gcc, make, and ruby. Add c:\cygwin\bin to your path. The ruby that comes with cygwin is slightly borked. It sets RUBYOPT=-rubygems for some reason. So make sure you "SET RUBYOPT=" to clear that out. Then download ruby-serialport and install it normally. (ruby extconf.rb, make, make install)
Now, when you pair your NXT via bluetooth, it should have created a COM4 Outgoing port on NXT 'Dev B'. Cygwin emulates the windows com ports to virtual /dev devices. COM1 = /dev/ttyS0. So in my case, the NXT is on COM4 therefore in ruby-nxt you want to connect to /dev/ttyS3.
During this whole fiasco I came this close to wiping this computer and installing Linux on it. Man I miss my MacBook...
Mindstorms NXT Bluetooth on OSX 7
Lego released the Mindstorms NXT Developer Kit today! I was bummed when I found out that the software that comes with it for OSX is PPC. Apps running under Rosetta are unable to access bluetooth so I couldn't play with in on my Macbook Pro. Now that the dev kit is available I plan on writing a ruby module to communicate with the NXT via bluetooth. First I had to figure out how to access it via a bluetooth serial port.
When I first got my NXT and found bluetooth no worky in NXT-G, I tried creating a serial port and connecting to it. It would connect, and show up as being on connection 0 on the NXT and no matter what I did, I couldn't get a message to show up in OSX. Connection 0 means the NXT thought it was a slave. It should still be able to send messages to it's master, yet I get nothing. Connections initiated on the NXT to the computer always came up Line is Busy.
I finally made a breakthrough today. I was doing some research and found that you can create an incoming bluetooth serial port and then connect to my computer from the NXT. Here's the steps:
Pair the NXT with OSX.
Go into the Bluetooth Preferences, Sharing tab and Add Serial Port Service. Give it a name (I made it NXT-Master). Set Type to RS-232. This will create a /dev/tty.NXT-Master device.
Open the device in OSX (this is important, otherwise you'll get a Line Is Busy message on the NXT) Just doing a cat /dev/tty.NXT-Master in a terminal will do it.
On the NXT, goto Bluetooth, My Contacts, Select your computer, Connect to whatever connection number you want.
Run a program on the NXT that sends a message to whatever connection number you chose.
Woot! The message should show up in terminal.
Juju