Fixed freeze in TouchTunes scan

Made adsb_map.py compatible with Python 3
This commit is contained in:
furrtek 2017-11-08 21:08:46 +01:00
parent d517bc31ec
commit 196518457f
8 changed files with 80 additions and 37 deletions

View File

@ -27,6 +27,7 @@
//TEST: Check AFSK transmit end, skips last bits ? //TEST: Check AFSK transmit end, skips last bits ?
//TEST: Imperial in whipcalc //TEST: Imperial in whipcalc
//BUG: Auto backlight off doesn't work anymore
//BUG: CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay //BUG: CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay
//BUG: REPLAY See what's wrong with quality (format, or need for interpolation filter ?) //BUG: REPLAY See what's wrong with quality (format, or need for interpolation filter ?)
//BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one //BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one
@ -59,24 +60,7 @@ Continuous (Fox-oring)
60s transmit, 240s space (Classic 1/5 min) 60s transmit, 240s space (Classic 1/5 min)
60s transmit, 360s space (Classic 1/7 min) 60s transmit, 360s space (Classic 1/7 min)
*/ */
<<<<<<< ./firmware/application/main_LOCAL_5232.cpp
||||||| ./firmware/application/main_BASE_5232.cpp
//TODO: Use TransmitterView in TEDI/LCR, Numbers, ...
=======
//TODO: Use TransmitterView in TEDI/LCR, Numbers, ...
//TODO: Use TransmitterView in TEDI/LCR, Numbers, ...
>>>>>>> ./firmware/application/main_REMOTE_5232.cpp
//TODO: FreqMan: Remove and rename categories //TODO: FreqMan: Remove and rename categories
<<<<<<< ./firmware/application/main_LOCAL_5232.cpp
||||||| ./firmware/application/main_BASE_5232.cpp
//TODO: Wav visualizer
//TODO: File browser view ?
=======
//TODO: Wav visualizer
//TODO: File browser view ?
//TODO: Wav visualizer
//TODO: File browser view ?
>>>>>>> ./firmware/application/main_REMOTE_5232.cpp
//TODO: Mousejack ? //TODO: Mousejack ?
//TODO: Move frequencykeypad from ui_receiver to ui_widget (used everywhere) //TODO: Move frequencykeypad from ui_receiver to ui_widget (used everywhere)
//TODO: ADS-B draw trajectory + GPS coordinates + scale, and playback //TODO: ADS-B draw trajectory + GPS coordinates + scale, and playback

View File

