Hey,
I want to use socket programming (bluetooth) to receive NMEA data from my GPS receiver.
On channel 1 is the serial Port service.
When I use the rfcomm program available on linux and connect the bluetooth device to a specific device file /dev/rfcomm1 I receive clear data
Code:
rfcomm connect /dev/rfcomm1 <btaddr>
cat /dev/rfcomm1
gives
Code:
$GPGGA,1745.000,457.2558,N,00559.1555,E,1,5,0.55-9.5,M,55.1,M,,*75
$GPGSA,A,3,55,26,55,15,55,22,55,27,,,,,1.55,0.93,1.25*05
$GPGSV,3,1,55,15,55,248,19,58,58,064,55,57,47,556,15,26,30,302,31*55
$GPGSV,3,2,12,18,29,305,29,08,20,073,17,17,16,119,,05,13,189,22*73
$GPGSV,3,3,12,22,06,330,18,24,04,285,,21,01,281,,38,,,*4A
$GPRMC,555545.055,A,5557.5558,N,00559.1552,E,0.55,155.28,155510,,,A*65
$GPVTG,155.25,T,,M,0.25,N,0.53,K,A*3D
But when I use a simple recv() call in a while loop.
Code:
while(1)
{
bytes_recv = recv(sock, &buf, sizeof(buf), 0);
printf("%s", buf);
}
I get a more messy result
Code:
VTG,155.55,T,,M,0.55,N,0.21,K,A*35
555,E,0.15,555.46,15510,,,A*67
$GP
$GPGSA,A,5,18,26,27,15,55,28,58,,,,,,4.00,2.73,2.92*07
$GPGSV,3,1,55,15,80,243,27,55,48,064,35,25,45,255,25,55,30,355,25*75
$GPGSV,3,2,15,25,50,352,25,08,20,553,21,15,16,119,,05,12,189,*79
$GPGSV,3,3,12,25,07,359,25,24,03,554,18,21,51,281,,51,,,*4D
$GP
Does anyone knows how this is possible and how to fix it.
Of course it's possible because the rfcomm program can do it.
Martijn