Skip to content

Commit 09c2c43

Browse files
authored
acars to ext but disabled (#2288)
1 parent b9771b2 commit 09c2c43

14 files changed

+349
-291
lines changed

firmware/application/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ file(GLOB I2CDEV_SOURCES ${COMMON}/i2cdev_*.cpp)
133133
set(CPPSRC
134134
main.cpp
135135
shell.cpp
136-
${COMMON}/acars_packet.cpp
137136
${COMMON}/adsb.cpp
138137
${COMMON}/adsb_frame.cpp
139138
${COMMON}/ais_baseband.cpp
@@ -269,7 +268,6 @@ set(CPPSRC
269268
ui/ui_tone_key.cpp
270269
ui/ui_transmitter.cpp
271270
ui/ui_bmpview.cpp
272-
apps/acars_app.cpp
273271
apps/ais_app.cpp
274272
apps/analog_audio_app.cpp
275273
# apps/analog_tv_app.cpp

firmware/application/apps/acars_app.cpp firmware/application/external/acars_rx/acars_app.cpp

+34-47
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,34 @@
2020
* Boston, MA 02110-1301, USA.
2121
*/
2222

23-
#include "acars_app.hpp"
24-
2523
#include "baseband_api.hpp"
2624
#include "portapack_persistent_memory.hpp"
2725
#include "file_path.hpp"
26+
#include "audio.hpp"
2827

28+
#include "acars_app.hpp"
2929
using namespace portapack;
30-
using namespace acars;
3130

3231
#include "string_format.hpp"
3332
#include "utility.hpp"
3433

35-
void ACARSLogger::log_raw_data(const acars::Packet& packet, const uint32_t frequency) {
36-
(void)frequency;
37-
std::string entry{}; //= "Raw: F:" + to_string_dec_uint(frequency) + "Hz ";
38-
entry.reserve(256);
39-
40-
// Raw hex dump of all the bytes
41-
// for (size_t c = 0; c < packet.length(); c += 32)
42-
// entry += to_string_hex(packet.read(c, 32), 8) + " ";
34+
namespace ui::external_app::acars_rx {
4335

44-
for (size_t c = 0; c < 256; c += 32)
45-
entry += to_string_bin(packet.read(c, 32), 32);
46-
47-
log_file.write_entry(packet.received_at(), entry);
36+
void ACARSLogger::log_str(std::string msg) {
37+
log_file.write_entry(msg);
4838
}
4939

50-
/*void ACARSLogger::log_decoded(
51-
const acars::Packet& packet,
52-
const std::string text) {
53-
54-
log_file.write_entry(packet.timestamp(), text);
55-
}*/
56-
57-
namespace ui {
58-
5940
ACARSAppView::ACARSAppView(NavigationView& nav)
6041
: nav_{nav} {
61-
baseband::run_image(portapack::spi_flash::image_tag_acars);
42+
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
6243

6344
add_children({&rssi,
6445
&channel,
6546
&field_rf_amp,
6647
&field_lna,
6748
&field_vga,
6849
&field_frequency,
50+
&field_volume,
6951
&check_log,
7052
&console});
7153

@@ -79,6 +61,9 @@ ACARSAppView::ACARSAppView(NavigationView& nav)
7961
logger = std::make_unique<ACARSLogger>();
8062
if (logger)
8163
logger->append(logs_dir / u"ACARS.TXT");
64+
65+
audio::set_rate(audio::Rate::Hz_24000);
66+
audio::output::start();
8267
}
8368

8469
ACARSAppView::~ACARSAppView() {
@@ -90,29 +75,31 @@ void ACARSAppView::focus() {
9075
field_frequency.focus();
9176
}
9277

93-
void ACARSAppView::on_packet(const acars::Packet& packet) {
78+
void ACARSAppView::on_packet(const ACARSPacketMessage* packet) {
9479
std::string console_info;
9580

96-
/*if (!packet.is_valid()) {
97-
console_info = to_string_datetime(packet.received_at(), HMS);
98-
console_info += " INVALID";
99-
100-
console.writeln(console_info);
101-
} else {
102-
console_info = to_string_datetime(packet.received_at(), HMS);
103-
console_info += ":" + to_string_bin(packet.read(0, 32), 32);
104-
//console_info += " REG:" + packet.registration_number();
105-
106-
console.writeln(console_info);
107-
}*/
108-
109-
packet_counter++;
110-
if (packet_counter % 10 == 0)
111-
console.writeln("Block #" + to_string_dec_uint(packet_counter));
112-
113-
// Log raw data whatever it contains
114-
if (logger && logging)
115-
logger->log_raw_data(packet, receiver_model.target_frequency());
81+
if (packet->state == 255) {
82+
// got a packet, parse it, and display
83+
rtc::RTC datetime;
84+
rtc_time::now(datetime);
85+
// todo parity error recovery
86+
console_info = to_string_datetime(datetime, HMS);
87+
console_info += ": ";
88+
console_info += packet->message;
89+
console.writeln(console_info);
90+
// Log raw data whatever it contains
91+
if (logger && logging)
92+
logger->log_str(console_info);
93+
} else {
94+
// debug message arrived
95+
console_info = "State: ";
96+
console_info += to_string_dec_int(packet->state);
97+
console_info += " lastbyte: ";
98+
console_info += to_string_dec_uint(packet->message[0]);
99+
console.writeln(console_info);
100+
if (logger && logging)
101+
logger->log_str(console_info);
102+
}
116103
}
117104

118-
} /* namespace ui */
105+
} // namespace ui::external_app::acars_rx

firmware/application/apps/acars_app.hpp firmware/application/external/acars_rx/acars_app.hpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,32 @@
3131
#include "ui_rssi.hpp"
3232
#include "log_file.hpp"
3333

34-
#include "acars_packet.hpp"
34+
namespace ui::external_app::acars_rx {
3535

3636
class ACARSLogger {
3737
public:
3838
Optional<File::Error> append(const std::filesystem::path& filename) {
3939
return log_file.append(filename);
4040
}
41-
42-
void log_raw_data(const acars::Packet& packet, const uint32_t frequency);
43-
// void log_decoded(const acars::Packet& packet, const std::string text);
41+
void log_str(std::string msg);
4442

4543
private:
4644
LogFile log_file{};
4745
};
4846

49-
namespace ui {
50-
5147
class ACARSAppView : public View {
5248
public:
5349
ACARSAppView(NavigationView& nav);
5450
~ACARSAppView();
5551

5652
void focus() override;
5753

58-
std::string title() const override { return "ACARS (WIP)"; };
54+
std::string title() const override { return "ACARS"; };
5955

6056
private:
6157
NavigationView& nav_;
6258
RxRadioState radio_state_{
63-
131550000 /* frequency */,
59+
131825000 /* frequency */,
6460
1750000 /* bandwidth */,
6561
2457600 /* sampling rate */
6662
};
@@ -85,27 +81,29 @@ class ACARSAppView : public View {
8581
{0 * 8, 0 * 8},
8682
nav_};
8783
Checkbox check_log{
88-
{22 * 8, 21},
84+
{16 * 8, 1 * 16},
8985
3,
9086
"LOG",
9187
true};
9288

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

92+
AudioVolumeField field_volume{
93+
{28 * 8, 1 * 16}};
94+
9695
std::unique_ptr<ACARSLogger> logger{};
9796

98-
void on_packet(const acars::Packet& packet);
97+
void on_packet(const ACARSPacketMessage* packet);
9998

10099
MessageHandlerRegistration message_handler_packet{
101100
Message::ID::ACARSPacket,
102101
[this](Message* const p) {
103102
const auto message = static_cast<const ACARSPacketMessage*>(p);
104-
const acars::Packet packet{message->packet};
105-
this->on_packet(packet);
103+
this->on_packet(message);
106104
}};
107105
};
108106

109-
} /* namespace ui */
107+
} // namespace ui::external_app::acars_rx
110108

111-
#endif /*__ACARS_APP_H__*/
109+
#endif /*__ACARS_APP_H__*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (C) 2023 Bernd Herzog
3+
*
4+
* This file is part of PortaPack.
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2, or (at your option)
9+
* any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; see the file COPYING. If not, write to
18+
* the Free Software Foundation, Inc., 51 Franklin Street,
19+
* Boston, MA 02110-1301, USA.
20+
*/
21+
22+
#include "ui.hpp"
23+
#include "acars_app.hpp"
24+
#include "ui_navigation.hpp"
25+
#include "external_app.hpp"
26+
27+
namespace ui::external_app::acars_rx {
28+
void initialize_app(ui::NavigationView& nav) {
29+
nav.push<ACARSAppView>();
30+
}
31+
} // namespace ui::external_app::acars_rx
32+
33+
extern "C" {
34+
35+
__attribute__((section(".external_app.app_acars_rx.application_information"), used)) application_information_t _application_information_acars_rx = {
36+
/*.memory_location = */ (uint8_t*)0x00000000,
37+
/*.externalAppEntry = */ ui::external_app::acars_rx::initialize_app,
38+
/*.header_version = */ CURRENT_HEADER_VERSION,
39+
/*.app_version = */ VERSION_MD5,
40+
41+
/*.app_name = */ "ACARS",
42+
/*.bitmap_data = */ {
43+
0x80,
44+
0x01,
45+
0xC0,
46+
0x03,
47+
0xC0,
48+
0x03,
49+
0xC0,
50+
0x03,
51+
0xC0,
52+
0x03,
53+
0xE0,
54+
0x07,
55+
0xF8,
56+
0x1F,
57+
0xFE,
58+
0x7F,
59+
0xFF,
60+
0xFF,
61+
0xFF,
62+
0xFF,
63+
0xC0,
64+
0x03,
65+
0xC0,
66+
0x03,
67+
0xC0,
68+
0x03,
69+
0xE0,
70+
0x07,
71+
0xF0,
72+
0x0F,
73+
0xF8,
74+
0x1F,
75+
},
76+
/*.icon_color = */ ui::Color::orange().v,
77+
/*.menu_location = */ app_location_t::RX,
78+
79+
/*.m4_app_tag = portapack::spi_flash::image_tag_acars */ {'P', 'A', 'C', 'A'},
80+
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
81+
};
82+
}

firmware/application/external/external.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ set(EXTCPPSRC
102102
external/random_password/ui_random_password.cpp
103103
external/random_password/sha512.cpp
104104
external/random_password/sha512.h
105+
106+
#acars
107+
external/acars_rx/main.cpp
108+
external/acars_rx/acars_app.cpp
109+
105110
)
106111

107112
set(EXTAPPLIST
@@ -129,4 +134,5 @@ set(EXTAPPLIST
129134
morse_tx
130135
sstvtx
131136
random_password
137+
#acars_rx
132138
)

firmware/application/external/external.ld

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ MEMORY
4747
ram_external_app_morse_tx(rwx) : org = 0xADC60000, len = 32k
4848
ram_external_app_sstvtx(rwx) : org = 0xADC70000, len = 32k
4949
ram_external_app_random_password(rwx) : org = 0xADC80000, len = 32k
50+
ram_external_app_acars_rx(rwx) : org = 0xADC90000, len = 32k
5051
}
5152

5253
SECTIONS
@@ -197,4 +198,13 @@ SECTIONS
197198
*(*ui*external_app*random_password*);
198199
} > ram_external_app_random_password
199200

201+
.external_app_acars_rx : ALIGN(4) SUBALIGN(4)
202+
{
203+
KEEP(*(.external_app.app_acars_rx.application_information));
204+
*(*ui*external_app*acars_rx*);
205+
} > ram_external_app_acars_rx
206+
207+
208+
209+
200210
}

firmware/application/ui_navigation.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
#include "ui_battinfo.hpp"
8787
#include "ui_external_items_menu_loader.hpp"
8888

89-
// #include "acars_app.hpp"
9089
#include "ais_app.hpp"
9190
#include "analog_audio_app.hpp"
9291
// #include "analog_tv_app.hpp" //moved to ext
@@ -157,7 +156,6 @@ const NavigationView::AppList NavigationView::appList = {
157156
{nullptr, "Debug", HOME, Color::light_grey(), &bitmap_icon_debug, new ViewFactory<DebugMenuView>()},
158157
//{"about", "About", HOME, Color::cyan(), nullptr, new ViewFactory<AboutView>()},
159158
/* RX ********************************************************************/
160-
//{"acars", "ACARS", RX, Color::yellow(), &bitmap_icon_adsb, new ViewFactory<ACARSAppView>()},
161159
{"adsbrx", "ADS-B", RX, Color::green(), &bitmap_icon_adsb, new ViewFactory<ADSBRxView>()},
162160
{"ais", "AIS Boats", RX, Color::green(), &bitmap_icon_ais, new ViewFactory<AISAppView>()},
163161
{"aprsrx", "APRS", RX, Color::green(), &bitmap_icon_aprs, new ViewFactory<APRSRXView>()},

firmware/baseband/CMakeLists.txt

+9-6
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,6 @@ endmacro()
314314

315315
set(add_to_firmware TRUE)
316316

317-
### ACARS RX
318-
319-
set(MODE_CPPSRC
320-
proc_acars.cpp
321-
)
322-
DeclareTargets(PACA acars)
323317

324318
### ADS-B RX
325319

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

576+
577+
### ACARS RX
578+
579+
set(MODE_CPPSRC
580+
proc_acars.cpp
581+
)
582+
DeclareTargets(PACA acars)
583+
584+
582585
### AFSK RX
583586

584587
set(MODE_CPPSRC

0 commit comments

Comments
 (0)