@ -204,10 +204,10 @@ SoundBoardView::SoundBoardView(
sounds[c].size = reader->data_size(); sounds[c].size = reader->data_size();
sounds[c].sample_duration = reader->data_size(); // / (reader->bits_per_sample() / 8); sounds[c].sample_duration = reader->data_size(); // / (reader->bits_per_sample() / 8);
sounds[c].sample_rate = reader->sample_rate(); sounds[c].sample_rate = reader->sample_rate();
/*if (reader->bits_per_sample() > 8) //if (reader->bits_per_sample() > 8)
sounds[c].sixteenbit = true; // sounds[c].sixteenbit = true;
else //else
sounds[c].sixteenbit = false;*/ // sounds[c].sixteenbit = false;
sounds[c].ms_duration = reader->ms_duration(); sounds[c].ms_duration = reader->ms_duration();
sounds[c].path = u"WAV/" + path.native(); sounds[c].path = u"WAV/" + path.native();
title = reader->title().substr(0, 20); title = reader->title().substr(0, 20);

View File

@ -28,6 +28,16 @@ using namespace portapack;
#include "string_format.hpp" #include "string_format.hpp"
void TestLogger::log_raw_data(const testapp::Packet& packet, const int32_t alt) {
std::string entry = to_string_dec_uint(packet.value()) + " " + to_string_dec_int(alt);
// Raw hex dump
//for (size_t c = 0; c < 10; c++)
// entry += to_string_hex(packet[c], 8) + " ";
log_file.write_entry(packet.received_at(), entry);
}
namespace ui { namespace ui {
TestView::TestView(NavigationView& nav) { TestView::TestView(NavigationView& nav) {
@ -41,7 +51,9 @@ TestView::TestView(NavigationView& nav) {
&field_vga, &field_vga,
&rssi, &rssi,
&text_debug_a, &text_debug_a,
&text_debug_b &text_debug_b,
&button_cal,
&check_log
}); });
field_frequency.set_value(target_frequency_); field_frequency.set_value(target_frequency_);
@ -59,6 +71,19 @@ TestView::TestView(NavigationView& nav) {
}; };
}; };
check_log.on_select = [this](Checkbox&, bool v) {
logging = v;
};
button_cal.on_select = [this](Button&) {
cal_value = raw_alt - 0x80;
};
logger = std::make_unique<TestLogger>();
if (logger)
logger->append("saucepan.txt");
radio::enable({ radio::enable({
tuning_frequency(), tuning_frequency(),
sampling_rate, sampling_rate,
@ -85,7 +110,7 @@ void TestView::on_packet(const testapp::Packet& packet) {
packet_count++; packet_count++;
uint32_t diff = ((v - 1) - prev_v); uint32_t diff = ((v - 1) - prev_v);
if (diff < 20) if (diff < 50)
packets_lost += diff; packets_lost += diff;
prev_v = v; prev_v = v;
@ -93,14 +118,18 @@ void TestView::on_packet(const testapp::Packet& packet) {
text_debug_b.set(to_string_dec_uint((packets_lost * 1000) / packet_count) + " per 1000"); text_debug_b.set(to_string_dec_uint((packets_lost * 1000) / packet_count) + " per 1000");
display.draw_pixel(Point(cur_x, 4 * 16 + (256 - packet.alt())), Color::white()); raw_alt = packet.alt();
display.draw_pixel(Point(cur_x, 4 * 16 + (256 - ((raw_alt - cal_value) / 4))), Color::white());
cur_x++; cur_x++;
if (cur_x >= 240) { if (cur_x >= 240) {
display.fill_rectangle(Rect(0, 4 * 16, 240, 256), Color::black()); display.fill_rectangle(Rect(0, 5 * 16, 240, 256), Color::black());
cur_x = 0; cur_x = 0;
} }
if (logger && logging)
logger->log_raw_data(packet, raw_alt - cal_value);
//radio::disable(); //radio::disable();
/*text_serial.set(packet.serial_number()); /*text_serial.set(packet.serial_number());

View File

@ -30,15 +30,28 @@
#include "event_m0.hpp" #include "event_m0.hpp"
#include "test_packet.hpp" #include "test_packet.hpp"
#include "log_file.hpp"
#include <cstddef> #include <cstddef>
#include <string> #include <string>
class TestLogger {
public:
Optional<File::Error> append(const std::string& filename) {
return log_file.append(filename);
}
void log_raw_data(const testapp::Packet& packet, const int32_t alt);
private:
LogFile log_file { };
};
namespace ui { namespace ui {
class TestView : public View { class TestView : public View {
public: public:
static constexpr uint32_t sampling_rate = 2457600; static constexpr uint32_t sampling_rate = 2457600*2;
static constexpr uint32_t baseband_bandwidth = 1750000; static constexpr uint32_t baseband_bandwidth = 1750000;
TestView(NavigationView& nav); TestView(NavigationView& nav);
@ -49,11 +62,14 @@ public:
std::string title() const override { return "Test app"; }; std::string title() const override { return "Test app"; };
private: private:
uint32_t target_frequency_ { 439255000 }; uint32_t target_frequency_ { 439206000 };
Coord cur_x { 0 }; Coord cur_x { 0 };
uint32_t packet_count { 0 }; uint32_t packet_count { 0 };
uint32_t packets_lost { 0 }; uint32_t packets_lost { 0 };
uint32_t prev_v { 0 }; uint32_t prev_v { 0 };
uint32_t raw_alt { 0 };
uint32_t cal_value { 0 };
bool logging { false };
Labels labels { Labels labels {
{ { 0 * 8, 1 * 16 }, "Data:", Color::light_grey() } { { 0 * 8, 1 * 16 }, "Data:", Color::light_grey() }
@ -79,13 +95,25 @@ private:
}; };
Text text_debug_a { Text text_debug_a {
{ 0 * 8, 2 * 16, 30 * 8, 16 }, { 0 * 8, 4 * 16, 30 * 8, 16 },
"..." "..."
}; };
Text text_debug_b { Text text_debug_b {
{ 0 * 8, 3 * 16, 30 * 8, 16 }, { 0 * 8, 5 * 16, 30 * 8, 16 },
"..." "..."
}; };
Button button_cal {
{ 17 * 8, 2 * 16, 5 * 8, 2 * 16 },
"CAL"
};
Checkbox check_log {
{ 23 * 8, 2 * 16 },
3,
"LOG"
};
std::unique_ptr<TestLogger> logger { };
MessageHandlerRegistration message_handler_packet { MessageHandlerRegistration message_handler_packet {
Message::ID::TestAppPacket, Message::ID::TestAppPacket,

View File

@ -62,6 +62,7 @@ void TouchTunesView::on_tx_progress(const uint32_t progress, const bool done) {
if (pin == TOUCHTUNES_MAX_PIN) { if (pin == TOUCHTUNES_MAX_PIN) {
stop_tx(); stop_tx();
} else { } else {
transmitter_model.disable();
pin++; pin++;
field_pin.set_value(pin); field_pin.set_value(pin);
start_tx(scan_button_index); start_tx(scan_button_index);
@ -71,9 +72,9 @@ void TouchTunesView::on_tx_progress(const uint32_t progress, const bool done) {
} }
void TouchTunesView::start_tx(const uint32_t button_index) { void TouchTunesView::start_tx(const uint32_t button_index) {
std::string fragments; std::string fragments = { "" };
size_t bit; size_t bit;
uint64_t frame_data { 0 }; uint64_t frame_data;
if (check_scan.value()) { if (check_scan.value()) {
scan_button_index = button_index; scan_button_index = button_index;

View File

@ -50,7 +50,7 @@ public:
void execute(const buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
private: private:
static constexpr size_t baseband_fs = 2457600; static constexpr size_t baseband_fs = 2457600*2;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive }; BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 }; RSSIThread rssi_thread { NORMALPRIO + 10 };
@ -66,7 +66,7 @@ private:
dsp::matched_filter::MatchedFilter mf { baseband::ais::square_taps_38k4_1t_p, 2 }; dsp::matched_filter::MatchedFilter mf { baseband::ais::square_taps_38k4_1t_p, 2 };
clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery_fsk_9600 { clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery_fsk_9600 {
19200, 9600, { 0.00555f }, 38400, 19192, { 0.00555f },
[this](const float raw_symbol) { [this](const float raw_symbol) {
const uint_fast8_t sliced_symbol = (raw_symbol >= 0.0f) ? 1 : 0; const uint_fast8_t sliced_symbol = (raw_symbol >= 0.0f) ? 1 : 0;
this->packet_builder_fsk_9600_CC1101.execute(sliced_symbol); this->packet_builder_fsk_9600_CC1101.execute(sliced_symbol);
@ -75,7 +75,7 @@ private:
PacketBuilder<BitPattern, NeverMatch, FixedLength> packet_builder_fsk_9600_CC1101 { PacketBuilder<BitPattern, NeverMatch, FixedLength> packet_builder_fsk_9600_CC1101 {
{ 0b01010110010110100101101001101010, 32, 1 }, // Manchester 0x1337 { 0b01010110010110100101101001101010, 32, 1 }, // Manchester 0x1337
{ }, { },
{ 10 * 8 }, { 22 * 8 },
[this](const baseband::Packet& packet) { [this](const baseband::Packet& packet) {
const TestAppPacketMessage message { packet }; const TestAppPacketMessage message { packet };
shared_memory.application_queue.push(message); shared_memory.application_queue.push(message);

View File

@ -42,11 +42,11 @@ FormattedSymbols Packet::symbols_formatted() const {
} }
uint32_t Packet::value() const { uint32_t Packet::value() const {
return reader_.read(3 * 8, 8); return (reader_.read(10 * 8, 6) << 8) | reader_.read(9 * 8, 8);
} }
uint32_t Packet::alt() const { uint32_t Packet::alt() const {
return reader_.read(1 * 8, 12) - 0xC00; return reader_.read(1 * 8, 12);
} }
} /* namespace testapp */ } /* namespace testapp */

View File

@ -18,6 +18,7 @@
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
# #
from __future__ import print_function
import sys import sys
import struct import struct
from PIL import Image from PIL import Image
@ -38,4 +39,4 @@ for y in range (0, im.size[1]):
pixel_lcd |= (pix[x, y][2] >> 3) pixel_lcd |= (pix[x, y][2] >> 3)
line += struct.pack('H', pixel_lcd) line += struct.pack('H', pixel_lcd)
outfile.write(line) outfile.write(line)
print str(y) + '/' + str(im.size[1]) + '\r', print(str(y) + '/' + str(im.size[1]) + '\r', end="")