Starting of the CSV input
This commit is contained in:
parent
ff94627f50
commit
2f686be21b
@ -10,7 +10,7 @@ import configparser
|
|||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
import os
|
import os
|
||||||
import distutils
|
import csv
|
||||||
|
|
||||||
###############################################################
|
###############################################################
|
||||||
|
|
||||||
@ -61,7 +61,8 @@ def argParser():
|
|||||||
parser.add_argument('-s', '--surface', action='store', default=cfg.getboolean('plane', 'surface'), type=auto_bool, dest='surface', help='If the plane is on the ground or not. Default: %(default)s')
|
parser.add_argument('-s', '--surface', action='store', default=cfg.getboolean('plane', 'surface'), type=auto_bool, dest='surface', help='If the plane is on the ground or not. Default: %(default)s')
|
||||||
parser.add_argument('-o', '--out', '--output', action='store', type=str, default=cfg.get('general', 'outputfilename'), dest='outputfilename', help='The iq8s output filename. This is the file which you will feed into the hackRF. Default: %(default)s')
|
parser.add_argument('-o', '--out', '--output', action='store', type=str, default=cfg.get('general', 'outputfilename'), dest='outputfilename', help='The iq8s output filename. This is the file which you will feed into the hackRF. Default: %(default)s')
|
||||||
parser.add_argument('-r', '--repeats', action='store', dest='repeats', type=int, default=cfg.getint('general', 'repeats'), help='How many repeats of the data to perform. Default: %(default)s')
|
parser.add_argument('-r', '--repeats', action='store', dest='repeats', type=int, default=cfg.getint('general', 'repeats'), help='How many repeats of the data to perform. Default: %(default)s')
|
||||||
|
parser.add_argument('--csv', '--csvfile', '--in', '--input', action='store', type=str, default=cfg.get('general', 'csvfile'), dest='csvfile', help='Import a CSV file with the plane data in it. Default: %(default)s')
|
||||||
|
# TODO Make it so it can do a static checksum
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -76,21 +77,35 @@ if __name__ == "__main__":
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.info('Starting ADSB Encoder')
|
logger.info('Starting ADSB Encoder')
|
||||||
logger.debug('The arguments: %s' % (arguments))
|
logger.debug('The arguments: %s' % (arguments))
|
||||||
print(arguments)
|
|
||||||
logger.info('Repeating the message %s times' % (arguments.repeats))
|
logger.info('Repeating the message %s times' % (arguments.repeats))
|
||||||
|
|
||||||
SamplesFile = open('tmp.iq8s', 'wb')
|
SamplesFile = open('tmp.iq8s', 'wb')
|
||||||
for i in range(0, arguments.repeats):
|
if arguments.csvfile == '':
|
||||||
modes = ModeS()
|
logger.info('Processing default and command line options for a single plane')
|
||||||
(df17_even, df17_odd) = modes.df17_pos_rep_encode(arguments.capability, arguments.icao, arguments.typecode, arguments.surveillancestatus, arguments.nicsupplementb, arguments.altitude, arguments.time, arguments.latitude, arguments.longitude, arguments.surface)
|
for i in range(0, arguments.repeats):
|
||||||
|
modes = ModeS()
|
||||||
|
(df17_even, df17_odd) = modes.df17_pos_rep_encode(arguments.capability, arguments.icao, arguments.typecode, arguments.surveillancestatus, arguments.nicsupplementb, arguments.altitude, arguments.time, arguments.latitude, arguments.longitude, arguments.surface)
|
||||||
|
|
||||||
ppm = PPM()
|
ppm = PPM()
|
||||||
df17_array = ppm.frame_1090es_ppm_modulate(df17_even, df17_odd)
|
df17_array = ppm.frame_1090es_ppm_modulate(df17_even, df17_odd)
|
||||||
|
|
||||||
hackrf = HackRF()
|
hackrf = HackRF()
|
||||||
samples_array = hackrf.hackrf_raw_IQ_format(df17_array)
|
samples_array = hackrf.hackrf_raw_IQ_format(df17_array)
|
||||||
|
|
||||||
|
|
||||||
SamplesFile.write(samples_array)
|
SamplesFile.write(samples_array)
|
||||||
|
else:
|
||||||
|
logger.info('Processing CSV file')
|
||||||
|
with open(arguments.csvfile, newline='') as csvfile:
|
||||||
|
reader = csv.DictReader(csvfile, delimiter=',')
|
||||||
|
for row in reader:
|
||||||
|
logger.debug('Row from CSV: %s' % (row))
|
||||||
|
if not 'icao' in row.keys():
|
||||||
|
print('Need ICAO')
|
||||||
|
if not 'latitude' in row.keys():
|
||||||
|
print('Need Latitude')
|
||||||
|
|
||||||
SamplesFile.close()
|
SamplesFile.close()
|
||||||
os.system('sync')
|
os.system('sync')
|
||||||
os.system("dd if=tmp.iq8s of=%s bs=4k seek=63" % (arguments.outputfilename)) # TODO redirect output to /dev/null
|
os.system("dd if=tmp.iq8s of=%s bs=4k seek=63" % (arguments.outputfilename)) # TODO redirect output to /dev/null
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[general]
|
[general]
|
||||||
outputfilename = Samples_256K.iq8s
|
outputfilename = Samples_256K.iq8s
|
||||||
repeats = 1
|
repeats = 1
|
||||||
|
csvfile =
|
||||||
|
|
||||||
[plane]
|
[plane]
|
||||||
icao = 0xABCDEF
|
icao = 0xABCDEF
|
||||||
|
3
example.csv
Normal file
3
example.csv
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
icao,altitude
|
||||||
|
0x123456,70000
|
||||||
|
0xABCDEF,-1000
|
|
Loading…
Reference in New Issue
Block a user