Skip to content

Commit

Permalink
Added sil value ASDB (#2078)
Browse files Browse the repository at this point in the history
* Added sil value. resolves #2005

* readibility
  • Loading branch information
htotoo authored Apr 3, 2024
1 parent 804b7c8 commit 3665b3c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
11 changes: 7 additions & 4 deletions firmware/application/apps/ui_adsb_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ void ADSBLogger::log(const ADSBLogEntry& log_entry) {
log_line += " Type:" + to_string_dec_uint(log_entry.vel_type) +
" Hdg:" + to_string_dec_uint(log_entry.vel.heading) +
" Spd: " + to_string_dec_int(log_entry.vel.speed);

if (log_entry.sil != 0)
log_line += " Sil:" + to_string_dec_uint(log_entry.sil);
log_file.write_entry(log_line);
}

Expand Down Expand Up @@ -354,11 +355,12 @@ void ADSBRxDetailsView::refresh_ui() {

text_callsign.set(entry_.callsign);
text_infos.set(entry_.info_string);
std::string str_sil = (entry_.sil > 0) ? " Sil:" + to_string_dec_uint(entry_.sil) : "";
if (entry_.velo.heading < 360 && entry_.velo.speed >= 0)
text_info2.set("Hdg:" + to_string_dec_uint(entry_.velo.heading) +
" Spd:" + to_string_dec_int(entry_.velo.speed));
" Spd:" + to_string_dec_int(entry_.velo.speed) + str_sil);
else
text_info2.set("");
text_info2.set(str_sil);

text_frame_pos_even.set(to_string_hex_array(entry_.frame_pos_even.get_raw_data(), 14));
text_frame_pos_odd.set(to_string_hex_array(entry_.frame_pos_odd.get_raw_data(), 14));
Expand Down Expand Up @@ -471,14 +473,15 @@ void ADSBRxView::on_frame(const ADSBFrameMessage* message) {
"Alt:" + to_string_dec_int(entry.pos.altitude) +
" Lat:" + to_string_decimal(entry.pos.latitude, 2) +
" Lon:" + to_string_decimal(entry.pos.longitude, 2);

entry.set_info_string(std::move(str_info));
}

} else if (msg_type == AIRBORNE_VEL && msg_sub >= VEL_GND_SUBSONIC && msg_sub <= VEL_AIR_SUPERSONIC) {
entry.set_frame_velo(frame);
log_entry.vel = entry.velo;
log_entry.vel_type = msg_sub;
} else if (msg_type == AIRBORNE_OP_STATUS) { // for ver 1
entry.sil = frame.get_sil_value();
}
}

Expand Down
5 changes: 5 additions & 0 deletions firmware/application/apps/ui_adsb_rx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ namespace ui {
#define AIRBORNE_POS_GPS_L 20 // airborne position (lowest type id)
#define AIRBORNE_POS_GPS_H 22 // airborne position (highest type id)

#define AIRBORNE_OP_STATUS 31 // Aircraft operation status

#define RESERVED_L 23 // reserved for other uses
#define RESERVED_H 31 // reserved for other uses

Expand Down Expand Up @@ -102,6 +104,8 @@ struct AircraftRecentEntry {
std::string callsign{};
std::string info_string{};

uint8_t sil{0}; // Surveillance integrity level

AircraftRecentEntry(const uint32_t ICAO_address)
: ICAO_address{ICAO_address} {
this->icao_str = to_string_hex(ICAO_address, 6);
Expand Down Expand Up @@ -173,6 +177,7 @@ struct ADSBLogEntry {
adsb_pos pos{};
adsb_vel vel{};
uint8_t vel_type{};
uint8_t sil{};
};

// TODO: Make logging optional.
Expand Down
4 changes: 4 additions & 0 deletions firmware/common/adsb_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class ADSBFrame {
return (raw_data[4] & 7);
}

uint8_t get_sil_value() {
return ((raw_data[10] >> 6) & 0b11); // 83-84 bits
}

uint32_t get_ICAO_address() {
return (raw_data[1] << 16) + (raw_data[2] << 8) + raw_data[3];
}
Expand Down

0 comments on commit 3665b3c

Please sign in to comment.