From 72bddcabab98ccbab15a54fbfc3a1d541fcc1951 Mon Sep 17 00:00:00 2001 From: nzkarit Date: Tue, 12 Sep 2017 23:30:27 +1200 Subject: [PATCH 1/4] Redirected dd's output to /dev/null --- ADSB_Encoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADSB_Encoder.py b/ADSB_Encoder.py index f62df2f..7160b8f 100755 --- a/ADSB_Encoder.py +++ b/ADSB_Encoder.py @@ -132,7 +132,7 @@ def writeOutputFile(filename, data): SamplesFile.close() os.system('sync') os.system('rm %s' % (filename)) - os.system("dd if=tmp.iq8s of=%s bs=4k seek=63" % (filename)) # TODO redirect output to /dev/null + os.system("dd if=tmp.iq8s of=%s bs=4k seek=63 > /dev/null 2>&1" % (filename)) os.system('sync') os.system('rm tmp.iq8s') From 3170515490ad2b279c1bbde067c0618b5311aea9 Mon Sep 17 00:00:00 2001 From: nzkarit Date: Thu, 14 Sep 2017 22:49:54 +1200 Subject: [PATCH 2/4] Bug fix for ICAO from csv casting --- ADSB_Encoder.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ADSB_Encoder.py b/ADSB_Encoder.py index 7160b8f..f3a8f44 100755 --- a/ADSB_Encoder.py +++ b/ADSB_Encoder.py @@ -87,14 +87,14 @@ def manyPlanes(arguments): logger.info('Processing CSV file') logger.info('Repeating the message %s times' % (arguments.repeats)) samples = bytearray() - print(arguments.repeats) for i in range(0, arguments.repeats): with open(arguments.csvfile, newline='') as csvfile: reader = csv.DictReader(csvfile, delimiter=',') for row in reader: if not 'icao' in row.keys(): row['icao'] = arguments.icao - row['icao'] = int(row['icao'], 0) + else: + row['icao'] = int(row['icao'], 0) if not 'latitude' in row.keys(): row['latitude'] = arguments.latitude if not 'longitude' in row.keys(): @@ -114,7 +114,6 @@ def manyPlanes(arguments): if not 'surface' in row.keys(): row['surface'] = arguments.surface logger.debug('Row from CSV: %s' % (row)) - print(row) modes = ModeS() (df17_even, df17_odd) = modes.df17_pos_rep_encode(row['capability'], row['icao'], row['typecode'], row['surveillancestatus'], row['nicsupplementb'], row['altitude'], row['time'], row['latitude'], row['longitude'], row['surface']) From 85b91a0719cf4cac41f428a779445f695825d1ae Mon Sep 17 00:00:00 2001 From: nzkarit Date: Mon, 18 Sep 2017 23:15:20 +1200 Subject: [PATCH 3/4] Getting logging working in the classes. Well one is enough for now --- ADSB_Encoder.py | 7 +++++-- HackRF.py | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ADSB_Encoder.py b/ADSB_Encoder.py index f3a8f44..b211064 100755 --- a/ADSB_Encoder.py +++ b/ADSB_Encoder.py @@ -84,9 +84,9 @@ def singlePlane(arguments): return samples def manyPlanes(arguments): - logger.info('Processing CSV file') - logger.info('Repeating the message %s times' % (arguments.repeats)) + logger.info('Processing CSV file') samples = bytearray() + logger.info('Repeating the message %s times' % (arguments.repeats)) for i in range(0, arguments.repeats): with open(arguments.csvfile, newline='') as csvfile: reader = csv.DictReader(csvfile, delimiter=',') @@ -126,11 +126,13 @@ def manyPlanes(arguments): return samples def writeOutputFile(filename, data): + logger.info('Writing tmp.iq8s file') SamplesFile = open('tmp.iq8s', 'wb') SamplesFile.write(data) SamplesFile.close() os.system('sync') os.system('rm %s' % (filename)) + logger.info('dd for file: %s' % (filename)) os.system("dd if=tmp.iq8s of=%s bs=4k seek=63 > /dev/null 2>&1" % (filename)) os.system('sync') os.system('rm tmp.iq8s') @@ -153,6 +155,7 @@ if __name__ == "__main__": else: data = manyPlanes(arguments) writeOutputFile(arguments.outputfilename, data) + logger.info('Complete') diff --git a/HackRF.py b/HackRF.py index 61753d9..0edfe4a 100644 --- a/HackRF.py +++ b/HackRF.py @@ -1,4 +1,5 @@ import numpy +import logging ############################################################### # Further work on fork # Copyright (C) 2017 David Robinson @@ -6,6 +7,10 @@ class HackRF: """The HackRF class has functions from converting data into a format into which the hackrf can process """ + logger = None + + def __init__(self): + self.logger = logging.getLogger(__name__) def hackrf_raw_IQ_format(self, ppm): """ @@ -15,7 +20,8 @@ class HackRF: Returns: bytearray: containing the IQ data """ - + print(self.logger) + self.logger.debug('Creating hackRF bytearray from the ppm stuff') signal = [] bits = numpy.unpackbits(numpy.asarray(ppm, dtype=numpy.uint8)) for bit in bits: From 853029586e321eef3dae2649cab68c6e84d85e54 Mon Sep 17 00:00:00 2001 From: nzkarit Date: Mon, 18 Sep 2017 23:16:47 +1200 Subject: [PATCH 4/4] Forgot ctrl+s --- HackRF.py | 1 - 1 file changed, 1 deletion(-) diff --git a/HackRF.py b/HackRF.py index 0edfe4a..c3ee1d3 100644 --- a/HackRF.py +++ b/HackRF.py @@ -20,7 +20,6 @@ class HackRF: Returns: bytearray: containing the IQ data """ - print(self.logger) self.logger.debug('Creating hackRF bytearray from the ppm stuff') signal = [] bits = numpy.unpackbits(numpy.asarray(ppm, dtype=numpy.uint8))