Skip to content

Commit

Permalink
Merge pull request #13 from ianrenton/feature/exclude-sar
Browse files Browse the repository at this point in the history
Option to exclude SAR aircraft
  • Loading branch information
jvde-github authored Jul 28, 2024
2 parents e61e8f1 + e256baf commit 3d5ef4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ AIS2ADSB v0.14- see https://github.com/jvde-github/ais2adsb
Usage: (python) ais2adsb.py <AIS UDP address> <AIS UDP IP> <AIS UDP port> <SBS TCP IP> <SBS TCP port> <options>
Options:
FILE xxxx : read mmsi <-> ICAO mapping from file xxxx
SAR on/off : include SAR aircraft in sendout
SHIPS on/off : include ships in sendout
CALLSIGN on/off : include generated callsigns in sendout
PRINT on/off : print mmsi/ICAO dictionary
Expand All @@ -34,7 +35,7 @@ AIS-catcher -u 192.168.1.235 4002 .....

There are only a few options. The `FILE` setting will read in a file with a Python Dictionary that maps MMSI numbers to 24-bit ICAO numbers. The Dictionary functionality allows the user to let the program use a pre-defined mapping. If not provided ais2adsb will auto generate ICAO numbers of the form `FXXXXX` based on the MMSI number or from a default dictionary embedded in the program. The `PRINT on` option will trigger dumping the Dictionary to stderr periodically (so it can be put back in via the FILE option if desired)

The SHIPS setting (on/off, default is off) will instruct the program to also include vessels in the sendout. By default only SAR Aircraft broadcasting AIS message type 9 are included. A callsign based on MMSI will be included by default, unless the option `CALLSIGN off` is given. A full example is:
The SAR setting (on/off, default is on) will instruct the program to also include SAR aircraft in the sendout. By default only SAR Aircraft broadcasting AIS message type 9 are included. The SHIPS setting (on/off, default is off) will instruct the program to also include vessels in the sendout. A callsign based on MMSI will be included by default, unless the option `CALLSIGN off` is given. A full example is:
```
python3 ./ais2adsb.py 192.168.1.235 4002 192.168.1.239 30003 SHIPS on FILE mapping.dict PRINT on CALLSIGN off
```
Expand Down
11 changes: 8 additions & 3 deletions ais2adsb.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
419000764:0x8006A0, 211340860:0x3EAF56, 32039:0x320069
}

settings = {"DICT_FILE": None, "SERVER_IP":"", "SERVER_PORT": 0, "UDP_IP":"" , "UDP_PORT":0, "includeShips":False, "includeCallSign": True, "printDict": False }
settings = {"DICT_FILE": None, "SERVER_IP":"", "SERVER_PORT": 0, "UDP_IP":"" , "UDP_PORT":0, "includeSAR":True, "includeShips":False, "includeCallSign": True, "printDict": False }

client_socket = None
sent = 0
Expand Down Expand Up @@ -177,6 +177,7 @@ def printUsage():
print("Usage: (python) ais2adsb.py <AIS UDP address> <AIS UDP IP> <AIS UDP port> <SBS TCP IP> <SBS TCP port> <options>")
print("Options:")
print("\tFILE xxxx : read mmsi <-> ICAO mapping from file xxxx")
print("\tSAR on/off : include SAR aircraft in sendout")
print("\tSHIPS on/off : include ships in sendout")
print("\tCALLSIGN on/off : include generated callsigns in sendout")
print("\tPRINT on/off : print mmsi/ICAO dictionary")
Expand Down Expand Up @@ -215,7 +216,9 @@ def parseCommandLine():
if len(sys.argv) >= 7 and len(sys.argv) % 2 == 1:
for i in range(5, len(sys.argv),2):
opt = sys.argv[i].upper()
if opt == 'SHIPS':
if opt == 'SAR':
settings["includeSAR"] = parseSwitch(sys.argv[i+1])
elif opt == 'SHIPS':
settings["includeShips"] = parseSwitch(sys.argv[i+1])
elif opt == 'PRINT':
settings["printDict"] = parseSwitch(sys.argv[i+1])
Expand Down Expand Up @@ -253,6 +256,7 @@ def parseCommandLine():

print(f"Input AIS : {settings['UDP_IP']}:{settings['UDP_PORT']}", file=sys.stderr)
print(f"Output SBS : {settings['SERVER_IP']}:{settings['SERVER_PORT']}", file=sys.stderr)
print(f"Include SAR : {settings['includeSAR']}", file=sys.stderr)
print(f"Include ships : {settings['includeShips']}", file=sys.stderr)
print(f"Include callsign : {settings['includeCallSign']}", file=sys.stderr)
print(f"Print Dictionary : {settings['printDict']}", file=sys.stderr)
Expand All @@ -278,7 +282,8 @@ def parseCommandLine():
except:
continue

if decoded['msg_type']==9 or settings['includeShips'] or (decoded['mmsi'] in ICAOmap):
if (((decoded['msg_type'] == 9 or (decoded['mmsi'] in ICAOmap)) and settings['includeSAR'])
or (decoded['msg_type'] != 9 and settings['includeShips'])):
sendBaseStation(decoded)
count = count + 1

Expand Down

0 comments on commit 3d5ef4c

Please sign in to comment.