hi Tom
i found and modified this code with ‘google assistance’ cause i know very little about programming and that in Visual Basic. so took 7-8 hrs to shape it to my need (only for use with dump1090-mutability).
i used some other code but kept erasing /etc/default/dump1090-mutablitity file.
other than that, i do need a ‘ready-made’ script to change the gain at preset times, and that cause i do not know how to program in python. being 63 is a little late to start learning python.
due to my position and antenna (i use abcd567 cantenna and/or spider) i try to scavenge every acft position available.
the code i modified
#!/usr/bin/python2
20.Oct.2017 ----------------------------> OK --------------------
import argparse, os, socket, threading
from subprocess import Popen, PIPE
from datetime import datetime
from select import select
import time, fileinput, os
try:
import queue
except:
import Queue as queue # For Python 2.x
os.system(‘clear’)
def date(): # Returns UTC date and time in the format DD MM YY HH:MM:SS
return datetime.strftime(datetime.utcnow(), ‘%a %d %b %Y %H:%M:%S UTC’)
==== CHANGE PARAMETERS AS REQUIRED =================================================================
measure_duration = 60 # duration of each pass seconds
ntests = 3 # number of tests
gainstr = “20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 -10”
gains = gainstr.split()
gains.reverse()
results = {}
s_port = 30003
s_format = “Basestation”
====================================================================================================
print " "
print “--------------------------------------------------------------”
print " DUMP1090-MUTABILITY * GAIN OPTIMIZATION TESTER "
print " "
print " ", "will run ", ntests, " test(s) for ", measure_duration, " seconds per gain setting, "
print " “, “using data received on port”, s_port, " format”, s_format # AVR, Beast, SBS etc.
print " ", "for the following gains : "
print " ", gainstr
print " "
print " ", date()
print “--------------------------------------------------------------”
orig_gain = “”
for i in range(ntests):
print " "
print " test", i+1, “of”, ntests
print " gain mesgs posns acft"
for g in gains:
if g not in results:
results[g] = [0,0,{}] # msgs, positions, aircraft
for line in fileinput.input(‘/etc/default/dump1090-mutability’, inplace=1):
if line.startswith(‘GAIN’):
if len(orig_gain) < 1:
orig_gain = line # remember AND preserve !
print(orig_gain),
os.system(“sudo systemctl restart dump1090-mutability”)
else:
print(line),
os.system(“sudo systemctl restart dump1090-mutability”)
else:
print(line),
os.system(“sudo systemctl restart dump1090-mutability”)
time.sleep(2)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((‘localhost’,s_port))
t = time.time()
d = ‘’
while 1:
d += s.recv(32)
if time.time() - t > measure_duration:
break
s.close()
messages = 0
positions = 0
planes = {}
for l in d.split(‘\n’):
a = l.split(‘,’)
messages += 1
if len(a) > 4:
if a[1] == ‘3’:
positions += 1
planes[a[4]] = 1
print " ",g, " ", messages, " ", positions, " ", len(planes.keys())
results[g][0] += messages
results[g][1] += positions
for hex in planes.keys():
results[g][2][hex] = 1
print(" “)
print(” === Totals ============“)
print(” Gain, Mesgs, Posns, Acft")
for g in gains:
(messages,positions,planes) = results[g]
print " ", g, " ", messages, " ", positions, " ",len(planes.keys())
#--------------------------------------------------------------------------
os.system(“sudo service dump1090-mutability restart”)
print(‘\n’)
print " ", date(), " - orig ", orig_gain
print “--------------------------------------------------------------”
print(‘\n’)
END
and the balcony antenas