This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| sdk:gps-udp-client-gnsstogps [2019/07/08 13:56] – fachet | sdk:gps-udp-client-gnsstogps [2021/10/08 10:22] (current) – [SDK Script gps-udp-client-GNSStoGPS.are] dodenhoeft | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Background ====== | ||
| + | GPS was the first Global Navigation Satellite System (GNSS) and the term GPS is often used as a synonym for GNSS. | ||
| + | |||
| + | Older software often only checks for NMEA 0183 sentences starting with < | ||
| + | |||
| + | Newer GNSS receivers often use multiple GNSS systems and therefore < | ||
| + | |||
| + | It would be better to us instead of < | ||
| + | |||
| + | < | ||
| + | NMEA 0183 sentence " | ||
| + | |||
| + | " | ||
| + | " | ||
| + | BD = Beidu | ||
| + | GA = Galileo | ||
| + | GL = GLONASS | ||
| + | GP = GPS | ||
| + | GN = GNSS position fix from more than one constellation (eg. GPS + GLONASS) | ||
| + | " | ||
| + | RMC = Recommended Minimum Sentence C (used in most cases) | ||
| + | GGA = Global Positioning System Fix Data | ||
| + | GNS = GNSS fixed data | ||
| + | GLL = Geographic Position - Latitude/ | ||
| + | ... | ||
| + | |||
| + | Source: https:// | ||
| + | </ | ||
| + | |||
| ====== SDK Script gps-udp-client-GNSStoGPS.are ====== | ====== SDK Script gps-udp-client-GNSStoGPS.are ====== | ||
| + | <code c gps-udp-client-gnsstogps.are> | ||
| /* DESC: This script sends the local GPS NMEA stream to a remote UDP server. | /* DESC: This script sends the local GPS NMEA stream to a remote UDP server. | ||
| * DESC: It checks for the correct CR/LF end of line characters and convert messages $GN to $GP | * DESC: It checks for the correct CR/LF end of line characters and convert messages $GN to $GP | ||
| Line 22: | Line 52: | ||
| nb_config_set(" | nb_config_set(" | ||
| - | sleep(3); | + | do { |
| + | | ||
| + | } while ( nb_config_done() != 0) | ||
| + | |||
| nb_config_set(" | nb_config_set(" | ||
| - | sleep(5); | + | do { |
| + | | ||
| + | } while ( nb_config_done() != 0) | ||
| return 0; | return 0; | ||
| } | } | ||
| - | |||
| int gpsd_connect () | int gpsd_connect () | ||
| { | { | ||
| Line 38: | Line 71: | ||
| exit(-1); | exit(-1); | ||
| } | } | ||
| - | for (attempt = 0; attempt <= 5; attempt++) { | + | for (attempt = 0; attempt <= 15; attempt++) { |
| - | sleep(3); | + | sleep(15); |
| if (connect(gpsd, | if (connect(gpsd, | ||
| nb_syslog(" | nb_syslog(" | ||
| - | if (attempt == 3) { | + | if (attempt == 12) { |
| nb_syslog(" | nb_syslog(" | ||
| gpsd_restart(); | gpsd_restart(); | ||
| Line 52: | Line 85: | ||
| } | } | ||
| nb_syslog(" | nb_syslog(" | ||
| - | send(gpsd," | + | send(gpsd, " |
| nb_syslog(" | nb_syslog(" | ||
| return gpsd; | return gpsd; | ||
| + | } | ||
| + | |||
| + | string checksum(string s) | ||
| + | { | ||
| + | pos = strchr(s, " | ||
| + | |||
| + | if (is_void(pos)) | ||
| + | return s; /* no checksum to correct */ | ||
| + | |||
| + | cs = 0; | ||
| + | chars = explode(s); | ||
| + | for (i = 1; i < pos; i++) { /* skip $ and *XX */ | ||
| + | c = ord(chars[i]); | ||
| + | cs ^= c; | ||
| + | } | ||
| + | r = sprintf(" | ||
| + | return r; | ||
| } | } | ||
| Line 70: | Line 120: | ||
| /* open UDP server socket */ | /* open UDP server socket */ | ||
| server = socket(AF_INET, | server = socket(AF_INET, | ||
| - | if(server < 0) { | + | if (server < 0) { |
| nb_syslog(" | nb_syslog(" | ||
| exit(-1); | exit(-1); | ||
| Line 104: | Line 154: | ||
| data = recv(gpsd); | data = recv(gpsd); | ||
| len = strlen(data); | len = strlen(data); | ||
| - | printf(" | ||
| /* Check for correct framing: CR+LF */ | /* Check for correct framing: CR+LF */ | ||
| if(len > 2) { | if(len > 2) { | ||
| Line 123: | Line 172: | ||
| } | } | ||
| /* Convert message $GN to $GP for backward compatibility */ | /* Convert message $GN to $GP for backward compatibility */ | ||
| - | printf(" | ||
| if(strstr(data, | if(strstr(data, | ||
| a_arr = explode(data); | a_arr = explode(data); | ||
| a_arr[2] = " | a_arr[2] = " | ||
| - | data = implode(a_arr); | + | data = checksum(implode(a_arr)); |
| } | } | ||
| - | printf(" | ||
| /* skip all messages different from GPGGA | /* skip all messages different from GPGGA | ||
| * if(strstr(data," | * if(strstr(data," | ||