diff --git a/README.md b/README.md index d21d125..b3d23f7 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Under active development, everything is subject to change without notice. | `LON` | Longitude of receiver. Only required if `MAX_DISTANCE` > 0 | Unset | | `MAX_DIST` | Set this to a nonzero value to reject parsed positions that are too far away. Only applies to positions parsed from message text. | `0` | | `DIST_UNIT` | The unit of the value in `MAX_DIST`. One of `km`, `m`, `mi`, `nmi`, `ft`, `in`. | `nmi` | +| `SEND_ALL` | Set to any value to send SBS messages for messages without a position. Set to `log` to print a log entry for each non-position message. | Unset | ## Docker Compose diff --git a/rootfs/scripts/acars2pos.py b/rootfs/scripts/acars2pos.py index a960f8a..96fcb60 100755 --- a/rootfs/scripts/acars2pos.py +++ b/rootfs/scripts/acars2pos.py @@ -94,9 +94,6 @@ def thread_wrapper(func, *args): if sbs is None: continue - if not sbs.get("txt") and not sbs.get("lat"): - continue - if not sbs.get("reg"): sbs["reg"] = icao2reg(sbs.get("icao", "")) @@ -115,7 +112,7 @@ def thread_wrapper(func, *args): elif sbs["type"] == "hfdl": squawk = "3333" else: - squawk = "0000" + squawk = "9999" if sbs.get("lat"): lat = sbs["lat"] @@ -126,6 +123,16 @@ def thread_wrapper(func, *args): logfile.write(f'{sbs["lat"]}, {sbs["lon"]}\n') logfile.write(f'{sbs["txt"]}\n\n') else: + if s := getenv("SEND_ALL"): + out = f'MSG,3,1,1,{sbs["icao"].upper()},1,{datetime.fromtimestamp(sbs["time"], tz=timezone.utc):%Y/%m/%d,%T},{datetime.now(timezone.utc):%Y/%m/%d,%T},{sbs.get("flight", "")},,,,,,,{squawk},,,,' + if s == "log": + print(f"sending nonpos {out}") + for q in txqs: + q.put(out+"\r\n") + + if not sbs.get("txt"): + continue + if getenv("LOG_FILE") and sbs.get("msgtype") and sbs.get("type") != "hfdl": with open(f"/log/nopos.log", "a", 1) as logfile: logfile.write(f'{sbs["type"]}\t{sbs.get("msgtype")}\thttps://globe.adsbexchange.com/?icao={sbs["icao"]}&showTrace={datetime.fromtimestamp(sbs["time"], tz=timezone.utc):%Y-%m-%d}×tamp={sbs["time"]}\n') @@ -206,13 +213,9 @@ def thread_wrapper(func, *args): continue print(f'{sbs["type"]} {sbs.get("msgtype")}', file=stderr) -# print(pos, file=stderr) - out = f'MSG,3,1,1,{sbs["icao"].upper()},1,{datetime.fromtimestamp(sbs["time"], tz=timezone.utc):%Y/%m/%d,%T},{datetime.now(timezone.utc):%Y/%m/%d,%T},{sbs.get("flight", "")},,,,{lat:.3f},{lon:.3f},,{squawk},,,,' - print(f'https://globe.adsbexchange.com/?icao={sbs["icao"]}&showTrace={datetime.fromtimestamp(sbs["time"], tz=timezone.utc):%Y-%m-%d}×tamp={sbs["time"]}') print(f'{Fore.BLUE}{out}{Fore.RESET}\n', file=stderr) - for q in txqs: q.put(out+"\r\n") except BaseException: diff --git a/rootfs/scripts/acars_decode/Decoder.py b/rootfs/scripts/acars_decode/Decoder.py index 0ccca42..9dfc484 100644 --- a/rootfs/scripts/acars_decode/Decoder.py +++ b/rootfs/scripts/acars_decode/Decoder.py @@ -217,6 +217,7 @@ def decode(msg): print(f"regex {i} matched message type {dat['msgtype']}") print(pos) raw = rgx.search(dat["txt"]) + print(raw) if i == 0: dat["lat"] = float(raw[2]) * (-1 if raw[1] == "S" else 1) dat["lon"] = float(raw[4]) * (-1 if raw[3] == "W" else 1)