Skip to content

Commit

Permalink
add freq as squawk and xid specific
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatel3001 committed Mar 8, 2024
1 parent ef75ea2 commit 581ce8d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Under active development, everything is subject to change without notice.
| `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 also print a log entry for each non-position message. | Unset |
| `ACARS_FREQ_AS_SQUAWK`, `VDLM2_FREQ_AS_SQUAWK`, `HFDL_FREQ_AS_SQUAWK` | Set to any value to send the received frequency as the squawk value, for each incoming message type. | Unset |

## Docker Compose

Expand Down
17 changes: 14 additions & 3 deletions rootfs/scripts/acars2pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,22 @@ def thread_wrapper(func, *args):
continue

if sbs["type"] == "acars":
squawk = "1111"
if getenv("ACARS_FREQ_AS_SQUAWK"):
squawk = f"{round(sbs['freq']/1000-100000):d}"
else:
squawk = "1111"
elif sbs["type"] == "vdlm2":
squawk = "2222"
if getenv("VDLM2_FREQ_AS_SQUAWK"):
squawk = f"{round(sbs['freq']/1000-100000):d}"
elif sbs.get("xid"):
squawk = "2220"
else:
squawk = "2222"
elif sbs["type"] == "hfdl":
squawk = "3333"
if getenv("HFDL_FREQ_AS_SQUAWK"):
squawk = f"{round(sbs['freq']/1000):d}"
else:
squawk = "3333"
else:
squawk = "9999"

Expand Down
4 changes: 4 additions & 0 deletions rootfs/scripts/acars_decode/Decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def decodeACARS(msg):
dat["flight"] = msg.get("flight", "")
dat["txt"] = msg["text"]
dat["msgtype"] = msg["label"]
dat["freq"] = round(float(msg.get("freq", 0))*1000000)
return dat

def decodeVDLM2(msg):
Expand All @@ -262,12 +263,14 @@ def decodeVDLM2(msg):
dat = {}
dat["type"] = "vdlm2"
dat["time"] = int(msg["t"]["sec"])
dat["freq"] = int(msg.get("freq", 0))
if msg["avlc"].get("acars"):
dat["reg"] = msg["avlc"]["acars"].get("reg", "")
dat["flight"] = msg["avlc"]["acars"].get("flight", "")
dat["msgtype"] = msg["avlc"]["acars"].get("label", "")
dat["txt"] = msg["avlc"]["acars"].get("msg_text", "")
elif not (msg["avlc"].get("xid") is None or msg["avlc"]["xid"].get("vdl_params") is None):
dat["xid"] = True
dat["icao"] = msg["avlc"]["src"]["addr"]
for p in msg["avlc"]["xid"]["vdl_params"]:
if p["name"] == "ac_location":
Expand All @@ -292,6 +295,7 @@ def decodeHFDL(msg):
dat["type"] = "hfdl"
dat["time"] = int(msg["t"]["sec"])
dat["flight"] = msg["lpdu"].get("hfnpdu", {}).get("flight_id", "")
dat["freq"] = int(msg.get("freq", 0))
try:
dat["lat"] = msg["lpdu"]["hfnpdu"]["pos"]["lat"]
dat["lon"] = msg["lpdu"]["hfnpdu"]["pos"]["lon"]
Expand Down

0 comments on commit 581ce8d

Please sign in to comment.