meta-sysmocom-bsp/recipes-extra/gpsd/gpsd/0001-gps2udp-Add-a-label-ti...

157 lines
5.4 KiB
Diff
Raw Normal View History

gpsd: upgrade to 3.24 Usually when upgrading packages, we just copy the upstream package and adjust it slightly. I've looked at the upstream package here: https://git.openembedded.org/meta-openembedded/tree/meta-oe/recipes-navigation/gpsd (HEAD at f3d14d41ad60d2d52a0ea795ae10fe0882146ed1) But as I compared both packaging trees, I found ours is quite different than upstream. We have a lot of additional patches, still use python2 and have these extra files: ├── gpsd │ ├── 60-gpsd.rules │ ├── gpsd │ ├── gpsd-default │ ├── gpsd.service │ ├── oc2g │ │ ├── gpsd-default │ │ └── gpsd.service │ ├── sysmobts2100 │ │ └── gpsd-default │ ├── sysmobts-v2 │ │ └── gpsd-default │ └── sysmocom-idu │ └── gpsd-default Therefore I didn't start with the upstream packaging but instead increased the gpsd version in our packaging and went through each patch to see if it can be dropped or needs to be forward ported. Change the version by renaming the .bb file. Reset the version of the recipe (PR) back to "r0" again, as it is common practice after changing the package version. The previous value "r3.20" looked a bit like a package version, but it's not that. Rebase patches: * 0001-gps2udp-Add-a-label-timestamp-and-mac-address-to-eac.patch * 0002-gps2udp-leave-argv-untouched.patch (leave-argv-untouched.patch) * 0003-tsip-configure-and-enable-1PPS.patch (gpsd-tsip-pps.patch) Add build fixes: * 0004-SConscript-force-use-of-pthread.patch Drop patches: * 0001-SConstruct-prefix-includepy-with-sysroot-and-drop-sy.patch: unused in previous version * 0001-SConstruct-disable-html-and-man-docs-building-becaus.patch: doesn't apply, instead disable docs building via manbuild='no' * 0002-SConstruct-respect-sysroot-also-in-SPLINTOPTS.patch: not needed anymore (no splintopts line in 3.24) * gpsd-3.3-ldflags.patch: fixed upstream * no-rpath-please.patch: doesn't apply, not needed anymore (see 5df2de36 in gpsd.git) Related: https://docs.yoctoproject.org/bitbake/2.2/bitbake-user-manual/bitbake-user-manual-ref-variables.html#term-PR Related: SYS#6222 Change-Id: I2debe481c5f1cc4ee8290ad0dc883d6a4ea73741
2022-12-13 12:28:40 +00:00
From cd89f0b340764e73de76f5297217caf61b3d3283 Mon Sep 17 00:00:00 2001
From: Oliver Smith <osmith@sysmocom.de>
Date: Tue, 13 Dec 2022 16:05:00 +0100
Subject: [PATCH] gps2udp: Add a label, timestamp and mac address to each
report
Rebase of 0001-gps2udp-Add-a-label-timestamp-and-mac-address-to-eac.patch
we have been carrying:
From 19a55075d4e60e07d03d49937cd2a4d9239d00a4 Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <hfreyther@sysmocom.de>
Date: Fri, 22 Aug 2014 09:55:19 +0200
Subject: [PATCH] gps2udp: Add a label, timestamp and mac address to each
report
---
clients/gps2udp.c | 61 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/clients/gps2udp.c b/clients/gps2udp.c
index 2d9c6033d..d27814f24 100644
--- a/clients/gps2udp.c
+++ b/clients/gps2udp.c
@@ -22,6 +22,7 @@
#include <getopt.h> // for getopt_long()
#endif
#include <netdb.h> /* for gethostbyname() */
+#include <net/if.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdio.h>
@@ -29,6 +30,7 @@
// do not use strsep() it is not POSIX
#include <string.h> /* for strlcpy(), strtok(), etc. */
#include <strings.h>
+#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -60,6 +62,9 @@ static unsigned int flags;
static unsigned int debug = 0;
static bool aisonly = false;
static bool tpvonly = false;
+static const char *label;
+static const char *mac;
+static char *mac_string;
// return local time hh:mm:ss
static char* time2string(void)
@@ -82,6 +87,7 @@ static char* time2string(void)
static int send_udp(char *nmeastring, size_t ind)
{
+ char output[1024];
char message[MAX_PACKET_LENGTH];
char *buffer;
int channel;
@@ -108,6 +114,16 @@ static int send_udp(char *nmeastring, size_t ind)
buffer[ind] = '\n'; ind++;
buffer[ind] = '\0';
+ /* copy once more for the label */
+ if (label)
+ snprintf(output, 1024, "%s,%llu,%s,%s",
+ label, (unsigned long long ) time(NULL), mac_string, buffer);
+ else
+ snprintf(output, 1024, "%s", buffer);
+
+ output[1023] = '\0';
+ ind = strlen(output);
+
if (0 == (flags & WATCH_JSON) &&
'{' == buffer[0]) {
// do not send JSON when not configured to do so
@@ -129,7 +145,7 @@ static int send_udp(char *nmeastring, size_t ind)
// send message on udp channel
for (channel=0; channel < udpchannel; channel ++) {
ssize_t status = sendto(sock[channel],
- buffer,
+ output,
ind,
0,
(struct sockaddr *)&remote[channel],
@@ -225,6 +241,8 @@ static void usage(void)
" -c COUNT Exit after count packets.\n"
" -d [0-2] 1 display sent packets, "
"2 display ignored packets.\n"
+ " -l [NAME] A label to be used for the output\n"
+ " -m [IF_NAME] The interface to extract the mac from\n"
" -h Show this help.\n"
" -j Feed JSON.\n"
" -n Feed NMEA.\n"
@@ -421,7 +439,7 @@ int main(int argc, char **argv)
bool daemonize = false;
long count = -1;
char *udphostport[MAX_UDP_DEST];
- const char *optstring = "?abc:d:hjntu:V";
+ const char *optstring = "?abc:d:l:m:hjntu:V";
#ifdef HAVE_GETOPT_LONG
int option_index = 0;
static struct option long_options[] = {
@@ -478,6 +496,12 @@ int main(int argc, char **argv)
if (0 < debug)
(void)fprintf(stdout, "Debug %u selected\n", debug);
break;
+ case 'l':
+ label = optarg;
+ break;
+ case 'm':
+ mac = optarg;
+ break;
case 'j':
if (0 < debug)
(void)fprintf(stdout, "JSON selected\n");
@@ -520,6 +544,39 @@ int main(int argc, char **argv)
}
}
+ if (label && !mac) {
+ fprintf(stderr, "Need to specify the ethernet device to find the mac.\n");
+ exit(EXIT_FAILURE);
+ }
+ if (mac && strlen(mac) >= IFNAMSIZ) {
+ fprintf(stderr, "Interface name is too long.\n");
+ exit(EXIT_FAILURE);
+ } else if (mac) {
+ struct ifreq addr = { };
+ int fd, rc;
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ fprintf(stderr, "Failed to open socket.\n");
+ exit(EXIT_FAILURE);
+ }
+ memcpy(&addr.ifr_name, mac, strlen(mac));
+ rc = ioctl(fd, SIOCGIFHWADDR, &addr);
+ close(fd);
+ if (rc < 0) {
+ fprintf(stderr, "Failed to query address.\n");
+ exit(EXIT_FAILURE);
+ }
+ mac_string = malloc(40 * sizeof(char));
+ snprintf(mac_string, 40,
+ "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
+ addr.ifr_hwaddr.sa_data[0] & 0xff,
+ addr.ifr_hwaddr.sa_data[1] & 0xff,
+ addr.ifr_hwaddr.sa_data[2] & 0xff,
+ addr.ifr_hwaddr.sa_data[3] & 0xff,
+ addr.ifr_hwaddr.sa_data[4] & 0xff,
+ addr.ifr_hwaddr.sa_data[5] & 0xff);
+ }
+
// Grok the server, port, and device.
if (optind < argc) {
gpsd_source_spec(argv[optind], &gpsd_source);
--
2.34.1