Skip to content

Commit

Permalink
write gpsd.json when using gpsd_in
Browse files Browse the repository at this point in the history
for each message with lat / lon received from gpsd, the message is
written as is to gpsd.json
  • Loading branch information
wiedehopf committed May 23, 2024
1 parent 3dc36ea commit 545d2a4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3577,6 +3577,16 @@ static int handle_gpsd(struct client *c, char *p, int remote, int64_t now, struc
fprintf(stderr, " gpsdebug: received from GPSD: \'%s\'\n", p);
}

struct char_buffer msg;
char msg_buf[4096];
msg.alloc = 4096;
msg.buffer = msg_buf;
msg.len = 0;
if (strlen(p) < msg.alloc - 8) {
sprintf(msg.buffer, "%s\n", p);
msg.len = strlen(msg.buffer);
}

// remove spaces in place
char *d = p;
char *s = p;
Expand Down Expand Up @@ -3659,6 +3669,9 @@ static int handle_gpsd(struct client *c, char *p, int remote, int64_t now, struc

if (Modes.json_dir) {
free(writeJsonToFile(Modes.json_dir, "receiver.json", generateReceiverJson()).buffer); // location changed
if (msg.len) {
writeJsonToFile(Modes.json_dir, "gpsd.json", msg);
}
}

return 0;
Expand Down

0 comments on commit 545d2a4

Please sign in to comment.