BlitzMax & Lego Mindstorms NXT

BlitzMax Forums/BlitzMax Programming/BlitzMax & Lego Mindstorms NXT

Hi folks,

Anybody here building robots with the new Lego NXT brick and using BlitzMax to send commands to it via BlueTooth?

I'm on OS X and have a working BlueTooth connection to the NXT with a bluetooth serial port named NXT_1 assigned to it. It appears in /dev as tty.NXT_1.

This port works with iCommand, the Open Source Java environment for the NXT.

However, when I try this is BlitzMax, which is supposed to play a tone, nothing happens and nothing is returned from the brick:


NXTWrite:TStream = WriteStream( "/dev/tty.NXT_1" )

If Not NXTWrite
	Print "Failed to open write stream."
	End
End If

NXTRead:TStream = ReadStream( "/dev/tty.NXT_1" )


If Not NXTRead
	Print "Failed to open read stream."
	End
End If

WriteByte( NXTWrite, $00 )
WriteByte( NXTWrite, $03 )
WriteShort( NXTWrite, 8000 )
WriteShort( NXTWrite, 60 )

FlushStream( NXTWrite )

Print "Now:" + StreamSize( NXTRead )


For n:Int = 0 To 6
	Print ReadByte( NXTRead )
Next

CloseStream( NXTWrite )
CloseStream( NXTRead )



Anybody got an idea what I'm doing wrong?

Thanks!