Skip to content

Commit

Permalink
acars to ext but disabled (#2288)
Browse files Browse the repository at this point in the history
  • Loading branch information
htotoo authored Oct 7, 2024
1 parent b9771b2 commit 09c2c43
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 291 deletions.
2 changes: 0 additions & 2 deletions firmware/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ file(GLOB I2CDEV_SOURCES ${COMMON}/i2cdev_*.cpp)
set(CPPSRC
main.cpp
shell.cpp
${COMMON}/acars_packet.cpp
${COMMON}/adsb.cpp
${COMMON}/adsb_frame.cpp
${COMMON}/ais_baseband.cpp
Expand Down Expand Up @@ -269,7 +268,6 @@ set(CPPSRC
ui/ui_tone_key.cpp
ui/ui_transmitter.cpp
ui/ui_bmpview.cpp
apps/acars_app.cpp
apps/ais_app.cpp
apps/analog_audio_app.cpp
# apps/analog_tv_app.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,34 @@
* Boston, MA 02110-1301, USA.
*/

#include "acars_app.hpp"

#include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp"
#include "file_path.hpp"
#include "audio.hpp"

#include "acars_app.hpp"
using namespace portapack;
using namespace acars;

#include "string_format.hpp"
#include "utility.hpp"

void ACARSLogger::log_raw_data(const acars::Packet& packet, const uint32_t frequency) {
(void)frequency;
std::string entry{}; //= "Raw: F:" + to_string_dec_uint(frequency) + "Hz ";
entry.reserve(256);

// Raw hex dump of all the bytes
// for (size_t c = 0; c < packet.length(); c += 32)
// entry += to_string_hex(packet.read(c, 32), 8) + " ";
namespace ui::external_app::acars_rx {

for (size_t c = 0; c < 256; c += 32)
entry += to_string_bin(packet.read(c, 32), 32);

log_file.write_entry(packet.received_at(), entry);
void ACARSLogger::log_str(std::string msg) {
log_file.write_entry(msg);
}

/*void ACARSLogger::log_decoded(
const acars::Packet& packet,
const std::string text) {
log_file.write_entry(packet.timestamp(), text);
}*/

namespace ui {

ACARSAppView::ACARSAppView(NavigationView& nav)
: nav_{nav} {
baseband::run_image(portapack::spi_flash::image_tag_acars);
baseband::run_prepared_image(portapack::memory::map::m4_code.base());

add_children({&rssi,
&channel,
&field_rf_amp,
&field_lna,
&field_vga,
&field_frequency,
&field_volume,
&check_log,
&console});

Expand All @@ -79,6 +61,9 @@ ACARSAppView::ACARSAppView(NavigationView& nav)
logger = std::make_unique<ACARSLogger>();
if (logger)
logger->append(logs_dir / u"ACARS.TXT");

audio::set_rate(audio::Rate::Hz_24000);
audio::output::start();
}

ACARSAppView::~ACARSAppView() {
Expand All @@ -90,29 +75,31 @@ void ACARSAppView::focus() {
field_frequency.focus();
}

void ACARSAppView::on_packet(const acars::Packet& packet) {
void ACARSAppView::on_packet(const ACARSPacketMessage* packet) {
std::string console_info;

/*if (!packet.is_valid()) {
console_info = to_string_datetime(packet.received_at(), HMS);
console_info += " INVALID";
console.writeln(console_info);
} else {
console_info = to_string_datetime(packet.received_at(), HMS);
console_info += ":" + to_string_bin(packet.read(0, 32), 32);
//console_info += " REG:" + packet.registration_number();
console.writeln(console_info);
}*/

packet_counter++;
if (packet_counter % 10 == 0)
console.writeln("Block #" + to_string_dec_uint(packet_counter));

// Log raw data whatever it contains
if (logger && logging)
logger->log_raw_data(packet, receiver_model.target_frequency());
if (packet->state == 255) {
// got a packet, parse it, and display
rtc::RTC datetime;
rtc_time::now(datetime);
// todo parity error recovery
console_info = to_string_datetime(datetime, HMS);
console_info += ": ";
console_info += packet->message;
console.writeln(console_info);
// Log raw data whatever it contains
if (logger && logging)
logger->log_str(console_info);
} else {
// debug message arrived
console_info = "State: ";
console_info += to_string_dec_int(packet->state);
console_info += " lastbyte: ";
console_info += to_string_dec_uint(packet->message[0]);
console.writeln(console_info);
if (logger && logging)
logger->log_str(console_info);
}
}

} /* namespace ui */
} // namespace ui::external_app::acars_rx
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,32 @@
#include "ui_rssi.hpp"
#include "log_file.hpp"

#include "acars_packet.hpp"
namespace ui::external_app::acars_rx {

class ACARSLogger {
public:
Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename);
}

void log_raw_data(const acars::Packet& packet, const uint32_t frequency);
// void log_decoded(const acars::Packet& packet, const std::string text);
void log_str(std::string msg);

private:
LogFile log_file{};
};

namespace ui {

class ACARSAppView : public View {
public:
ACARSAppView(NavigationView& nav);
~ACARSAppView();

void focus() override;

std::string title() const override { return "ACARS (WIP)"; };
std::string title() const override { return "ACARS"; };

private:
NavigationView& nav_;
RxRadioState radio_state_{
131550000 /* frequency */,
131825000 /* frequency */,
1750000 /* bandwidth */,
2457600 /* sampling rate */
};
Expand All @@ -85,27 +81,29 @@ class ACARSAppView : public View {
{0 * 8, 0 * 8},
nav_};
Checkbox check_log{
{22 * 8, 21},
{16 * 8, 1 * 16},
3,
"LOG",
true};

Console console{
{0, 3 * 16, 240, 256}};

AudioVolumeField field_volume{
{28 * 8, 1 * 16}};

std::unique_ptr<ACARSLogger> logger{};

void on_packet(const acars::Packet& packet);
void on_packet(const ACARSPacketMessage* packet);

MessageHandlerRegistration message_handler_packet{
Message::ID::ACARSPacket,
[this](Message* const p) {
const auto message = static_cast<const ACARSPacketMessage*>(p);
const acars::Packet packet{message->packet};
this->on_packet(packet);
this->on_packet(message);
}};
};

} /* namespace ui */
} // namespace ui::external_app::acars_rx

#endif /*__ACARS_APP_H__*/
#endif /*__ACARS_APP_H__*/
82 changes: 82 additions & 0 deletions firmware/application/external/acars_rx/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (C) 2023 Bernd Herzog
*
* 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.
*/

#include "ui.hpp"
#include "acars_app.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"

namespace ui::external_app::acars_rx {
void initialize_app(ui::NavigationView& nav) {
nav.push<ACARSAppView>();
}
} // namespace ui::external_app::acars_rx

extern "C" {

__attribute__((section(".external_app.app_acars_rx.application_information"), used)) application_information_t _application_information_acars_rx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::acars_rx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,

/*.app_name = */ "ACARS",
/*.bitmap_data = */ {
0x80,
0x01,
0xC0,
0x03,
0xC0,
0x03,
0xC0,
0x03,
0xC0,
0x03,
0xE0,
0x07,
0xF8,
0x1F,
0xFE,
0x7F,
0xFF,
0xFF,
0xFF,
0xFF,
0xC0,
0x03,
0xC0,
0x03,
0xC0,
0x03,
0xE0,
0x07,
0xF0,
0x0F,
0xF8,
0x1F,
},
/*.icon_color = */ ui::Color::orange().v,
/*.menu_location = */ app_location_t::RX,

/*.m4_app_tag = portapack::spi_flash::image_tag_acars */ {'P', 'A', 'C', 'A'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
6 changes: 6 additions & 0 deletions firmware/application/external/external.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ set(EXTCPPSRC
external/random_password/ui_random_password.cpp
external/random_password/sha512.cpp
external/random_password/sha512.h

#acars
external/acars_rx/main.cpp
external/acars_rx/acars_app.cpp

)

set(EXTAPPLIST
Expand Down Expand Up @@ -129,4 +134,5 @@ set(EXTAPPLIST
morse_tx
sstvtx
random_password
#acars_rx
)
10 changes: 10 additions & 0 deletions firmware/application/external/external.ld
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ MEMORY
ram_external_app_morse_tx(rwx) : org = 0xADC60000, len = 32k
ram_external_app_sstvtx(rwx) : org = 0xADC70000, len = 32k
ram_external_app_random_password(rwx) : org = 0xADC80000, len = 32k
ram_external_app_acars_rx(rwx) : org = 0xADC90000, len = 32k
}

SECTIONS
Expand Down Expand Up @@ -197,4 +198,13 @@ SECTIONS
*(*ui*external_app*random_password*);
} > ram_external_app_random_password

.external_app_acars_rx : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_acars_rx.application_information));
*(*ui*external_app*acars_rx*);
} > ram_external_app_acars_rx




}
2 changes: 0 additions & 2 deletions firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
#include "ui_battinfo.hpp"
#include "ui_external_items_menu_loader.hpp"

// #include "acars_app.hpp"
#include "ais_app.hpp"
#include "analog_audio_app.hpp"
// #include "analog_tv_app.hpp" //moved to ext
Expand Down Expand Up @@ -157,7 +156,6 @@ const NavigationView::AppList NavigationView::appList = {
{nullptr, "Debug", HOME, Color::light_grey(), &bitmap_icon_debug, new ViewFactory<DebugMenuView>()},
//{"about", "About", HOME, Color::cyan(), nullptr, new ViewFactory<AboutView>()},
/* RX ********************************************************************/
//{"acars", "ACARS", RX, Color::yellow(), &bitmap_icon_adsb, new ViewFactory<ACARSAppView>()},
{"adsbrx", "ADS-B", RX, Color::green(), &bitmap_icon_adsb, new ViewFactory<ADSBRxView>()},
{"ais", "AIS Boats", RX, Color::green(), &bitmap_icon_ais, new ViewFactory<AISAppView>()},
{"aprsrx", "APRS", RX, Color::green(), &bitmap_icon_aprs, new ViewFactory<APRSRXView>()},
Expand Down
15 changes: 9 additions & 6 deletions firmware/baseband/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,6 @@ endmacro()

set(add_to_firmware TRUE)

### ACARS RX

set(MODE_CPPSRC
proc_acars.cpp
)
DeclareTargets(PACA acars)

### ADS-B RX

Expand Down Expand Up @@ -579,6 +573,15 @@ DeclareTargets(PUSB sd_over_usb)
### Place external app and disabled images below so they don't get added to the firmware
set(add_to_firmware FALSE)


### ACARS RX

set(MODE_CPPSRC
proc_acars.cpp
)
DeclareTargets(PACA acars)


### AFSK RX

set(MODE_CPPSRC
Expand Down
Loading

0 comments on commit 09c2c43

Please sign in to comment.