Add software
This commit is contained in:
@ -0,0 +1,117 @@
|
||||
options:
|
||||
parameters:
|
||||
author: ''
|
||||
category: Custom
|
||||
cmake_opt: ''
|
||||
comment: ''
|
||||
copyright: ''
|
||||
description: ''
|
||||
gen_cmake: 'On'
|
||||
gen_linking: dynamic
|
||||
generate_options: no_gui
|
||||
hier_block_src_path: '.:'
|
||||
id: top_block
|
||||
max_nouts: '0'
|
||||
output_language: python
|
||||
placement: (0,0)
|
||||
qt_qss_theme: ''
|
||||
realtime_scheduling: ''
|
||||
run: 'True'
|
||||
run_command: '{python} -u {filename}'
|
||||
run_options: run
|
||||
sizing_mode: fixed
|
||||
thread_safe_setters: ''
|
||||
title: ''
|
||||
window_size: ''
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [8, 8]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
|
||||
blocks:
|
||||
- name: blocks_file_sink_0
|
||||
id: blocks_file_sink
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
append: 'False'
|
||||
comment: ''
|
||||
file: /tmp/foo.cfile
|
||||
type: complex
|
||||
unbuffered: 'False'
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [632, 140.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: blocks_file_source_0
|
||||
id: blocks_file_source
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
begin_tag: pmt.PMT_NIL
|
||||
comment: ''
|
||||
file: Porpack_Capture.C16
|
||||
length: '0'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
offset: '0'
|
||||
repeat: 'False'
|
||||
type: short
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [64, 124.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: blocks_interleaved_short_to_complex_0
|
||||
id: blocks_interleaved_short_to_complex
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
swap: 'False'
|
||||
vector_input: 'False'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [272, 156.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: blocks_multiply_const_vxx_0
|
||||
id: blocks_multiply_const_vxx
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
const: ' 1.0 / 32768.0'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
type: complex
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [448, 156.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
|
||||
connections:
|
||||
- [blocks_file_source_0, '0', blocks_interleaved_short_to_complex_0, '0']
|
||||
- [blocks_interleaved_short_to_complex_0, '0', blocks_multiply_const_vxx_0, '0']
|
||||
- [blocks_multiply_const_vxx_0, '0', blocks_file_sink_0, '0']
|
||||
|
||||
metadata:
|
||||
file_format: 1
|
127
Software/portapack-mayhem/firmware/tools/extract_cpld_data.py
Normal file
127
Software/portapack-mayhem/firmware/tools/extract_cpld_data.py
Normal file
@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
#
|
||||
# This file is part of PortaPack.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# Very fragile code to extract data from Altera MAX V CPLD SVF
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print('Usage: <command> <Altera MAX V CPLD SVF file path> <revision name>')
|
||||
sys.exit(-1)
|
||||
|
||||
f = open(sys.argv[1], 'r')
|
||||
revision_name = sys.argv[2]
|
||||
|
||||
calculate_crc = False
|
||||
|
||||
# !PROGRAM
|
||||
# SIR 10 TDI (203);
|
||||
# RUNTEST 93 TCK;
|
||||
# SDR 13 TDI (0000);
|
||||
# SIR 10 TDI (2F4);
|
||||
# RUNTEST 93 TCK;
|
||||
# while:
|
||||
# SDR 16 TDI (7FFF);
|
||||
# RUNTEST 1800 TCK;
|
||||
# SIR 10 TDI (203);
|
||||
# RUNTEST 93 TCK;
|
||||
# SDR 13 TDI (0001);
|
||||
# SIR 10 TDI (2F4);
|
||||
# RUNTEST 93 TCK;
|
||||
|
||||
phase = None
|
||||
|
||||
block_0 = []
|
||||
block_1 = []
|
||||
current_block = None
|
||||
|
||||
for line in f:
|
||||
line = line.strip().upper()
|
||||
|
||||
if line == '!PROGRAM':
|
||||
phase = 'block_0'
|
||||
current_block = block_0
|
||||
elif line == '!VERIFY':
|
||||
phase = 'verify'
|
||||
current_block = None
|
||||
|
||||
if phase == 'block_0':
|
||||
if line == 'SDR 13 TDI (0001);':
|
||||
phase = 'block_1'
|
||||
current_block = block_1
|
||||
|
||||
if phase == 'block_0' or phase == 'block_1':
|
||||
if line.startswith('SDR 16 TDI ('):
|
||||
sdr_value = int(line.split('(', 1)[1][:4], 16)
|
||||
#print('0x%04x,' % sdr_value)
|
||||
current_block.append(sdr_value)
|
||||
|
||||
def print_block(block):
|
||||
for n in range(0, len(block), 8):
|
||||
chunk = block[n:n+8]
|
||||
line = ['0x%04x,' % v for v in chunk]
|
||||
print('\t%s' % ' '.join(line))
|
||||
|
||||
def crc32(blocks):
|
||||
import zlib
|
||||
|
||||
crc_bytes = []
|
||||
for block in blocks:
|
||||
for word in block:
|
||||
crc_bytes.append((word >> 0) & 0xff)
|
||||
crc_bytes.append((word >> 8) & 0xff)
|
||||
return zlib.crc32(bytearray(crc_bytes)) & 0xffffffff
|
||||
|
||||
print("""#include "portapack_cpld_data.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
|
||||
namespace portapack {
|
||||
namespace cpld {
|
||||
namespace %s {
|
||||
""" % revision_name)
|
||||
|
||||
print('const std::array<uint16_t, %d> block_0 { {' % len(block_0))
|
||||
print_block(block_0)
|
||||
|
||||
print("""} };
|
||||
""")
|
||||
|
||||
print('const std::array<uint16_t, %d> block_1 { {' % len(block_1))
|
||||
print_block(block_1)
|
||||
|
||||
print("""} };
|
||||
|
||||
} /* namespace %s */
|
||||
} /* namespace cpld */
|
||||
} /* namespace portapack */
|
||||
""" % revision_name)
|
||||
|
||||
if calculate_crc:
|
||||
# Apply post-programming modification to make post-programming CRC correct:
|
||||
programmed_block_0 = block_0[:]
|
||||
programmed_block_0[0] &= 0xfbff
|
||||
|
||||
crc = crc32((programmed_block_0, block_1))
|
||||
print('%08x' % crc)
|
20
Software/portapack-mayhem/firmware/tools/fir_lpf.py
Normal file
20
Software/portapack-mayhem/firmware/tools/fir_lpf.py
Normal file
@ -0,0 +1,20 @@
|
||||
import math
|
||||
|
||||
m = 64 - 1
|
||||
ft = 300.0 / 24000.0
|
||||
|
||||
taps = []
|
||||
window = []
|
||||
|
||||
print("Normalized ft = " + str(ft))
|
||||
|
||||
for n in range(0, 64):
|
||||
taps.append(math.sin(2 * math.pi * ft * (n - (m / 2.0))) / (math.pi * (n - (m / 2.0))))
|
||||
|
||||
for n in range(0, 64):
|
||||
window.append(0.5 - 0.5 * math.cos(2 * math.pi * n / m))
|
||||
|
||||
for n in range(0, 64):
|
||||
taps[n] = int(taps[n] * window[n] * 32768)
|
||||
|
||||
print(taps)
|
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2017 Furrtek
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import struct
|
||||
from PIL import Image
|
||||
|
||||
outfile = open('../../sdcard/ADSB/world_map.bin', 'wb')
|
||||
|
||||
# Allow for bigger images
|
||||
Image.MAX_IMAGE_PIXELS = None
|
||||
im = Image.open("../../sdcard/ADSB/world_map.jpg")
|
||||
pix = im.load()
|
||||
|
||||
outfile.write(struct.pack('H', im.size[0]))
|
||||
outfile.write(struct.pack('H', im.size[1]))
|
||||
|
||||
print("Generating: \t" + outfile.name + "\n from\t\t" + im.filename + "\n please wait...");
|
||||
|
||||
for y in range (0, im.size[1]):
|
||||
line = b''
|
||||
for x in range (0, im.size[0]):
|
||||
# RRRRRGGGGGGBBBBB
|
||||
pixel_lcd = (pix[x, y][0] >> 3) << 11
|
||||
pixel_lcd |= (pix[x, y][1] >> 2) << 5
|
||||
pixel_lcd |= (pix[x, y][2] >> 3)
|
||||
# RRRGGGBB to
|
||||
# RRR00GGG000BB000
|
||||
# pixel_lcd = (pix[x, y][0] >> 5) << 5
|
||||
# pixel_lcd |= (pix[x, y][1] >> 5) << 2
|
||||
# pixel_lcd |= (pix[x, y][2] >> 6)
|
||||
line += struct.pack('H', pixel_lcd)
|
||||
outfile.write(line)
|
||||
print(str(y) + '/' + str(im.size[1]) + '\r', end="")
|
||||
|
||||
print("Ready.");
|
@ -0,0 +1,8 @@
|
||||
# Make airlines.db
|
||||
|
||||
Licensed under [GNU GPL v3](../../../LICENSE)
|
||||
|
||||
USAGE:
|
||||
- Copy file from: https://raw.githubusercontent.com/kx1t/planefence-airlinecodes/main/airlinecodes.txt
|
||||
- Run Python 3 script: `./make_airlines_db.py`
|
||||
- Copy file to /ADSB folder on SDCARD
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2021 ArjanOnwezen
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
# Create airline.db, used for ADS-B receiver application, using
|
||||
# https://raw.githubusercontent.com/kx1t/planefence-airlinecodes/main/airlinecodes.txt
|
||||
# as a source.
|
||||
# -------------------------------------------------------------------------------------
|
||||
import csv
|
||||
import unicodedata
|
||||
icao_codes=bytearray()
|
||||
airlines_countries=bytearray()
|
||||
row_count=0
|
||||
|
||||
database=open("airlines.db", "wb")
|
||||
|
||||
with open('airlinecodes.txt', 'rt') as csv_file:
|
||||
sorted_lines=sorted(csv_file.readlines())
|
||||
|
||||
for row in csv.reader(sorted_lines, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True):
|
||||
icao_code=row[0]
|
||||
# Normalize some unicode characters
|
||||
airline=unicodedata.normalize('NFKD', row[1][:32]).encode('ascii', 'ignore')
|
||||
country=unicodedata.normalize('NFKD', row[3][:32]).encode('ascii', 'ignore')
|
||||
if len(icao_code) == 3 :
|
||||
airline_padding=bytearray()
|
||||
country_padding=bytearray()
|
||||
print(icao_code,' - ', airline,' - ', country)
|
||||
icao_codes=icao_codes+bytearray(icao_code+'\0', encoding='ascii')
|
||||
airline_padding=bytearray('\0' * (32 - len(airline)), encoding='ascii')
|
||||
country_padding=bytearray('\0' * (32 - len(country)), encoding='ascii')
|
||||
airlines_countries=airlines_countries+bytearray(airline+airline_padding+country+country_padding)
|
||||
row_count+=1
|
||||
|
||||
database.write(icao_codes+airlines_countries)
|
||||
print("Total of", row_count, "ICAO codes stored in database")
|
||||
|
117
Software/portapack-mayhem/firmware/tools/make_baseband_file.py
Normal file
117
Software/portapack-mayhem/firmware/tools/make_baseband_file.py
Normal file
@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2016 Furrtek
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
import sys
|
||||
import struct
|
||||
import md5
|
||||
|
||||
usage_message = """
|
||||
Baseband module package file generator
|
||||
|
||||
Usage: <command> <module_name> <module_name>...
|
||||
"""
|
||||
|
||||
def read_image(path):
|
||||
f = open(path, 'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
return data
|
||||
|
||||
def write_file(data, path):
|
||||
f = open(path, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print(usage_message)
|
||||
sys.exit(-1)
|
||||
|
||||
data = bytearray()
|
||||
h_data = bytearray()
|
||||
name = bytearray()
|
||||
info = bytearray()
|
||||
description = bytearray()
|
||||
data_default_byte = bytearray((0,))
|
||||
|
||||
sys.argv = sys.argv[1:]
|
||||
|
||||
# Format for module file:
|
||||
# Magic (4), Version (2), Length (4), Name (16), MD5 (16), Description (214)
|
||||
# 0x00 pad bytes (256)
|
||||
# Module binary (padded to 32768-16)
|
||||
# MD5 (16) again, so that module code can read it (dirty...)
|
||||
|
||||
for args in sys.argv:
|
||||
m = md5.new()
|
||||
data = read_image(args + '/build/' + args + '.bin')
|
||||
data_r = data
|
||||
|
||||
# Magic bytes
|
||||
info = 'PPM '
|
||||
|
||||
# Version
|
||||
info += struct.pack('H', 2)
|
||||
|
||||
# Length
|
||||
info += struct.pack('I', len(data))
|
||||
|
||||
# Module name
|
||||
name = read_image(args + '/name')
|
||||
if len(name) > 16:
|
||||
name = name[0:15]
|
||||
pad_size = 16 - len(name)
|
||||
name += (data_default_byte * pad_size)
|
||||
info += name
|
||||
|
||||
# Module MD5 footprint
|
||||
m.update(data)
|
||||
digest = m.digest()
|
||||
pad_size = 16 - len(digest)
|
||||
digest += (data_default_byte * pad_size)
|
||||
info += digest
|
||||
|
||||
# Module description
|
||||
description = read_image(args + '/description')
|
||||
if len(description) > 214:
|
||||
description = description[0:213]
|
||||
pad_size = 214 - len(description)
|
||||
description += (data_default_byte * pad_size)
|
||||
info += description
|
||||
|
||||
# Header padding to fit in SD card sector
|
||||
info += (data_default_byte * 256)
|
||||
|
||||
# Binary padding
|
||||
data = info + data
|
||||
pad_size = (32768 + 512 - 16) - len(data)
|
||||
data += (data_default_byte * pad_size)
|
||||
data += digest
|
||||
write_file(data, args + '.bin')
|
||||
|
||||
# Add to modules.h
|
||||
md5sum = ''
|
||||
for byte in digest:
|
||||
md5sum += '0x' + format(byte, '02x') + ','
|
||||
h_data += 'const char md5_' + args.replace('-','_') + '[16] = {' + md5sum + '};\n'
|
||||
|
||||
# Update original binary with MD5 footprint
|
||||
write_file(data[512:(32768+512)], args + '/build/' + args + '_inc.bin')
|
||||
|
||||
write_file(h_data, 'common/modules.h')
|
115
Software/portapack-mayhem/firmware/tools/make_bitmap.py
Normal file
115
Software/portapack-mayhem/firmware/tools/make_bitmap.py
Normal file
@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2016 Furrtek
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
import sys
|
||||
import struct
|
||||
from PIL import Image
|
||||
from os import listdir
|
||||
from os import path
|
||||
|
||||
usage_message = """
|
||||
1BPP PortaPack bitmap.hpp generator
|
||||
|
||||
Usage: <directory>
|
||||
"""
|
||||
|
||||
if len(sys.argv) < 1:
|
||||
print(usage_message)
|
||||
sys.exit(-1)
|
||||
|
||||
def convert_png(file):
|
||||
c = 0
|
||||
data = 0
|
||||
|
||||
im = Image.open(file)
|
||||
rgb_im = im.convert('RGBA')
|
||||
|
||||
if rgb_im.size[0] % 8 or rgb_im.size[1] % 8:
|
||||
print(file + ": Size isn\'t a multiple of 8")
|
||||
sys.exit(-1)
|
||||
|
||||
name = path.basename(file).split(".")[0].lower();
|
||||
|
||||
f.write("static constexpr uint8_t bitmap_" + name + "_data[] = {\n")
|
||||
f.write(' ') # Tab
|
||||
|
||||
for i in range(rgb_im.size[1]):
|
||||
for j in range(rgb_im.size[0]):
|
||||
r, g, b, a = rgb_im.getpixel((j, i))
|
||||
|
||||
data >>= 1
|
||||
|
||||
if r > 127 and g > 127 and b > 127 and a > 127:
|
||||
data += 128
|
||||
|
||||
if j % 8 == 7:
|
||||
f.write("0x%0.2X, " % data)
|
||||
data = 0
|
||||
|
||||
f.write("\n")
|
||||
if i < rgb_im.size[1] - 1:
|
||||
f.write(' ') # Tab
|
||||
|
||||
f.write("};\n")
|
||||
f.write("static constexpr Bitmap bitmap_" + name + " {\n")
|
||||
f.write(" { " + str(rgb_im.size[0]) + ", " + str(rgb_im.size[1]) + " }, bitmap_" + name+ "_data\n")
|
||||
f.write("};\n\n")
|
||||
return
|
||||
|
||||
count = 0
|
||||
|
||||
f = open('bitmap.hpp', 'w')
|
||||
f.write("/*\n")
|
||||
f.write(" * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.\n")
|
||||
f.write(" * Copyright (C) 2016 Furrtek\n")
|
||||
f.write(" *\n")
|
||||
f.write(" * This file is part of PortaPack.\n")
|
||||
f.write(" *\n")
|
||||
f.write(" * This program is free software; you can redistribute it and/or modify\n")
|
||||
f.write(" * it under the terms of the GNU General Public License as published by\n")
|
||||
f.write(" * the Free Software Foundation; either version 2, or (at your option)\n")
|
||||
f.write(" * any later version.\n")
|
||||
f.write(" *\n")
|
||||
f.write(" * This program is distributed in the hope that it will be useful,\n")
|
||||
f.write(" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n")
|
||||
f.write(" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n")
|
||||
f.write(" * GNU General Public License for more details.\n")
|
||||
f.write(" *\n")
|
||||
f.write(" * You should have received a copy of the GNU General Public License\n")
|
||||
f.write(" * along with this program; see the file COPYING. If not, write to\n")
|
||||
f.write(" * the Free Software Foundation, Inc., 51 Franklin Street,\n")
|
||||
f.write(" * Boston, MA 02110-1301, USA.\n")
|
||||
f.write(" */\n\n")
|
||||
f.write("// This file was generated by make_bitmap.py\n\n")
|
||||
f.write("#ifndef __BITMAP_HPP__\n")
|
||||
f.write("#define __BITMAP_HPP__\n\n")
|
||||
f.write("#include \"ui.hpp\"\n\n")
|
||||
f.write("namespace ui {\n\n")
|
||||
|
||||
for file in listdir(sys.argv[1]):
|
||||
if file.endswith(".png"):
|
||||
convert_png(sys.argv[1] + file)
|
||||
count += 1
|
||||
|
||||
f.write("\n")
|
||||
f.write("} /* namespace ui */\n\n")
|
||||
f.write("#endif/*__BITMAP_HPP__*/\n")
|
||||
|
||||
print("Converted " + str(count) + " files")
|
43
Software/portapack-mayhem/firmware/tools/make_dcs.py
Normal file
43
Software/portapack-mayhem/firmware/tools/make_dcs.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2016 Furrtek
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# From http://mmi-comm.tripod.com/dcs.html
|
||||
|
||||
import sys
|
||||
import struct
|
||||
|
||||
cb = [0,0,0,0,0,0,0,0,0]
|
||||
for c in range (0, 0x200): # DCS code is 9 bits
|
||||
for bit in range(0, 9):
|
||||
cb[bit] = (c >> bit) & 1
|
||||
|
||||
p1 = cb[0] ^ cb[1] ^ cb[2] ^ cb[3] ^ cb[4] ^ cb[7];
|
||||
p2 = cb[1] ^ cb[2] ^ cb[3] ^ cb[4] ^ cb[5] ^ cb[8] ^ 1;
|
||||
p3 = cb[0] ^ cb[1] ^ cb[5] ^ cb[6] ^ cb[7];
|
||||
p4 = cb[1] ^ cb[2] ^ cb[6] ^ cb[7] ^ cb[8] ^ 1;
|
||||
p5 = cb[0] ^ cb[1] ^ cb[4] ^ cb[8] ^ 1;
|
||||
p6 = cb[0] ^ cb[3] ^ cb[4] ^ cb[5] ^ cb[7] ^ 1;
|
||||
p7 = cb[0] ^ cb[2] ^ cb[3] ^ cb[5] ^ cb[6] ^ cb[7] ^ cb[8];
|
||||
p8 = cb[1] ^ cb[3] ^ cb[4] ^ cb[6] ^ cb[7] ^ cb[8];
|
||||
p9 = cb[2] ^ cb[4] ^ cb[5] ^ cb[7] ^ cb[8];
|
||||
p10 = cb[3] ^ cb[5] ^ cb[6] ^ cb[8] ^ 1;
|
||||
p11 = cb[0] ^ cb[1] ^ cb[2] ^ cb[3] ^ cb[6] ^ 1;
|
||||
|
||||
print ' 0b{0:011b}'.format((p11<<10) | (p10<<9) | (p9<<8) |(p8<<7) | (p7<<6) | (p6<<5) | (p5<<4) | (p4<<3) | (p3<<2) | (p2<<1) | (p1)) + ', // ' + str(c);
|
@ -0,0 +1,8 @@
|
||||
# Make icao24.db
|
||||
|
||||
Licensed under [GNU GPL v3](../../../LICENSE)
|
||||
|
||||
USAGE:
|
||||
- Copy file from: https://opensky-network.org/datasets/metadata/aircraftDatabase.csv
|
||||
- Run Python 3 script: `./make_icao24_db.py`
|
||||
- Copy file to /ADSB folder on SDCARD
|
460059
Software/portapack-mayhem/firmware/tools/make_icao24_db/aircraftDatabase.csv
Normal file
460059
Software/portapack-mayhem/firmware/tools/make_icao24_db/aircraftDatabase.csv
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2021 ArjanOnwezen
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
# Create icao24.db, used for ADS-B receiver application, using
|
||||
# https://opensky-network.org/datasets/metadata/aircraftDatabase.csv
|
||||
# as a source.
|
||||
# -------------------------------------------------------------------------------------
|
||||
import csv
|
||||
import unicodedata
|
||||
icao24_codes=bytearray()
|
||||
data=bytearray()
|
||||
row_count=0
|
||||
|
||||
database=open("icao24.db", "wb")
|
||||
|
||||
with open('aircraftDatabase.csv', 'rt') as csv_file:
|
||||
sorted_lines=sorted(csv_file.readlines()[1:])
|
||||
for row in csv.reader(sorted_lines, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True):
|
||||
# only store in case enough info is available
|
||||
if len(row) == 27 and len(row[0]) == 6 and len(row[1]) > 0:
|
||||
icao24_code=row[0][:6].upper()
|
||||
registration=row[1][:8].encode('ascii', 'ignore')
|
||||
manufacturer=row[3][:32].encode('ascii', 'ignore')
|
||||
model=row[4][:32].encode('ascii', 'ignore')
|
||||
# in case icao aircraft type isn't, use ac type like BALL for balloon
|
||||
if len(row[8]) == 3:
|
||||
actype=row[8][:3].encode('ascii', 'ignore')
|
||||
else:
|
||||
actype=row[5][:4].encode('ascii', 'ignore')
|
||||
owner=row[13][:32].encode('ascii', 'ignore')
|
||||
operator=row[9][:32].encode('ascii', 'ignore')
|
||||
#padding
|
||||
icao24_codes=icao24_codes+bytearray(icao24_code+'\0', encoding='ascii')
|
||||
registration_padding=bytearray('\0' * (9 - len(registration)), encoding='ascii')
|
||||
manufacturer_padding=bytearray('\0' * (33 - len(manufacturer)), encoding='ascii')
|
||||
model_padding=bytearray('\0' * (33 - len(model)), encoding='ascii')
|
||||
actype_padding=bytearray('\0' * (5 - len(actype)), encoding='ascii')
|
||||
owner_padding=bytearray('\0' * (33 - len(owner)), encoding='ascii')
|
||||
operator_padding=bytearray('\0' * (33 - len(operator)), encoding='ascii')
|
||||
data=data+bytearray(registration+registration_padding+manufacturer+manufacturer_padding+model+model_padding+actype+actype_padding+owner+owner_padding+operator+operator_padding)
|
||||
row_count+=1
|
||||
|
||||
database.write(icao24_codes+data)
|
||||
print("Total of", row_count, "ICAO codes stored in database")
|
||||
|
72
Software/portapack-mayhem/firmware/tools/make_image_chunk.py
Normal file
72
Software/portapack-mayhem/firmware/tools/make_image_chunk.py
Normal file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
#
|
||||
# This file is part of PortaPack.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
import sys
|
||||
import struct
|
||||
|
||||
usage_message = """
|
||||
PortaPack image chunk writer
|
||||
|
||||
Usage: <command> <input_binary> <four-characer tag> <output_tagged_binary> [<chunk max size>]
|
||||
"""
|
||||
|
||||
def read_image(path):
|
||||
f = open(path, 'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
return data
|
||||
|
||||
def write_image(data, path):
|
||||
f = open(path, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
input_image_max_length = 32768
|
||||
if len(sys.argv) in (4, 5):
|
||||
input_image = read_image(sys.argv[1])
|
||||
tag = tuple(map(ord, sys.argv[2]))
|
||||
output_path = sys.argv[3]
|
||||
if len(sys.argv) == 5:
|
||||
input_image_max_length = int(sys.argv[4])
|
||||
elif len(sys.argv) == 2:
|
||||
input_image = bytearray()
|
||||
tag = (0, 0, 0, 0)
|
||||
output_path = sys.argv[1]
|
||||
else:
|
||||
print(usage_message)
|
||||
sys.exit(-1)
|
||||
|
||||
if len(tag) != 4:
|
||||
print(usage_message)
|
||||
sys.exit(-2)
|
||||
|
||||
if len(input_image) > input_image_max_length:
|
||||
raise RuntimeError('image size of %d exceeds device size of %d bytes' % (len(input_image), input_image_max_length))
|
||||
if (len(input_image) & 3) != 0:
|
||||
raise RuntimeError('image size of %d is not multiple of four' % (len(input_image,)))
|
||||
|
||||
output_image = bytearray()
|
||||
output_image += struct.pack('<4BI', tag[0], tag[1], tag[2], tag[3], len(input_image))
|
||||
output_image += input_image
|
||||
|
||||
write_image(output_image, output_path)
|
@ -0,0 +1,295 @@
|
||||
Digit,Allocated to
|
||||
201,Albania (Republic of)
|
||||
202,Andorra (Principality of)
|
||||
203,Austria
|
||||
204,Portugal - Azores
|
||||
205,Belgium
|
||||
206,Belarus (Republic of)
|
||||
207,Bulgaria (Republic of)
|
||||
208,Vatican City State
|
||||
209,Cyprus (Republic of)
|
||||
210,Cyprus (Republic of)
|
||||
211,Germany (Federal Republic of)
|
||||
212,Cyprus (Republic of)
|
||||
213,Georgia
|
||||
214,Moldova (Republic of)
|
||||
215,Malta
|
||||
216,Armenia (Republic of)
|
||||
218,Germany (Federal Republic of)
|
||||
219,Denmark
|
||||
220,Denmark
|
||||
224,Spain
|
||||
225,Spain
|
||||
226,France
|
||||
227,France
|
||||
228,France
|
||||
229,Malta
|
||||
230,Finland
|
||||
231,Denmark - Faroe Islands
|
||||
232,United Kingdom of Great Britain and Northern Ireland
|
||||
233,United Kingdom of Great Britain and Northern Ireland
|
||||
234,United Kingdom of Great Britain and Northern Ireland
|
||||
235,United Kingdom of Great Britain and Northern Ireland
|
||||
236,United Kingdom of Great Britain and Northern Ireland - Gibraltar
|
||||
237,Greece
|
||||
238,Croatia (Republic of)
|
||||
239,Greece
|
||||
240,Greece
|
||||
241,Greece
|
||||
242,Morocco (Kingdom of)
|
||||
243,Hungary
|
||||
244,Netherlands (Kingdom of the)
|
||||
245,Netherlands (Kingdom of the)
|
||||
246,Netherlands (Kingdom of the)
|
||||
247,Italy
|
||||
248,Malta
|
||||
249,Malta
|
||||
250,Ireland
|
||||
251,Iceland
|
||||
252,Liechtenstein (Principality of)
|
||||
253,Luxembourg
|
||||
254,Monaco (Principality of)
|
||||
255,Portugal - Madeira
|
||||
256,Malta
|
||||
257,Norway
|
||||
258,Norway
|
||||
259,Norway
|
||||
261,Poland (Republic of)
|
||||
262,Montenegro
|
||||
263,Portugal
|
||||
264,Romania
|
||||
265,Sweden
|
||||
266,Sweden
|
||||
267,Slovak Republic
|
||||
268,San Marino (Republic of)
|
||||
269,Switzerland (Confederation of)
|
||||
270,Czech Republic
|
||||
271,Turkey
|
||||
272,Ukraine
|
||||
273,Russian Federation
|
||||
274,North Macedonia (Republic of)
|
||||
275,Latvia (Republic of)
|
||||
276,Estonia (Republic of)
|
||||
277,Lithuania (Republic of)
|
||||
278,Slovenia (Republic of)
|
||||
279,Serbia (Republic of)
|
||||
301,United Kingdom of Great Britain and Northern Ireland - Anguilla
|
||||
303,United States of America - Alaska (State of)
|
||||
304,Antigua and Barbuda
|
||||
305,Antigua and Barbuda
|
||||
306,"Netherlands (Kingdom of the) - Bonaire, Sint Eustatius and Saba"
|
||||
306,Netherlands (Kingdom of the) - Curaçao
|
||||
306,Netherlands (Kingdom of the) - Sint Maarten (Dutch part)
|
||||
307,Netherlands (Kingdom of the) - Aruba
|
||||
308,Bahamas (Commonwealth of the)
|
||||
309,Bahamas (Commonwealth of the)
|
||||
310,United Kingdom of Great Britain and Northern Ireland - Bermuda
|
||||
311,Bahamas (Commonwealth of the)
|
||||
312,Belize
|
||||
314,Barbados
|
||||
316,Canada
|
||||
319,United Kingdom of Great Britain and Northern Ireland - Cayman Islands
|
||||
321,Costa Rica
|
||||
323,Cuba
|
||||
325,Dominica (Commonwealth of)
|
||||
327,Dominican Republic
|
||||
329,France - Guadeloupe (French Department of)
|
||||
330,Grenada
|
||||
331,Denmark - Greenland
|
||||
332,Guatemala (Republic of)
|
||||
334,Honduras (Republic of)
|
||||
336,Haiti (Republic of)
|
||||
338,United States of America
|
||||
339,Jamaica
|
||||
341,Saint Kitts and Nevis (Federation of)
|
||||
343,Saint Lucia
|
||||
345,Mexico
|
||||
347,France - Martinique (French Department of)
|
||||
348,United Kingdom of Great Britain and Northern Ireland - Montserrat
|
||||
350,Nicaragua
|
||||
351,Panama (Republic of)
|
||||
352,Panama (Republic of)
|
||||
353,Panama (Republic of)
|
||||
354,Panama (Republic of)
|
||||
355,Panama (Republic of)
|
||||
356,Panama (Republic of)
|
||||
357,Panama (Republic of)
|
||||
358,United States of America - Puerto Rico
|
||||
359,El Salvador (Republic of)
|
||||
361,France - Saint Pierre and Miquelon (Territorial Collectivity of)
|
||||
362,Trinidad and Tobago
|
||||
364,United Kingdom of Great Britain and Northern Ireland - Turks and Caicos Islands
|
||||
366,United States of America
|
||||
367,United States of America
|
||||
368,United States of America
|
||||
369,United States of America
|
||||
370,Panama (Republic of)
|
||||
371,Panama (Republic of)
|
||||
372,Panama (Republic of)
|
||||
373,Panama (Republic of)
|
||||
374,Panama (Republic of)
|
||||
375,Saint Vincent and the Grenadines
|
||||
376,Saint Vincent and the Grenadines
|
||||
377,Saint Vincent and the Grenadines
|
||||
378,United Kingdom of Great Britain and Northern Ireland - British Virgin Islands
|
||||
379,United States of America - United States Virgin Islands
|
||||
401,Afghanistan
|
||||
403,Saudi Arabia (Kingdom of)
|
||||
405,Bangladesh (People's Republic of)
|
||||
408,Bahrain (Kingdom of)
|
||||
410,Bhutan (Kingdom of)
|
||||
412,China (People's Republic of)
|
||||
413,China (People's Republic of)
|
||||
414,China (People's Republic of)
|
||||
416,China (People's Republic of) - Taiwan (Province of China)
|
||||
417,Sri Lanka (Democratic Socialist Republic of)
|
||||
419,India (Republic of)
|
||||
422,Iran (Islamic Republic of)
|
||||
423,Azerbaijan (Republic of)
|
||||
425,Iraq (Republic of)
|
||||
428,Israel (State of)
|
||||
431,Japan
|
||||
432,Japan
|
||||
434,Turkmenistan
|
||||
436,Kazakhstan (Republic of)
|
||||
437,Uzbekistan (Republic of)
|
||||
438,Jordan (Hashemite Kingdom of)
|
||||
440,Korea (Republic of)
|
||||
441,Korea (Republic of)
|
||||
443,"State of Palestine (In accordance with Resolution 99 Rev. Dubai, 2018)"
|
||||
445,Democratic People's Republic of Korea
|
||||
447,Kuwait (State of)
|
||||
450,Lebanon
|
||||
451,Kyrgyz Republic
|
||||
453,China (People's Republic of) - Macao (Special Administrative Region of China)
|
||||
455,Maldives (Republic of)
|
||||
457,Mongolia
|
||||
459,Nepal (Federal Democratic Republic of)
|
||||
461,Oman (Sultanate of)
|
||||
463,Pakistan (Islamic Republic of)
|
||||
466,Qatar (State of)
|
||||
468,Syrian Arab Republic
|
||||
470,United Arab Emirates
|
||||
471,United Arab Emirates
|
||||
472,Tajikistan (Republic of)
|
||||
473,Yemen (Republic of)
|
||||
475,Yemen (Republic of)
|
||||
477,China (People's Republic of) - Hong Kong (Special Administrative Region of China)
|
||||
478,Bosnia and Herzegovina
|
||||
501,France - Adelie Land
|
||||
503,Australia
|
||||
506,Myanmar (Union of)
|
||||
508,Brunei Darussalam
|
||||
510,Micronesia (Federated States of)
|
||||
511,Palau (Republic of)
|
||||
512,New Zealand
|
||||
514,Cambodia (Kingdom of)
|
||||
515,Cambodia (Kingdom of)
|
||||
516,Australia - Christmas Island (Indian Ocean)
|
||||
518,New Zealand - Cook Islands
|
||||
520,Fiji (Republic of)
|
||||
523,Australia - Cocos (Keeling) Islands
|
||||
525,Indonesia (Republic of)
|
||||
529,Kiribati (Republic of)
|
||||
531,Lao People's Democratic Republic
|
||||
533,Malaysia
|
||||
536,United States of America - Northern Mariana Islands (Commonwealth of the)
|
||||
538,Marshall Islands (Republic of the)
|
||||
540,France - New Caledonia
|
||||
542,New Zealand - Niue
|
||||
544,Nauru (Republic of)
|
||||
546,France - French Polynesia
|
||||
548,Philippines (Republic of the)
|
||||
550,Timor-Leste (Democratic Republic of)
|
||||
553,Papua New Guinea
|
||||
555,United Kingdom of Great Britain and Northern Ireland - Pitcairn Island
|
||||
557,Solomon Islands
|
||||
559,United States of America - American Samoa
|
||||
561,Samoa (Independent State of)
|
||||
563,Singapore (Republic of)
|
||||
564,Singapore (Republic of)
|
||||
565,Singapore (Republic of)
|
||||
566,Singapore (Republic of)
|
||||
567,Thailand
|
||||
570,Tonga (Kingdom of)
|
||||
572,Tuvalu
|
||||
574,Viet Nam (Socialist Republic of)
|
||||
576,Vanuatu (Republic of)
|
||||
577,Vanuatu (Republic of)
|
||||
578,France - Wallis and Futuna Islands
|
||||
601,South Africa (Republic of)
|
||||
603,Angola (Republic of)
|
||||
605,Algeria (People's Democratic Republic of)
|
||||
607,France - Saint Paul and Amsterdam Islands
|
||||
608,United Kingdom of Great Britain and Northern Ireland - Ascension Island
|
||||
609,Burundi (Republic of)
|
||||
610,Benin (Republic of)
|
||||
611,Botswana (Republic of)
|
||||
612,Central African Republic
|
||||
613,Cameroon (Republic of)
|
||||
615,Congo (Republic of the)
|
||||
616,Comoros (Union of the)
|
||||
617,Cabo Verde (Republic of)
|
||||
618,France - Crozet Archipelago
|
||||
619,Côte d'Ivoire (Republic of)
|
||||
620,Comoros (Union of the)
|
||||
621,Djibouti (Republic of)
|
||||
622,Egypt (Arab Republic of)
|
||||
624,Ethiopia (Federal Democratic Republic of)
|
||||
625,Eritrea
|
||||
626,Gabonese Republic
|
||||
627,Ghana
|
||||
629,Gambia (Republic of the)
|
||||
630,Guinea-Bissau (Republic of)
|
||||
631,Equatorial Guinea (Republic of)
|
||||
632,Guinea (Republic of)
|
||||
633,Burkina Faso
|
||||
634,Kenya (Republic of)
|
||||
635,France - Kerguelen Islands
|
||||
636,Liberia (Republic of)
|
||||
637,Liberia (Republic of)
|
||||
638,South Sudan (Republic of)
|
||||
642,Libya (State of)
|
||||
644,Lesotho (Kingdom of)
|
||||
645,Mauritius (Republic of)
|
||||
647,Madagascar (Republic of)
|
||||
649,Mali (Republic of)
|
||||
650,Mozambique (Republic of)
|
||||
654,Mauritania (Islamic Republic of)
|
||||
655,Malawi
|
||||
656,Niger (Republic of the)
|
||||
657,Nigeria (Federal Republic of)
|
||||
659,Namibia (Republic of)
|
||||
660,France - Reunion (French Department of)
|
||||
661,Rwanda (Republic of)
|
||||
662,Sudan (Republic of the)
|
||||
663,Senegal (Republic of)
|
||||
664,Seychelles (Republic of)
|
||||
665,United Kingdom of Great Britain and Northern Ireland - Saint Helena
|
||||
666,Somalia (Federal Republic of)
|
||||
667,Sierra Leone
|
||||
668,Sao Tome and Principe (Democratic Republic of)
|
||||
669,Eswatini (Kingdom of)
|
||||
670,Chad (Republic of)
|
||||
671,Togolese Republic
|
||||
672,Tunisia
|
||||
674,Tanzania (United Republic of)
|
||||
675,Uganda (Republic of)
|
||||
676,Democratic Republic of the Congo
|
||||
677,Tanzania (United Republic of)
|
||||
678,Zambia (Republic of)
|
||||
679,Zimbabwe (Republic of)
|
||||
701,Argentine Republic
|
||||
710,Brazil (Federative Republic of)
|
||||
720,Bolivia (Plurinational State of)
|
||||
725,Chile
|
||||
730,Colombia (Republic of)
|
||||
735,Ecuador
|
||||
740,United Kingdom of Great Britain and Northern Ireland - Falkland Islands (Malvinas)
|
||||
745,France - Guiana (French Department of)
|
||||
750,Guyana
|
||||
755,Paraguay (Republic of)
|
||||
760,Peru
|
||||
765,Suriname (Republic of)
|
||||
770,Uruguay (Eastern Republic of)
|
||||
775,Venezuela (Bolivarian Republic of)
|
|
@ -0,0 +1,13 @@
|
||||
# Make mids.db
|
||||
|
||||
Licensed under [GNU GPL v3](../../../LICENSE)
|
||||
|
||||
Python3 script creates a MID (Marine Identification Digit) database.
|
||||
MID is part of MMSI and determines (among other things) the conutry.
|
||||
|
||||
|
||||
USAGE:
|
||||
- Copy Excel file from https://www.itu.int/en/ITU-R/terrestrial/fmd/Pages/mid.aspx
|
||||
- Convert it to a csv document
|
||||
- Run Python 3 script: `./make_mids_db.py`
|
||||
- Copy file to /AIS folder on SDCARD
|
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2022 ArjanOnwezen
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# -------------------------------------------------------------------------------------
|
||||
# Create mids.db, used for AIS receiver application, using converted Excel file on page:
|
||||
# https://www.itu.int/en/ITU-R/terrestrial/fmd/Pages/mid.aspx
|
||||
# as a source.
|
||||
# MID stands for Marine Identification Digits and can be used to determine conutry of
|
||||
# vessel or coastal station.
|
||||
# -------------------------------------------------------------------------------------
|
||||
import csv
|
||||
import re
|
||||
import unicodedata
|
||||
mid_codes=bytearray()
|
||||
countries=bytearray()
|
||||
row_count=0
|
||||
|
||||
database=open("mids.db", "wb")
|
||||
|
||||
with open('MaritimeIdentificationDigits.csv', 'rt') as csv_file:
|
||||
sorted_lines=sorted(csv_file.readlines())
|
||||
|
||||
for row in csv.reader(sorted_lines, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True):
|
||||
mid_code=row[0]
|
||||
# Normalize some unicode characters
|
||||
#unicodedata.normalize('NFKD', row[3][:32]).encode('ascii', 'ignore')
|
||||
country=unicodedata.normalize('NFKD', "".join(re.split("\(|\)|\[|\]", row[1].split('-')[-1].replace(" of Great Britain and Northern Ireland" , ""))[::2])).replace("Democratic People's Republic of Korea", "North-Korea").strip().encode('ascii', 'ignore')[:32]
|
||||
if len(mid_code) == 3 :
|
||||
country_padding=bytearray()
|
||||
print(mid_code,' - ', country)
|
||||
mid_codes=mid_codes+bytearray(mid_code+'\0', encoding='ascii')
|
||||
country_padding=bytearray('\0' * (32 - len(country)), encoding='ascii')
|
||||
countries=countries+country+country_padding
|
||||
row_count+=1
|
||||
|
||||
database.write(mid_codes+countries)
|
||||
print("Total of", row_count, "MID codes stored in database")
|
||||
|
80
Software/portapack-mayhem/firmware/tools/make_spi_image.py
Normal file
80
Software/portapack-mayhem/firmware/tools/make_spi_image.py
Normal file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
#
|
||||
# This file is part of PortaPack.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
import sys
|
||||
|
||||
usage_message = """
|
||||
PortaPack SPI flash image generator
|
||||
|
||||
Usage: <command> <application_path> <baseband_path> <output_path>
|
||||
Where paths refer to the .bin files for each component project.
|
||||
"""
|
||||
|
||||
def read_image(path):
|
||||
f = open(path, 'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
return data
|
||||
|
||||
def write_image(data, path):
|
||||
f = open(path, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print(usage_message)
|
||||
sys.exit(-1)
|
||||
|
||||
application_image = read_image(sys.argv[1])
|
||||
baseband_image = read_image(sys.argv[2])
|
||||
output_path = sys.argv[3]
|
||||
|
||||
spi_size = 1048576
|
||||
|
||||
images = (
|
||||
{
|
||||
'name': 'application',
|
||||
'data': application_image,
|
||||
'size': len(application_image),
|
||||
},
|
||||
{
|
||||
'name': 'baseband',
|
||||
'data': baseband_image,
|
||||
'size': len(baseband_image),
|
||||
},
|
||||
)
|
||||
|
||||
spi_image = bytearray()
|
||||
spi_image_default_byte = bytearray((255,))
|
||||
|
||||
for image in images:
|
||||
if len(image['data']) > image['size']:
|
||||
raise RuntimeError('data for image "%(name)s" is longer than 0x%(size)x bytes 0x%(sz)x' % {'name':image['name'], 'size':image['size'], 'sz':len(image['data'])})
|
||||
pad_size = image['size'] - len(image['data'])
|
||||
padded_data = image['data'] + (spi_image_default_byte * pad_size)
|
||||
spi_image += padded_data
|
||||
|
||||
if len(spi_image) > spi_size:
|
||||
raise RuntimeError('SPI flash image size of %d exceeds device size of %d bytes' % (len(spi_image), spi_size))
|
||||
|
||||
write_image(spi_image, output_path)
|
Reference in New Issue
Block a user