I have a Linx RXM-GPS-R4-x GPS module that uses the UART pins on the Raspberry Pi 3 model B's GPIO pinout. I'm also using the wiringPi's serial library. However, I'm having difficulty with understanding the communication between the GPS module and my Pi. The datasheet is here. This module uses the NMEA protocols for GPS data.
First, does the module require a wake up or start signal from the Pi to the module before data is sent from the module to the Pi? If this isn't the case, does the module just send and continuous stream for each type of GPS protocol? Lastly, can I just use the wiringPi's serialGetchar()
to read the module-to-Pi signal?
I have a moderate understanding of C++ and a novice experience of the UART interface. Thank you for your time and help!
Below is a very unfinished prototype code if you'd like to suggest how I could approach this problem (I'm building upon a file by the author of the wiringPi author Gordon Henderson, file here):
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringPi.h>
#include <wiringSerial.h>
int main(){
int fd;
int count;
unsigned int nextTime;
if((fd=serialOpen("/dev/ttyAMA0",9600))<0){
fprintf(stderr,"Unable to open serial device: %s\n",strerror(errno));
return 1;
}
if(wiringPiSetup()==1){
fprintf(stdout,"Unable to start wiringPi: %s\n",strerror(errno));
return 1;
}
nextTime=millis()+300;
for(count=0;count<3;){
printf("\nOut: %3d: ",count);
if(millis()>nextTime){
printf("\nOut: %3d: ",count);
fflush(stdout);
char in_recieved;/*what the Pi recieves from the module*/
/*Begin Here*/ //serialPrintf();
}
while(serialDataAvail(fd)){
printf(" -> %3d",serialGetchar(fd));
fflush(stdout);
}
count+=1;
}
return 0;
}
/dev/ttyAMA0
See How-do-i-make-serial-work-on-the-raspberry-pi3 – Milliways Feb 21 '18 at 04:14sudo apt-get install gpsd
thenman gpsd
. – joan Feb 21 '18 at 08:31