diff --git a/Nasal/FMGC/mcdu-messages.nas b/Nasal/FMGC/mcdu-messages.nas index 3e5c8f9a..8ac87b43 100644 --- a/Nasal/FMGC/mcdu-messages.nas +++ b/Nasal/FMGC/mcdu-messages.nas @@ -173,7 +173,7 @@ var MessageController = { TypeIMessage.new("USING COST INDEX N", 1),TypeIMessage.new("WAIT FOR SYSTEM RESPONSE"),TypeIMessage.new("RWY/LS MISMATCH"), TypeIMessage.new("VHF3 VOICE MSG NOT GEN"),TypeIMessage.new("NO COMM MSG NOT GEN"),TypeIMessage.new("WX UPLINK"), TypeIMessage.new("SIMBRIEF DOWNLOAD FAILED"),TypeIMessage.new("MISSING USERNAME"),TypeIMessage.new("AOC ACT F-PLN UPLINK"), - TypeIMessage.new("NO ANSWER TO REQUEST"),TypeIMessage.new("NO D-ATIS AVAILABLE") + TypeIMessage.new("NO ANSWER TO REQUEST"),TypeIMessage.new("NO D-ATIS AVAILABLE"),TypeIMessage.new("BAD SERVER RESPONSE") ]), typeIIMessages: std.Vector.new([ TypeIIMessage.new("LAT DISCONT AHEAD", "amb", 0),TypeIIMessage.new("MORE DRAG"),TypeIIMessage.new("RWY/LS MISMATCH", "amb", 0),TypeIIMessage.new("STEP DELETED"), diff --git a/Nasal/Systems/Comm/Notification.nas b/Nasal/Systems/Comm/Notification.nas index 2f6b79ce..339c6d74 100644 --- a/Nasal/Systems/Comm/Notification.nas +++ b/Nasal/Systems/Comm/Notification.nas @@ -175,7 +175,16 @@ var AOC = { http.load(serverString ~ airport) .fail(func(r) me.downloadFail(i, r)) - .done(func(r) me.processMETAR(r, i)); + .done(func(r) { + var errs = []; + call(me.processMETAR, [r, i], me, {}, errs); + if (size(errs) > 0) { + print("Failed to parse METAR for " ~ airport); + debug.dump(r.response); + debug.printerror(errs); + mcdu.mcdu_message(i, "BAD SERVER RESPONSE"); + } + }); return 0; }, fetchTAF: func(airport, i) { @@ -189,16 +198,32 @@ var AOC = { } http.load("https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=tafs&requestType=retrieve&format=xml&timeType=issue&mostRecent=true&hoursBeforeNow=12&stationString=" ~ airport) .fail(func(r) me.downloadFail(i)) - .done(func(r) me.processTAF(r, i)); + .done(func(r) { + var errs = []; + call(me.processTAF, [r, i], me, {}, errs); + if (size(errs) > 0) { + print("Failed to parse TAF for " ~ airport); + debug.dump(r.response); + debug.printerror(errs); + mcdu.mcdu_message(i, "BAD SERVER RESPONSE"); + } + }); return 0; }, processMETAR: func(r, i) { var raw = r.response; - if (find("", raw) != -1) { + if (me.server.getValue() == "vatsim") { + me.lastMETAR = raw; + } else if (find("", raw) != -1) { raw = split("", raw)[1]; raw = split("", raw)[0]; + me.lastMETAR = raw; + } else { + me.received = 0; + me.sent = 0; + mcdu.mcdu_message(i, "BAD SERVER RESPONSE"); + return; } - me.lastMETAR = raw; settimer(func() { me.received = 1; mcdu.mcdu_message(i, "WX UPLINK"); @@ -211,8 +236,16 @@ var AOC = { }, processTAF: func(r, i) { var raw = r.response; - raw = split("", raw)[1]; - raw = split("", raw)[0]; + if (find("", raw) != -1) { + raw = split("", raw)[1]; + raw = split("", raw)[0]; + me.lastTAF = raw; + } else { + me.received = 0; + me.sent = 0; + mcdu.mcdu_message(i, "BAD SERVER RESPONSE"); + return; + } me.lastTAF = raw; settimer(func() { me.received = 1; @@ -290,6 +323,7 @@ var ATIS = { print("Failed to parse ATIS for " ~ airport); debug.dump(r.response); debug.printerror(errs); + mcdu.mcdu_message(i, "BAD SERVER RESPONSE"); } }); return 0;