GPS distribution via Alfred
PATCH 1/1 GPS distribution via Alfred
Hi Folks
I'm working on a mesh project with some nodes which are nomadic. I need to know the location of each node, so i can do map overlays. So these nomadic nodes have GPS and i'm distributing the location information over Alfred, with a new server/client binary. I also have stationary nodes, and a simulation system, without GPS, so i have support for passing location via the command line.
The code needs some more testing, a man page, but release early, release often, so here it is.
Comment welcome.
Andrew
Andrew Lunn (1):
alfred: Add support for passing location information over alfred.
CHANGELOG | 3 + Makefile | 24 ++- README | 52 +++++- gpsd/Makefile | 81 ++++++++ gpsd/alfred-gpsd.c | 529 +++++++++++++++++++++++++++++++++++++++++++++++++++++ gpsd/alfred-gpsd.h | 102 +++++++++++ 6 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 gpsd/Makefile create mode 100644 gpsd/alfred-gpsd.c create mode 100644 gpsd/alfred-gpsd.h
Signature · 1 line
1.8.4.rc3
PATCH 1/1 alfred: Add support for passing location information over alfred.
--- CHANGELOG | 3 + Makefile | 24 ++- README | 52 +++++- gpsd/Makefile | 81 ++++++++ gpsd/alfred-gpsd.c | 529 +++++++++++++++++++++++++++++++++++++++++++++++++++++ gpsd/alfred-gpsd.h | 102 +++++++++++ 6 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 gpsd/Makefile create mode 100644 gpsd/alfred-gpsd.c create mode 100644 gpsd/alfred-gpsd.h
CHANGELOG +3 -0
@@ -11,3 +11,6 @@ alfred 2013.3.0: * exchanges data via IPv6 unicast/multicast -- Sun, 28 Jul 2013 18:56:52 +0200 + + * Add support for distributing geographic location information, + either fixed, or read from gpsd.
Makefile +20 -4
@@ -64,9 +64,15 @@ ifneq ($(CONFIG_ALFRED_VIS),n) VIS_INSTALL=vis-install endif +ifneq ($(CONFIG_ALFRED_GPSD),n) + GPSD_ALL=gpsd-all + GPSD_CLEAN=gpsd-clean + GPSD_INSTALL=gpsd-install +endif + # default target -all: $(BINARY_NAME) $(VIS_ALL) +all: $(BINARY_NAME) $(VIS_ALL) $(GPSD_ALL) # standard build rules .SUFFIXES: .o .c
@@ -76,10 +82,10 @@ all: $(BINARY_NAME) $(VIS_ALL) $(BINARY_NAME): $(OBJ) $(LINK.o) $^ $(LDLIBS) -o $@ -clean: $(VIS_CLEAN) +clean: $(VIS_CLEAN) $(GPSD_CLEAN) $(RM) $(BINARY_NAME) $(OBJ) $(DEP) -install: $(BINARY_NAME) $(VIS_INSTALL) +install: $(BINARY_NAME) $(VIS_INSTALL) $(GPSD_INSTALL) $(MKDIR) $(DESTDIR)$(SBINDIR) $(MKDIR) $(DESTDIR)$(MANDIR)/man8 $(INSTALL) -m 0755 $(BINARY_NAME) $(DESTDIR)$(SBINDIR)
@@ -94,8 +100,18 @@ vis-all: vis-clean: $(MAKE) -C vis clean +gpsd-install: + $(MAKE) -C gpsd install + +gpsd-all: + $(MAKE) -C gpsd all + +gpsd-clean: + $(MAKE) -C gpsd clean + # load dependencies DEP = $(OBJ:.o=.d) -include $(DEP) -.PHONY: all clean install vis-install vis-all vis-clean +.PHONY: all clean install vis-install vis-all vis-clean \ + gpsd-install gpsd-all gpsd-clean
README +49 -3
77 lines not on this page · raw message
gpsd/Makefile new file +81 -0
81 lines not on this page · raw message
gpsd/alfred-gpsd.c new file +529 -0
529 lines not on this page · raw message
gpsd/alfred-gpsd.h new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
1.8.4.rc3
Re: [B.A.T.M.A.N.] [PATCHv1] alfred: Add support for passing location information over alfred.
Hello Andrew (and the rest of the list),
Quoted 38 lines · Andrew Lunn
README +31
-0+Alfred-gpsd +----------- + +Alfred-gpsd can be used to distibute GPS location information about +your batman-adv mesh network. This information could be, for example, +combined with Vis to visualize your mesh topology with true geographic +layout. For mobile or nomadic nodes, Alfred-gpsd, can get location +information from gpsd. Alternatively, a static location can be passed +on the command line, which is useful for static nodes without a GPS. + +Alfred-gpsd, similar to to alfred, combines server (daemon) and client +functionality in the 'alfred-gpsd' binary. The alfred-gpsd server must +be started to distribute location information. When retrieving +location information from gpsd, it should be started with: + + $ alfred-gpsd -s + +For a static location, use: + + $ alfred-gpsd -s -l 48.858222,2.2945,358 + +This server will set the location in alfred via unix +socket. Obviously, the alfred server must run too to get this +information set. When using gpsd, it updates alfred every 2 +seconds. With a static location, the update it made every 5 minutes. + +To get JSON formatted output, use: + + $ alfred-gpsd +[ + { "source" : "f6:00:48:13:d3:1e", "tpv" :{"class":"TPV","tag":"RMC","device":"/dev/ttyACM0","mode":3,"time":"2013-10-01T10:43:20.000Z","ept":0.005,"lat":52.575485000,"lon":-1.339716667,"alt":122.500,"epx":10.199,"epy":15.720,"epv":31.050,"track":0.0000,"speed":0.010,"climb":0.000,"eps":31.44} },
+ { "source" : "8e:4c:77:b3:65:b4", "tpv" :
{"class":"TPV","device":"command
line","time":"2013-10-01T10:43:05.129Z","lat":48.858222,"lon":2.2945,"alt":358.000000,"mode":3}
}
+]
Review
Quoted 2 lines
(quoted diff) +2
-0+ +See gpsd_json(5) for documentation of the tpv object.
As there are many different ways to display GPS coordinates, I suggest adding the format in which the data will be reported to the documentation.
In my time playing with gps positioning (just a couple of weeks), I've run into at least 4 different latitude/longitude formats, most of which look very much alike, but all of which are incompatible with each other, so it's important to know which format is used.
Specifically, gpsd parses (standard) NMEA messages, which give position as hybrid of integer degrees and decimal arc minutes (ddmm.mmmm) followed by a direction (NSEW).
When displayed in raw mode, gpsd will return these NMEA formatted values; the JSON output however (which is used) returns pure decimal degrees (dd.dddddd), with the sign specifying direction (NW are positive, SE are negative if I'm not mistaking).
I know the format is specified in the gpsd_json man page (which is referenced), but it seems more user-friendly to me to have the output format described here as well.
Seeing as there is a member gpsd_format, I'm assuming this is meant to allow for different formatting in the future, which makes it even more important to explicitly state how the values are formatted.
Other than that, this looks very promising.
Signature · 6 lines
Thijs van Veen [email protected] -- http://www.fastmail.fm - Does exactly what it says on the tin
Re: [B.A.T.M.A.N.] [PATCHv1] alfred: Add support for passing location information over alfred.
Quoted 39 lines · Thijs van Veen
Hello Andrew (and the rest of the list),
Quoted 36 lines · Andrew Lunn
README +31
-0+Alfred-gpsd +----------- + +Alfred-gpsd can be used to distibute GPS location information about +your batman-adv mesh network. This information could be, for example, +combined with Vis to visualize your mesh topology with true geographic +layout. For mobile or nomadic nodes, Alfred-gpsd, can get location +information from gpsd. Alternatively, a static location can be passed +on the command line, which is useful for static nodes without a GPS. + +Alfred-gpsd, similar to to alfred, combines server (daemon) and client +functionality in the 'alfred-gpsd' binary. The alfred-gpsd server must +be started to distribute location information. When retrieving +location information from gpsd, it should be started with: + + $ alfred-gpsd -s + +For a static location, use: + + $ alfred-gpsd -s -l 48.858222,2.2945,358 + +This server will set the location in alfred via unix +socket. Obviously, the alfred server must run too to get this +information set. When using gpsd, it updates alfred every 2 +seconds. With a static location, the update it made every 5 minutes. + +To get JSON formatted output, use: + + $ alfred-gpsd +[ + { "source" : "f6:00:48:13:d3:1e", "tpv" :{"class":"TPV","tag":"RMC","device":"/dev/ttyACM0","mode":3,"time":"2013-10-01T10:43:20.000Z","ept":0.005,"lat":52.575485000,"lon":-1.339716667,"alt":122.500,"epx":10.199,"epy":15.720,"epv":31.050,"track":0.0000,"speed":0.010,"climb":0.000,"eps":31.44} },
+ { "source" : "8e:4c:77:b3:65:b4", "tpv" :
{"class":"TPV","device":"command
line","time":"2013-10-01T10:43:05.129Z","lat":48.858222,"lon":2.2945,"alt":358.000000,"mode":3}
Quoted 8 lines
Review
Quoted 4 lines
}
+](quoted diff) +2
-0+ +See gpsd_json(5) for documentation of the tpv object.As there are many different ways to display GPS coordinates, I suggest adding the format in which the data will be reported to the documentation.
This would be quite a bit of information, so i would probably put in into an alfred-gpsd specific README, not the Alfred README.
Quoted 13 lines
In my time playing with gps positioning (just a couple of weeks), I've run into at least 4 different latitude/longitude formats, most of which look very much alike, but all of which are incompatible with each other, so it's important to know which format is used.
Specifically, gpsd parses (standard) NMEA messages, which give position as hybrid of integer degrees and decimal arc minutes (ddmm.mmmm) followed by a direction (NSEW).
When displayed in raw mode, gpsd will return these NMEA formatted values; the JSON output however (which is used) returns pure decimal degrees (dd.dddddd), with the sign specifying direction (NW are positive, SE are negative if I'm not mistaking).
Quoted 3 lines
I know the format is specified in the
gpsd_jsonman page (which is referenced), but it seems more user-friendly to me to have the output format described here as well.
The gpsd_json documentation is not very specific:
├───────┼─────────┼─────────┼────────────────────────┤
│lat │ No │ numeric │ Latitude in degrees: │
│ │ │ │ +/- signifies │
│ │ │ │ West/East. Present │
│ │ │ │ when mode is 2 │
│ │ │ │ or 3. │
├───────┼─────────┼─────────┼────────────────────────┤
│lon │ No │ numeric │ Longitude in degrees: │
│ │ │ │ +/- signifies │
│ │ │ │ North/South. Present │
│ │ │ │ when mode is 2 │
│ │ │ │ or 3. │
├───────┼─────────┼─────────┼────────────────────────┤It just says degrees, not "pure" degrees, "not hybrid" degrees, etc. So importing the gpsd documentation does not really clarify it more. I'm also hesitant to add additional documentation, above what gpsd_json says. I've just implemented a "dumb pipe". I don't interpret the data in any way, i don't guarantee that the format will never change etc.
Quoted 3 lines
Seeing as there is a member
gpsd_format, I'm assuming this is meant to allow for different formatting in the future, which makes it even more important to explicitly state how the values are formatted.
No, that is not why i added the tpv gpsd_format. I will probably need the ATT, the vehicle-attitude report, to report what direction my directional antennae are pointing. I've no intentional of adding other location formats, eg raw NMEA. That just added complexity i don't want to handle.
Quoted 1 line
Other than that, this looks very promising.
Thanks
Andrew
Re: [B.A.T.M.A.N.] [PATCHv1] alfred: Add support for passing location information over alfred.
In reply to Andrew LunnQuoted 17 lines · Andrew Lunn
--- CHANGELOG | 3 + Makefile | 24 ++- README | 52 +++++- gpsd/Makefile | 81 ++++++++ gpsd/alfred-gpsd.c | 529 +++++++++++++++++++++++++++++++++++++++++++++++++++++ gpsd/alfred-gpsd.h | 102 +++++++++++ 6 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 gpsd/Makefile create mode 100644 gpsd/alfred-gpsd.c create mode 100644 gpsd/alfred-gpsd.hCHANGELOG +0
-0
CHANGELOG alfred 2013.3.0: · line 16
Quoted 6 lines
CHANGELOG +3
-0@@ -11,3 +11,6 @@ alfred 2013.3.0: * exchanges data via IPv6 unicast/multicast -- Sun, 28 Jul 2013 18:56:52 +0200 + + * Add support for distributing geographic location information, + either fixed, or read from gpsd.
I'd like to do the CHANGELOG the other way around, e.g. newest entries come first - and your changes will not be released in 2013.3.0 or before. :)
Please just drop this change as I'll compile the CHANGELOG when releasing myself anyway. No need to bother. :)
Quoted 22 lines
\ No newline at end of file
[...]gpsd/Makefile new file +17
-0@@ -0,0 +1,81 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# +# Copyright (C) 2013 B.A.T.M.A.N. contributors +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
gpsd/Makefile line 27
Quoted 10 lines
gpsd/Makefile new file +10
-0+# 02110-1301, USA +# + +# alfred build +BINARY_NAME = alfred-gpsd +OBJ = alfred-gpsd.o + +# alfred flags and options +CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP +LDLIBS += -lgps
I have no idea if we need some special handling for this to let it work for crosscompiling, OpenWRT etc?
Quoted 4 lines
gpsd/Makefile new file +4
-0+ +# disable verbose output +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V
gpsd/Makefile
Quoted 10 lines
gpsd/Makefile new file +9
-0+ Q_CC = @echo ' ' CC $@; + Q_LD = @echo ' ' LD $@; + export Q_CC + export Q_LD +endif +endif + + if ((alt < -1000) || (lon > 9000)) { + /* No support for aircraft or submarines! */
Too bad :D
I haven't tested this, but I like the idea to transport the gpsd information. We will probably seperate the package to let OpenWRT users choose if they want to have this feature (because it comes with gpsd dependency), just as we have done with vis. TBH I didn't expect to fill the alfred repository with feature daemons, but as long as it is maintained, why not. :)
Thanks,
Simon
Re: [B.A.T.M.A.N.] [PATCHv1] alfred: Add support for passing location information over alfred.
Quoted 10 lines · On Wednesday 02 October 2013 06:19:15 Simon Wunderlich wrote:
gpsd/Makefile line 27
Quoted 7 lines
gpsd/Makefile new file +7
-0+# alfred build +BINARY_NAME = alfred-gpsd +OBJ = alfred-gpsd.o + +# alfred flags and options +CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP +LDLIBS += -lgpsI have no idea if we need some special handling for this to let it work for crosscompiling, OpenWRT etc?
Please use pkg-config for things like this. An example Makefile is attached.
@Simon: Please fix your e-mail adress inside the README file.
Kind regards,
Sven
#!/usr/bin/make -f
# -*- makefile -*-
#
# Copyright (C) 2013 B.A.T.M.A.N. contributors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public # License as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA #
# alfred build BINARY_NAME = alfred-gpsd OBJ = alfred-gpsd.o
# alfred flags and options CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP
# disable verbose output ifneq ($(findstring $(MAKEFLAGS),s),s) ifndef V Q_CC = @echo ' ' CC $@; Q_LD = @echo ' ' LD $@; export Q_CC export Q_LD endif endif
ifeq ($(origin PKG_CONFIG), undefined)
PKG_CONFIG = pkg-config
ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),)
$(error $(PKG_CONFIG) not found)
endif
endif
ifeq ($(origin LIBGPS_CFLAGS) $(origin LIBGPS_LDLIBS), undefined undefined)
LIBGPS_NAME ?= libgps
ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBGPS_NAME) 2>/dev/null),)
$(error No $(LIBGPS_NAME) development libraries found!)
endif
LIBGPS_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBGPS_NAME)) LIBGPS_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBGPS_NAME))
endif
CFLAGS += $(LIBGPS_CFLAGS)
LDLIBS += $(LIBGPS_LDLIBS)
# standard build tools CC ?= gcc RM ?= rm -f INSTALL ?= install MKDIR ?= mkdir -p COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c LINK.o = $(Q_LD)$(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH)
# standard install paths PREFIX = /usr/local SBINDIR = $(PREFIX)/sbin
# try to generate revision REVISION= $(shell if [ -d ../.git ]; then \ echo $$(git describe --always --dirty --match "v*" |sed 's/^v//' 2> /dev/null || echo "[unknown]"); \ fi) ifneq ($(REVISION),) CPPFLAGS += -DSOURCE_VERSION=\"$(REVISION)\" endif
# default target all: $(BINARY_NAME)
# standard build rules .SUFFIXES: .o .c .c.o: $(COMPILE.c) -o $@ $<
$(BINARY_NAME): $(OBJ)
$(LINK.o) $^ $(LDLIBS) -o $@
clean:
$(RM) $(BINARY_NAME) $(OBJ) $(DEP)
install: $(BINARY_NAME)
$(MKDIR) $(DESTDIR)$(SBINDIR) $(INSTALL) -m 0755 $(BINARY_NAME) $(DESTDIR)$(SBINDIR)
# load dependencies DEP = $(OBJ:.o=.d) -include $(DEP)
.PHONY: all clean install
Re: [B.A.T.M.A.N.] [PATCHv1] alfred: Add support for passing location information over alfred.
Quoted 12 lines · Sven Eckelmann
Quoted 10 lines · On Wednesday 02 October 2013 06:19:15 Simon Wunderlich wrote:
gpsd/Makefile line 27
Quoted 7 lines
gpsd/Makefile new file +7
-0+# alfred build +BINARY_NAME = alfred-gpsd +OBJ = alfred-gpsd.o + +# alfred flags and options +CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP +LDLIBS += -lgpsI have no idea if we need some special handling for this to let it work for crosscompiling, OpenWRT etc?
Quoted 1 line
Please use pkg-config for things like this. An example
Makefileis attached.
Hi Sven
Thanks for the Makefile. Works on my Debian system.
Andrew
Re: [B.A.T.M.A.N.] [PATCHv1] alfred: Add support for passing location information over alfred.
In reply to Sven EckelmannQuoted 12 lines · Sven Eckelmann
Quoted 10 lines · On Wednesday 02 October 2013 06:19:15 Simon Wunderlich wrote:
gpsd/Makefile line 27
Quoted 7 lines
gpsd/Makefile new file +7
-0+# alfred build +BINARY_NAME = alfred-gpsd +OBJ = alfred-gpsd.o + +# alfred flags and options +CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP +LDLIBS += -lgpsI have no idea if we need some special handling for this to let it work for crosscompiling, OpenWRT etc?
Quoted 3 lines
Please use pkg-config for things like this. An example
Makefileis attached.@Simon: Please fix your e-mail adress inside the README file.
Done, applied in 9021511.
Thanks for pointing that out.
Simon