1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

Add decode of Mode-A transonder (Squawk) code

This commit is contained in:
Jon Beniston 2020-11-10 12:03:36 +00:00
parent ea213bf6cc
commit 599c31493a
4 changed files with 50 additions and 19 deletions

View File

@ -61,16 +61,17 @@
#define ADSB_COL_LONGITUDE 11 #define ADSB_COL_LONGITUDE 11
#define ADSB_COL_CATEGORY 12 #define ADSB_COL_CATEGORY 12
#define ADSB_COL_STATUS 13 #define ADSB_COL_STATUS 13
#define ADSB_COL_REGISTRATION 14 #define ADSB_COL_SQUAWK 14
#define ADSB_COL_COUNTRY 15 #define ADSB_COL_REGISTRATION 15
#define ADSB_COL_REGISTERED 16 #define ADSB_COL_COUNTRY 16
#define ADSB_COL_MANUFACTURER 17 #define ADSB_COL_REGISTERED 17
#define ADSB_COL_OWNER 18 #define ADSB_COL_MANUFACTURER 18
#define ADSB_COL_OPERATOR_ICAO 19 #define ADSB_COL_OWNER 19
#define ADSB_COL_TIME 20 #define ADSB_COL_OPERATOR_ICAO 20
#define ADSB_COL_FRAMECOUNT 21 #define ADSB_COL_TIME 21
#define ADSB_COL_CORRELATION 22 #define ADSB_COL_FRAMECOUNT 22
#define ADSB_COL_RSSI 23 #define ADSB_COL_CORRELATION 23
#define ADSB_COL_RSSI 24
const char *Aircraft::m_speedTypeNames[] = { const char *Aircraft::m_speedTypeNames[] = {
"GS", "TAS", "IAS" "GS", "TAS", "IAS"
@ -617,6 +618,7 @@ void ADSBDemodGUI::handleADSB(
ui->adsbData->setItem(row, ADSB_COL_LONGITUDE, aircraft->m_longitudeItem); ui->adsbData->setItem(row, ADSB_COL_LONGITUDE, aircraft->m_longitudeItem);
ui->adsbData->setItem(row, ADSB_COL_CATEGORY, aircraft->m_emitterCategoryItem); ui->adsbData->setItem(row, ADSB_COL_CATEGORY, aircraft->m_emitterCategoryItem);
ui->adsbData->setItem(row, ADSB_COL_STATUS, aircraft->m_statusItem); ui->adsbData->setItem(row, ADSB_COL_STATUS, aircraft->m_statusItem);
ui->adsbData->setItem(row, ADSB_COL_SQUAWK, aircraft->m_squawkItem);
ui->adsbData->setItem(row, ADSB_COL_REGISTRATION, aircraft->m_registrationItem); ui->adsbData->setItem(row, ADSB_COL_REGISTRATION, aircraft->m_registrationItem);
ui->adsbData->setItem(row, ADSB_COL_COUNTRY, aircraft->m_countryItem); ui->adsbData->setItem(row, ADSB_COL_COUNTRY, aircraft->m_countryItem);
ui->adsbData->setItem(row, ADSB_COL_REGISTERED, aircraft->m_registeredItem); ui->adsbData->setItem(row, ADSB_COL_REGISTERED, aircraft->m_registeredItem);
@ -957,12 +959,27 @@ void ADSBDemodGUI::handleADSB(
{ {
// Aircraft status // Aircraft status
int st = data[4] & 0x7; // Subtype int st = data[4] & 0x7; // Subtype
int es = (data[5] >> 5) & 0x7; // Emergency state
if (st == 1) if (st == 1)
{
int es = (data[5] >> 5) & 0x7; // Emergency state
int modeA = ((data[5] << 8) & 0x1f00) | (data[6] & 0xff); // Mode-A code (squawk)
aircraft->m_status = emergencyStatus[es]; aircraft->m_status = emergencyStatus[es];
else aircraft->m_statusItem->setText(aircraft->m_status);
aircraft->m_status = QString(""); int a, b, c, d;
aircraft->m_statusItem->setText(aircraft->m_status); c = ((modeA >> 12) & 1) | ((modeA >> (10-1)) & 0x2) | ((modeA >> (8-2)) & 0x4);
a = ((modeA >> 11) & 1) | ((modeA >> (9-1)) & 0x2) | ((modeA >> (7-2)) & 0x4);
b = ((modeA >> 5) & 1) | ((modeA >> (3-1)) & 0x2) | ((modeA << (1)) & 0x4);
d = ((modeA >> 4) & 1) | ((modeA >> (2-1)) & 0x2) | ((modeA << (2)) & 0x4);
aircraft->m_squawk = a*1000 + b*100 + c*10 + d;
if (modeA & 0x40)
aircraft->m_squawkItem->setText(QString("%1 IDENT").arg(aircraft->m_squawk, 4, 10, QLatin1Char('0')));
else
aircraft->m_squawkItem->setText(QString("%1").arg(aircraft->m_squawk, 4, 10, QLatin1Char('0')));
}
else if (st == 2)
{
// TCAS/ACAS RA Broadcast
}
} }
else if (tc == 29) else if (tc == 29)
{ {
@ -1872,6 +1889,7 @@ void ADSBDemodGUI::resizeTable()
ui->adsbData->setItem(row, ADSB_COL_LONGITUDE, new QTableWidgetItem("-180.00000")); ui->adsbData->setItem(row, ADSB_COL_LONGITUDE, new QTableWidgetItem("-180.00000"));
ui->adsbData->setItem(row, ADSB_COL_CATEGORY, new QTableWidgetItem("Heavy")); ui->adsbData->setItem(row, ADSB_COL_CATEGORY, new QTableWidgetItem("Heavy"));
ui->adsbData->setItem(row, ADSB_COL_STATUS, new QTableWidgetItem("No emergency")); ui->adsbData->setItem(row, ADSB_COL_STATUS, new QTableWidgetItem("No emergency"));
ui->adsbData->setItem(row, ADSB_COL_SQUAWK, new QTableWidgetItem("Squawk"));
ui->adsbData->setItem(row, ADSB_COL_REGISTRATION, new QTableWidgetItem("G-12345")); ui->adsbData->setItem(row, ADSB_COL_REGISTRATION, new QTableWidgetItem("G-12345"));
ui->adsbData->setItem(row, ADSB_COL_COUNTRY, new QTableWidgetItem("Country")); ui->adsbData->setItem(row, ADSB_COL_COUNTRY, new QTableWidgetItem("Country"));
ui->adsbData->setItem(row, ADSB_COL_REGISTERED, new QTableWidgetItem("Registered")); ui->adsbData->setItem(row, ADSB_COL_REGISTERED, new QTableWidgetItem("Registered"));
@ -1897,6 +1915,7 @@ void ADSBDemodGUI::resizeTable()
ui->adsbData->removeCellWidget(row, ADSB_COL_LONGITUDE); ui->adsbData->removeCellWidget(row, ADSB_COL_LONGITUDE);
ui->adsbData->removeCellWidget(row, ADSB_COL_CATEGORY); ui->adsbData->removeCellWidget(row, ADSB_COL_CATEGORY);
ui->adsbData->removeCellWidget(row, ADSB_COL_STATUS); ui->adsbData->removeCellWidget(row, ADSB_COL_STATUS);
ui->adsbData->removeCellWidget(row, ADSB_COL_SQUAWK);
ui->adsbData->removeCellWidget(row, ADSB_COL_REGISTRATION); ui->adsbData->removeCellWidget(row, ADSB_COL_REGISTRATION);
ui->adsbData->removeCellWidget(row, ADSB_COL_COUNTRY); ui->adsbData->removeCellWidget(row, ADSB_COL_COUNTRY);
ui->adsbData->removeCellWidget(row, ADSB_COL_REGISTERED); ui->adsbData->removeCellWidget(row, ADSB_COL_REGISTERED);

View File

@ -91,6 +91,7 @@ struct Aircraft {
int m_verticalRate; // Vertical climb rate in ft/min int m_verticalRate; // Vertical climb rate in ft/min
QString m_emitterCategory; // Aircraft type QString m_emitterCategory; // Aircraft type
QString m_status; // Aircraft status QString m_status; // Aircraft status
int m_squawk; // Mode-A code
Real m_range; // Distance from station to aircraft Real m_range; // Distance from station to aircraft
Real m_azimuth; // Azimuth from station to aircraft Real m_azimuth; // Azimuth from station to aircraft
Real m_elevation; // Elevation from station to aicraft; Real m_elevation; // Elevation from station to aicraft;
@ -138,6 +139,7 @@ struct Aircraft {
QTableWidgetItem *m_azElItem; QTableWidgetItem *m_azElItem;
QTableWidgetItem *m_emitterCategoryItem; QTableWidgetItem *m_emitterCategoryItem;
QTableWidgetItem *m_statusItem; QTableWidgetItem *m_statusItem;
QTableWidgetItem *m_squawkItem;
QTableWidgetItem *m_registrationItem; QTableWidgetItem *m_registrationItem;
QTableWidgetItem *m_countryItem; QTableWidgetItem *m_countryItem;
QTableWidgetItem *m_registeredItem; QTableWidgetItem *m_registeredItem;
@ -193,6 +195,7 @@ struct Aircraft {
m_longitudeItem = new QTableWidgetItem(); m_longitudeItem = new QTableWidgetItem();
m_emitterCategoryItem = new QTableWidgetItem(); m_emitterCategoryItem = new QTableWidgetItem();
m_statusItem = new QTableWidgetItem(); m_statusItem = new QTableWidgetItem();
m_squawkItem = new QTableWidgetItem();
m_registrationItem = new QTableWidgetItem(); m_registrationItem = new QTableWidgetItem();
m_countryItem = new QTableWidgetItem(); m_countryItem = new QTableWidgetItem();
m_registeredItem = new QTableWidgetItem(); m_registeredItem = new QTableWidgetItem();

View File

@ -693,6 +693,14 @@
<string>Aircraft emergency status</string> <string>Aircraft emergency status</string>
</property> </property>
</column> </column>
<column>
<property name="text">
<string>Squawk</string>
</property>
<property name="toolTip">
<string>Mode-A transponder code</string>
</property>
</column>
<column> <column>
<property name="text"> <property name="text">
<string>Reg</string> <string>Reg</string>
@ -844,6 +852,11 @@
<extends>QWidget</extends> <extends>QWidget</extends>
<header location="global">QtQuickWidgets/QQuickWidget</header> <header location="global">QtQuickWidgets/QQuickWidget</header>
</customwidget> </customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget> <customwidget>
<class>RollupWidget</class> <class>RollupWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@ -862,11 +875,6 @@
<header>gui/valuedialz.h</header> <header>gui/valuedialz.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>deltaFrequency</tabstop> <tabstop>deltaFrequency</tabstop>

View File

@ -109,6 +109,7 @@ The table displays the decoded ADS-B data for each aircraft along side data avai
* Longitude - Horizontal position coordinate, in decimal degrees. (ADS-B) * Longitude - Horizontal position coordinate, in decimal degrees. (ADS-B)
* Category - The vehicle category, such as Light, Large, Heavy or Rotorcraft. (ADS-B) * Category - The vehicle category, such as Light, Large, Heavy or Rotorcraft. (ADS-B)
* Status - The status of the flight, including if there is an emergency. (ADS-B) * Status - The status of the flight, including if there is an emergency. (ADS-B)
* Squawk - The squawk code (Mode-A transponder code). (ADS-B)
* Registration - The registration number of the aircraft. (DB) * Registration - The registration number of the aircraft. (DB)
* Country - The flag of the country the aircraft is registered in. (DB) * Country - The flag of the country the aircraft is registered in. (DB)
* Registered - The date when the aircraft was registered. (DB) * Registered - The date when the aircraft was registered. (DB)