This package is based on dump1090-fa with many modifications. A big advantage over dump1090-fa is that it can connect to multiple services like adsbexchange, piaware or fr24feed. As the idea for this package is mostly to feed other services, the HTML files to serve via a webserver have not been included. The service(s) that will be fed by readsb can offer such a webpage instead. Finally, the init script does not use local variables, as local is undefined in POSIX. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>lilik-openwrt-22.03
@ -0,0 +1,73 @@ | |||
# Copyright (C) 2020 Stijn Tintel <stijn@linux-ipv6.be> | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
include $(TOPDIR)/rules.mk | |||
PKG_NAME:=readsb | |||
PKG_VERSION:=3.8.3 | |||
PKG_RELEASE:=1 | |||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | |||
PKG_SOURCE_URL:=https://codeload.github.com/Mictronics/readsb/tar.gz/v$(PKG_VERSION)? | |||
PKG_HASH:=bf59b8ecd0ff66945b210c55a5b824aa63ff8cbb1704249528d30a4902e716b2 | |||
PKG_LICENSE:=GPL-3.0-or-later | |||
PKG_LICENSE_FILES:=COPYING LICENSE | |||
PKG_MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be> | |||
PKG_BUILD_DEPENDS:=!USE_GLIBC:argp-standalone | |||
PKG_BUILD_PARALLEL:=1 | |||
include $(INCLUDE_DIR)/package.mk | |||
define Package/readsb/default | |||
SECTION:=utils | |||
CATEGORY:=Utilities | |||
DEPENDS:=+libncurses | |||
TITLE:=Mode-S/ADSB/TIS decoder for various devices | |||
URL:=https://github.com/Mictronic/readsb | |||
endef | |||
define Package/readsb | |||
$(call Package/readsb/default) | |||
TITLE+= (readsb) | |||
DEPENDS+=+librtlsdr | |||
endef | |||
define Package/viewadsb | |||
$(call Package/readsb/default) | |||
TITLE+= (viewadsb) | |||
endef | |||
MAKE_FLAGS += \ | |||
BLADERF=no \ | |||
CFLAGS="$(TARGET_CFLAGS)" \ | |||
RTLSDR=yes \ | |||
UNAME="Linux" | |||
TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto | |||
TARGET_LDFLAGS += \ | |||
$(if $(CONFIG_LIBC_USE_GLIBC),,-largp) \ | |||
-Wl,--gc-sections,--as-needed | |||
define Package/readsb/conffiles | |||
/etc/config/readsb | |||
endef | |||
define Package/readsb/install | |||
$(INSTALL_DIR) $(1)/etc/{config,init.d} $(1)/usr/bin | |||
$(INSTALL_CONF) ./files/readsb.config $(1)/etc/config/readsb | |||
$(INSTALL_BIN) ./files/readsb.init $(1)/etc/init.d/readsb | |||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/readsb $(1)/usr/bin | |||
endef | |||
define Package/viewadsb/install | |||
$(INSTALL_DIR) $(1)/usr/bin | |||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/viewadsb $(1)/usr/bin | |||
endef | |||
$(eval $(call BuildPackage,readsb)) | |||
$(eval $(call BuildPackage,viewadsb)) |
@ -0,0 +1,46 @@ | |||
config readsb main | |||
option enabled '0' | |||
option beast_crc_off '0' | |||
option beast_df045_on '0' | |||
option beast_df1117_on '0' | |||
option beast_fec_off '0' | |||
option beast_mlat_off '0' | |||
option beast_modeac '0' | |||
option beast_serial '' | |||
option dcfilter '0' | |||
option debug '' | |||
option device '' | |||
option device_type '' | |||
option enable_agc '0' | |||
option enable_biastee '0' | |||
option fix '1' | |||
option freq '' | |||
option forward_mlat '0' | |||
option gain '' | |||
option gnss '0' | |||
option json_location_accuracy '' | |||
option lat '' | |||
option lon '' | |||
option max_range '' | |||
option metric '0' | |||
option mlat '0' | |||
option modeac '0' | |||
option net '1' | |||
option net_beast_reduce_interval '' | |||
option net_beast_reduce_out_port '' | |||
option net_bi_port '' | |||
option net_bind_address '' | |||
option net_bo_port '' | |||
option net_buffer '' | |||
list net_connector '' | |||
option net_only '0' | |||
option net_verbatim '0' | |||
option no_crc_check '0' | |||
option no_modeac_auto '0' | |||
option onlyaddr '0' | |||
option ppm '' | |||
option stats '0' | |||
option stats_every '' | |||
option stats_range '0' | |||
option write_json '' | |||
option write_json_every '' |
@ -0,0 +1,105 @@ | |||
#!/bin/sh /etc/rc.common | |||
START=90 | |||
STOP=10 | |||
USE_PROCD=1 | |||
append_bool() { | |||
config_get_bool tbool "$1" "$2" | |||
v=$(echo "$2" | sed 's/_/-/g') | |||
[ -z "$tbool" ] && tbool="$3" | |||
[ "$tbool" -eq 1 ] && procd_append_param command "--${v}" | |||
} | |||
append_bool_no() { | |||
config_get_bool tbool "$1" "$2" | |||
v=$(echo "$2" | sed 's/_/-/g') | |||
[ -z "$tbool" ] && tbool="$3" | |||
[ "$tbool" -eq 0 ] && procd_append_param command "--no-${v}" | |||
[ "$tbool" -eq 1 ] && procd_append_param command "--${v}" | |||
} | |||
append_param() { | |||
config_get tparam "$1" "$2" | |||
name=$(echo "$2" | sed 's/_/-/g') | |||
[ -n "$tparam" ] && procd_append_param command "--${name}=${tparam}" | |||
} | |||
start_instance() { | |||
cfg=$1 | |||
config_get_bool enabled "$cfg" "enabled" 0 | |||
[ "$enabled" -eq 1 ] || return 0 | |||
procd_open_instance "$cfg" | |||
procd_set_param command /usr/bin/readsb | |||
procd_append_param command "--quiet" | |||
procd_set_param respawn | |||
procd_set_param stderr "1" | |||
procd_set_param stdout "1" | |||
append_bool "$cfg" beast_crc_off 0 | |||
append_bool "$cfg" beast_df045_on 0 | |||
append_bool "$cfg" beast_df1117_on 0 | |||
append_bool "$cfg" beast_fec_off 0 | |||
append_bool "$cfg" beast_mlat_off 0 | |||
append_bool "$cfg" beast_modeac 0 | |||
append_bool "$cfg" dcfilter 0 | |||
append_bool "$cfg" enable_agc 0 | |||
append_bool "$cfg" enable_biastee 0 | |||
append_bool "$cfg" forward_mlat 0 | |||
append_bool "$cfg" gnss 0 | |||
append_bool "$cfg" metric 0 | |||
append_bool "$cfg" mlat 0 | |||
append_bool "$cfg" modeac 0 | |||
append_bool "$cfg" net 1 | |||
append_bool "$cfg" net_only 0 | |||
append_bool "$cfg" net_verbatim 0 | |||
append_bool "$cfg" no_crc_check 0 | |||
append_bool "$cfg" no_modeac_auto 0 | |||
append_bool "$cfg" onlyaddr 0 | |||
append_bool "$cfg" stats 0 | |||
append_bool "$cfg" stats_range 0 | |||
append_bool_no "$cfg" fix 1 | |||
for param in \ | |||
beast_serial \ | |||
debug \ | |||
device \ | |||
device_type \ | |||
freq \ | |||
gain \ | |||
json_location_accuracy \ | |||
lat \ | |||
lon \ | |||
max_range \ | |||
net_beast_reduce_interval \ | |||
net_beast_reduce_out_port \ | |||
net_bi_port \ | |||
net_bind_address \ | |||
net_bo_port \ | |||
net_buffer \ | |||
ppm \ | |||
stats_every \ | |||
write_json \ | |||
write_json_every | |||
do | |||
append_param "$cfg" "$param" | |||
done | |||
config_get net_connector "$cfg" "net_connector" | |||
[ -z "$net_connector" ] || { | |||
for conn in $net_connector; do | |||
procd_append_param command --net-connector="$conn" | |||
done | |||
} | |||
procd_close_instance | |||
} | |||
start_service() { | |||
config_load readsb | |||
config_foreach start_instance readsb | |||
} |
@ -0,0 +1,89 @@ | |||
From 82014a5fa9930b0875e57869265acf011772277c Mon Sep 17 00:00:00 2001 | |||
From: Stijn Tintel <stijn@linux-ipv6.be> | |||
Date: Sun, 3 May 2020 20:56:58 +0300 | |||
Subject: [PATCH] network: avoid segfault in freeaddrinfo | |||
Calling freeaddrinfo(NULL) when using musl libc causes a segfault. | |||
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> | |||
--- | |||
anet.c | 15 ++++++++++++--- | |||
net_io.c | 5 ++++- | |||
viewadsb.c | 5 ++++- | |||
3 files changed, 20 insertions(+), 5 deletions(-) | |||
diff --git a/anet.c b/anet.c | |||
index 5c35ff8..7f01958 100644 | |||
--- a/anet.c | |||
+++ b/anet.c | |||
@@ -212,7 +212,10 @@ static int anetTcpGenericConnect(char *err, char *addr, char *service, int flags | |||
if (ss) { | |||
memcpy(ss, p->ai_addr, sizeof(*ss)); | |||
} | |||
- freeaddrinfo(gai_result); | |||
+ if (gai_result) { | |||
+ freeaddrinfo(gai_result); | |||
+ gai_result = NULL; | |||
+ } | |||
return s; | |||
} | |||
@@ -220,7 +223,10 @@ static int anetTcpGenericConnect(char *err, char *addr, char *service, int flags | |||
anetCloseSocket(s); | |||
} | |||
- freeaddrinfo(gai_result); | |||
+ if (gai_result) { | |||
+ freeaddrinfo(gai_result); | |||
+ gai_result = NULL; | |||
+ } | |||
return ANET_ERR; | |||
} | |||
@@ -368,7 +374,10 @@ int anetTcpServer(char *err, char *service, char *bindaddr, int *fds, int nfds) | |||
fds[i++] = s; | |||
} | |||
- freeaddrinfo(gai_result); | |||
+ if (gai_result) { | |||
+ freeaddrinfo(gai_result); | |||
+ gai_result = NULL; | |||
+ } | |||
return (i > 0 ? i : ANET_ERR); | |||
} | |||
diff --git a/net_io.c b/net_io.c | |||
index 1f4d848..5f59194 100644 | |||
--- a/net_io.c | |||
+++ b/net_io.c | |||
@@ -3285,7 +3285,10 @@ void cleanupNetwork(void) { | |||
for (int i = 0; i < Modes.net_connectors_count; i++) { | |||
struct net_connector *con = Modes.net_connectors[i]; | |||
free(con->address); | |||
- freeaddrinfo(con->addr_info); | |||
+ if (con->addr_info) { | |||
+ freeaddrinfo(con->addr_info); | |||
+ con->addr_info = NULL; | |||
+ } | |||
if (con->mutex) { | |||
pthread_mutex_unlock(con->mutex); | |||
pthread_mutex_destroy(con->mutex); | |||
diff --git a/viewadsb.c b/viewadsb.c | |||
index 5fc5386..ad7b1bd 100644 | |||
--- a/viewadsb.c | |||
+++ b/viewadsb.c | |||
@@ -308,7 +308,10 @@ int main(int argc, char **argv) { | |||
} | |||
// Free local service and client | |||
if (s) free(s); | |||
- freeaddrinfo(con->addr_info); | |||
+ if (con->addr_info) { | |||
+ freeaddrinfo(con->addr_info); | |||
+ con->addr_info = NULL; | |||
+ } | |||
pthread_mutex_unlock(con->mutex); | |||
pthread_mutex_destroy(con->mutex); | |||
free(con->mutex); | |||
-- | |||
2.26.2 | |||