From dd7d54cfccb34076b46f3f51e7fe872b199b90a9 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 13 Nov 2017 19:08:05 +0100 Subject: [PATCH 1/5] Do not crash when specifying an unsupported transport medium for an I/O protocol. --- src/Main/fg_io.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Main/fg_io.cxx b/src/Main/fg_io.cxx index c75138e91..a1df491ff 100644 --- a/src/Main/fg_io.cxx +++ b/src/Main/fg_io.cxx @@ -328,6 +328,12 @@ FGIO::parse_port_config( const string& config ) io->set_io_channel( new SGSocket( hostname, port, style ) ); } + else + { + SG_LOG( SG_IO, SG_ALERT, "Unknown transport medium \"" << medium << "\" in \"" << config << "\""); + delete io; + return NULL; + } return io; } From f6ce43424180c42488651c54d03be789d2da68b6 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 13 Nov 2017 19:08:45 +0100 Subject: [PATCH 2/5] Disabled forgotten debug output. --- src/Network/garmin.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Network/garmin.cxx b/src/Network/garmin.cxx index 3ae22d2a1..807e6219e 100644 --- a/src/Network/garmin.cxx +++ b/src/Network/garmin.cxx @@ -174,7 +174,7 @@ bool FGGarmin::gen_message() { garmin_sentence += gsa; garmin_sentence += "\r\n"; - std::cout << garmin_sentence; + // std::cout << garmin_sentence; length = garmin_sentence.length(); strncpy( buf, garmin_sentence.c_str(), length ); From 6077ef8cddd5b8670d60f70c87df5625adddbc91 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 13 Nov 2017 19:10:36 +0100 Subject: [PATCH 3/5] Remove unused copy&pasted nmea code from other protocol's source. --- src/Network/AV400.cxx | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/Network/AV400.cxx b/src/Network/AV400.cxx index 2915ccf60..e54fc488b 100644 --- a/src/Network/AV400.cxx +++ b/src/Network/AV400.cxx @@ -46,28 +46,6 @@ FGAV400::~FGAV400() { } -#if 0 -// calculate the garmin check sum -static char calc_nmea_cksum(char *sentence) { - unsigned char sum = 0; - int i, len; - - // cout << sentence << endl; - - len = strlen(sentence); - sum = sentence[0]; - for ( i = 1; i < len; i++ ) { - // cout << sentence[i]; - sum ^= sentence[i]; - } - // cout << endl; - - // printf("sum = %02x\n", sum); - return sum; -} -#endif - - // generate AV400 message bool FGAV400::gen_message() { // cout << "generating garmin message" << endl; From 5f994c94b9a96614bdd4b0a8e63b9b864faacd19 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 13 Nov 2017 22:54:48 +0100 Subject: [PATCH 4/5] TCAS: do not process invalid AI models --- src/Instrumentation/tcas.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Instrumentation/tcas.cxx b/src/Instrumentation/tcas.cxx index c06e3ffd0..6f9e1fb9c 100644 --- a/src/Instrumentation/tcas.cxx +++ b/src/Instrumentation/tcas.cxx @@ -547,7 +547,7 @@ TCAS::ThreatDetector::init(void) nodeHeading = fgGetNode("/orientation/heading-deg", true); nodeVelocity = fgGetNode("/velocities/airspeed-kt", true); nodeVerticalFps = fgGetNode("/velocities/vertical-speed-fps", true); - + tcas->advisoryGenerator.init(&self,¤tThreat); } @@ -620,7 +620,9 @@ TCAS::ThreatDetector::checkThreat(int mode, const SGPropertyNode* pModel) #ifdef FEATURE_TCAS_DEBUG_THREAT_DETECTOR checkCount++; #endif - + if (!pModel->getBoolValue("valid")) + return ThreatInvisible; + float velocityKt = pModel->getDoubleValue("velocities/true-airspeed-kt"); if (!checkTransponder(pModel, velocityKt)) From cae4523d97bb99feff77dda1c7dba2db1cf81a82 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Tue, 14 Nov 2017 20:35:26 +0100 Subject: [PATCH 5/5] Completely removed obsolete debug code as suggested by James. --- src/Main/fg_io.cxx | 2 +- src/Network/garmin.cxx | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Main/fg_io.cxx b/src/Main/fg_io.cxx index a1df491ff..c3b7e68cc 100644 --- a/src/Main/fg_io.cxx +++ b/src/Main/fg_io.cxx @@ -332,7 +332,7 @@ FGIO::parse_port_config( const string& config ) { SG_LOG( SG_IO, SG_ALERT, "Unknown transport medium \"" << medium << "\" in \"" << config << "\""); delete io; - return NULL; + return nullptr; } return io; diff --git a/src/Network/garmin.cxx b/src/Network/garmin.cxx index 807e6219e..75c4453a7 100644 --- a/src/Network/garmin.cxx +++ b/src/Network/garmin.cxx @@ -56,25 +56,18 @@ static char calc_nmea_cksum(char *sentence) { unsigned char sum = 0; int i, len; - // cout << sentence << endl; - len = strlen(sentence); sum = sentence[0]; for ( i = 1; i < len; i++ ) { - // cout << sentence[i]; sum ^= sentence[i]; } - // cout << endl; - // printf("sum = %02x\n", sum); return sum; } // generate Garmin message bool FGGarmin::gen_message() { - // cout << "generating garmin message" << endl; - char rmc[256], rmc_sum[256], rmz[256], rmz_sum[256], gsa[256]; char dir; int deg; @@ -174,8 +167,6 @@ bool FGGarmin::gen_message() { garmin_sentence += gsa; garmin_sentence += "\r\n"; - // std::cout << garmin_sentence; - length = garmin_sentence.length(); strncpy( buf, garmin_sentence.c_str(), length ); @@ -364,8 +355,6 @@ bool FGGarmin::parse_message() { } - // printf("%.8f %.8f\n", lon, lat); - begin = begin_line; end_line = msg.find("\n", begin_line); }