Skip to content

Commit

Permalink
Switch to more generic libacars API, drop ARINC622-specific calls
Browse files Browse the repository at this point in the history
So far libacars was used to parse ARINC-622 ATS messages only. This
patch causes all non-ADS-C messages to be passed to generic ACARS
application decoding routine la_acars_decode_apps() which will decode
any ACARS application supported by libacars (be it ARINC-622 or not).
  • Loading branch information
szpajder committed Dec 25, 2018
1 parent 96b9a32 commit 2af258a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 43 deletions.
66 changes: 25 additions & 41 deletions JAERO/arincparse.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "arincparse.h"
#include <QDebug>
#include <libacars/libacars.h>
#include <libacars/arinc.h>
#include <libacars/cpdlc.h>
#include <libacars/acars.h>
#include <libacars/vstring.h>

ArincParse::ArincParse(QObject *parent) : QObject(parent)
Expand Down Expand Up @@ -47,35 +46,32 @@ qint32 ArincParse::extractqint32(QByteArray &ba,int lsbyteoffset,int bitoffset,i
return val;
}

void ArincParse::parse_cpdlc_payload(QByteArray &ba, la_msg_dir msg_dir) {
la_proto_node *node = la_cpdlc_parse((uint8_t *)ba.data(), ba.size(), msg_dir);
la_vstring *vstr = NULL;
if(node != NULL) {
vstr = la_proto_tree_format_text(NULL, node);
arincmessage.info += vstr->str;
la_vstring_destroy(vstr, true);
la_proto_tree_destroy(node);
void ArincParse::try_acars_apps(ACARSItem &acarsitem, la_msg_dir msg_dir) {
QByteArray ba;
if(msg_dir == LA_MSG_DIR_AIR2GND) {
// skip message number and flight ID
ba = acarsitem.message.mid(4+6).toLatin1();
} else {
ba = acarsitem.message.toLatin1();
}
}

void ArincParse::parse_arinc_payload(QByteArray &ba, la_msg_dir msg_dir) {
la_proto_node *node = la_arinc_parse(ba.data(), msg_dir);
la_vstring *vstr = NULL;
if(ba.size() < 1) {
return;
}
la_proto_node *node = la_acars_decode_apps(acarsitem.LABEL.data(), ba.data(), msg_dir);
if(node != NULL) {
vstr = la_proto_tree_format_text(NULL, node);
arincmessage.info += vstr->str;
la_vstring_destroy(vstr, true);
la_proto_tree_destroy(node);
la_vstring *vstr = la_proto_tree_format_text(NULL, node);
arincmessage.info += vstr->str;
la_vstring_destroy(vstr, true);
}
la_proto_tree_destroy(node);
}

bool ArincParse::parseUplinkmessage(ACARSItem &acarsitem)
{
if(acarsitem.downlink)return false;
if(acarsitem.nonacars)return false;

QByteArray ba = acarsitem.message.toLatin1();
parse_arinc_payload(ba, LA_MSG_DIR_GND2AIR);
try_acars_apps(acarsitem, LA_MSG_DIR_GND2AIR);
return true;
}

Expand Down Expand Up @@ -117,7 +113,11 @@ bool ArincParse::parseDownlinkmessage(ACARSItem &acarsitem)//QString &msg)

//deal with application section
QStringList sections=acarsitem.message.split('/');
if(sections.size()!=2)return true;
// Not an ARINC message - try other ACARS applications with libacars
if(sections.size()!=2) {
try_acars_apps(acarsitem, LA_MSG_DIR_AIR2GND);
return true;
}

//split up into components as strings
//eg "F58ADL0040/AKLCDYA.ADS.N705DN07EEE19454DAC7D010D21D0DEEEC44556208024029F0588C71D7884D000E13B90F00000F12C1A280001029305F1019F4"
Expand Down Expand Up @@ -450,26 +450,10 @@ bool ArincParse::parseDownlinkmessage(ACARSItem &acarsitem)//QString &msg)
}
break;
}
case AT1:
{
arincmessage.info += "FANS-1/A CPDLC Message:\n";
parse_cpdlc_payload(appmessage_bytes, LA_MSG_DIR_AIR2GND);
break;
}
case DR1:
{
arincmessage.info += "FANS-1/A CPDLC Disconnect Request:\n";
parse_cpdlc_payload(appmessage_bytes, LA_MSG_DIR_AIR2GND);
break;
}
case CC1:
{
arincmessage.info += "FANS-1/A CPDLC Connect Confirm:\n";
parse_cpdlc_payload(appmessage_bytes, LA_MSG_DIR_AIR2GND);
break;
}
default:
break;
// Not an ADS-C message - try other ACARS applications with libacars
try_acars_apps(acarsitem, LA_MSG_DIR_AIR2GND);
return true;
}

if(fail)arincmessage.info+="...\n";//"Failed understanding\n";//no need to bog the user down with to much detail
Expand Down
3 changes: 1 addition & 2 deletions JAERO/arincparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ public slots:
QString middlespacer;

DownlinkGroups downlinkgroups;
void parse_cpdlc_payload(QByteArray &ba, la_msg_dir msg_dir);
void parse_arinc_payload(QByteArray &ba, la_msg_dir msg_dir);
void try_acars_apps(ACARSItem &acarsitem, la_msg_dir msg_dir);

};

Expand Down

0 comments on commit 2af258a

Please sign in to comment.