From: Brad M. <bmi...@gm...> - 2008-04-03 03:21:48
|
channel 2 looks wrong. it's usually 1, but you can use sdptool to check. On Wed, Apr 2, 2008 at 8:49 PM, Zack Schilling <za...@sn...> wrote: > I understand that some of my setup could be simpler (I tried it the > way you described and got basically the same result). GPSd cannot > connect to this device, nor can "sertest", a serial test program off > the Wiki. What should the inside of my rfcomm file look like? Right > now, it looks like this: > > rfcomm0 { > listen yes; > > # Bluetooth address of the device > device hci0; > > # RFCOMM channel for the connection > channel 1; > > # Description of the connection > comment "Gumstix Serial Console"; > } > > rfcomm1 { > bind yes; > device 00:0D:B5:34:B1:12; > channel 2; > comment "GPS"; > } > > > Does the passkey go in here somewhere? Do I have it set up incorrectly? > > > > > On Apr 2, 2008, at 10:22 PM, Brad Midgley wrote: > > > Zach > > > > Some of your approach could be simpler. You don't need to do anything > > with sdp since you are a client to the gps. > > > > Put your rfcomm bindings in /etc/bluetooth/rfcomm.conf. > > > > Use gpsd and point it at /dev/rfcomm1 or whatever using /etc/default/ > > gpsd. > > > > You can make gpsd hold the connection up by running something like > > "gpspipe -r" in the background. Otherwise the bt connection is made on > > demand and your gps may time and turn off the bt radio. > > > > The c api for gpsd is straightforward and isolates you from nmea > > parsing. > > > > Brad > > > > On Wed, Apr 2, 2008 at 4:41 PM, Zack Schilling <za...@sn...> wrote: > >> This is a long read, I'm sorry for that, but I wanted to be very > >> complete. Please read all of it. > >> > >> I'm working on a project where I'd like to connect a waysmall 400xm- > >> bt > >> to a Bluetooth GPS receiver. The receiver is a G-sat model that > >> requires a passkey for connection ("0000"). I'm trying to connect it > >> to the gumstix computer as a bluetooth serial device. I then want to > >> use this serial device in a C program I'm writing. > >> > >> I seem to be having trouble getting this all working and I'm not > >> exactly sure where the problem is, I'm new to all of this. Basically, > >> this is what I have: > >> > >> I want to keep the bluetooth terminal and this new device at the same > >> time, so I have the following in a startup script: > >> > >> sdptool add --channel=2 SP > >> sdptool setattr 0x10000 0x100 "Ch 1 Serial (getty)" > >> sdptool setattr 0x10001 0x100 "Ch 2 Serial (GPS)" > >> > >> This seems to be working. I can see it run at startup and it makes > >> the > >> new port for me. > >> > >> Next, I have a script that binds the bluetooth device to /dev/rfcomm1 > >> before my program runs. I simply run the command: > >> > >> # rfcomm bind 1 00:0D:B5:34:B1:12 > >> # rfcomm > >> rfcomm1: 00:0D:B5:34:B1:12 channel 1 clean > >> > >> As you can see, the port binds and all that. I can even ping the > >> device (l2ping 00:0D:B5:34:B1:12) with 0% loss. But when I run my C > >> program, the trouble starts. > >> > >> The program is supposed to read from the GPS, run a few calculations, > >> and send off the result over wired serial (ttyS2) to a nearby PIC. > >> The > >> wired serial port part works fine. I've tested it independently with > >> hardcoded data. However, the minute I try to use basically the same > >> code to connect to and test the GPS, it all goes downhill. > >> > >> The GPS setup code follows: > >> > >> // Open the GPS serial port. > >> > >> if (( gpsPort = open( "/dev/rfcomm1", O_RDWR | O_EXCL )) < 0 ) > >> { > >> fprintf( stderr, "Unable to open GPS serial port: %s > >> \n", > >> strerror( errno )); > >> exit( 2 ); > >> } > >> > >> // Get the attribute structure of the port we just opened to set up > >> the baud rate and other details. > >> if ( tcgetattr( gpsPort, &attr ) < 0 ) > >> { > >> fprintf( stderr, "Failed initialize GPS serial port: %s\n", > >> strerror( errno )); > >> exit( 3 ); > >> } > >> > >> attr.c_iflag = 0; // No Software Flow Control > >> attr.c_oflag = 0; > >> attr.c_cflag = CLOCAL | CREAD | CS8; > >> attr.c_lflag = 0; > >> attr.c_cc[ VTIME ] = 2; // timeout in tenths of a second > >> attr.c_cc[ VMIN ] = 1; > >> > >> cfsetispeed( &attr, B38400 ); > >> cfsetospeed( &attr, B38400 ); > >> > >> // Apply the attribute changes. > >> if ( tcsetattr( gpsPort, TCSAFLUSH, &attr ) < 0 ) > >> { > >> fprintf( stderr, "Failed to setup GPS serial port: %s\n", > >> strerror( errno )); > >> exit( 4 ); > >> } > >> > >> // Done setting up GPS. > >> > >> fprintf( stdout, "System Online.\n\n"); > >> > >> > >> > >> Except I never get to the "System Online" part. I get a segmentation > >> fault. Ugh, it couldn't be more vague. Though some basic debugging, I > >> found the program is never getting past this function: > >> > >> open( "/dev/rfcomm1", O_RDWR | O_EXCL ) > >> > >> When I check rfcomm after the program has run, I see: > >> > >> # rfcomm > >> rfcomm1: 00:0D:B5:34:B1:12 channel 1 closed > >> > >> If I run the program again, I get this error: > >> > >> Unable to open GPS serial port: Device or resource busy > >> > >> Ok, not exactly unexpected. I can unbind, bind and run again and I'll > >> get the segmentation fault again. Any advice would be appreciated. Am > >> I missing something obvious? I replaced my default Gumstix bluetooth > >> passkey of 1234 with 0000, should I be doing something else to > >> connect? Could it be my compiler settings? Other wired serial ports > >> open, read, write and otherwise work perfectly fine. In fact, if I > >> replace /dev/rfcomm1 with /dev/ttyS2 in my code, it runs fine. I've > >> been stuck on this for 2 days and it's so frustrating. > >> > >> ------------------------------------------------------------------------- > >> Check out the new SourceForge.net Marketplace. > >> It's the best place to buy or sell services for > >> just about anything Open Source. > >> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > >> _______________________________________________ > >> gumstix-users mailing list > >> gum...@li... > >> https://lists.sourceforge.net/lists/listinfo/gumstix-users > >> > > > > > > > > -- > > Brad > > > > ------------------------------------------------------------------------- > > Check out the new SourceForge.net Marketplace. > > It's the best place to buy or sell services for > > just about anything Open Source. > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > _______________________________________________ > > gumstix-users mailing list > > gum...@li... > > https://lists.sourceforge.net/lists/listinfo/gumstix-users > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > gumstix-users mailing list > gum...@li... > https://lists.sourceforge.net/lists/listinfo/gumstix-users > -- Brad |