I am in the process of building a telemetry parser. The way the telemetry data is set up is it includes a ascii trigger byte, 1-8 ascii data bytes and “>” as the terminator byte. One of the trigger bytes is a backslash “” (why they chose to include the back slash character as one of the triggers is beyond me).
Here is an example of the raw telemetry data:
{040>@2>#0010>~AB---->( 0213>-001>?079>! 212>=KM6ZFL>01>?079>! 212>=KM6ZFL>
{045>@2>#0014>~AB---->( 0072>-001>?079>! 212>=KM6ZFL>
{046>@4>#0016>~AB---->( 0033>-001>?079>! 212>=KM6ZFL>
{043>@5>#0022>~1B---->(-0029> 004>%04679>^0660>[025>?079>! 209>=KM6ZFL>
Telemetry data format specification
I Have built some code to separate the data but as soon as I process the data the backslash has been striped
function telemetryParser(data) {
TelemetryData = data.split(">");
console.log(TelemetryData);
for (var i = 0; i < TelemetryData.length; i++) {
triggerParser(TelemetryData[i])
}
// return altitude;
}
function triggerParser(data){
const triggers = ["#", "{","<","(","\","@","~","!","=","?","%","^","["]
const element = ["flightTime","Altitude100","altitude","velocity","acceleration","flightPhase","channelStatus","temperature","callSign","voltage","apogee","maxVolocity","maxAcceleration"]
for (var j = 0; j < triggers.length; j++) {
if (data.split(triggers[j])[1]) {
console.log(element[j] +":"+ data.split(triggers[j])[1] )
}
}
}
Result:
telemetryParser("{040>@2>#0010>~AB---->( 0213>-001>?079>! 212>=KM6ZFL>01>?079>! 212>=KM6ZFL>")
parser.js:3 (14) ['{040', '@2', '#0010', '~AB----', '( 0213', '-001', '?079', '! 212', '=KM6ZFL', '01', '?079', '! 212', '=KM6ZFL', '']0: "{040"1: "@2"2: "#0010"3: "~AB----"4: "( 0213"5: "-001"6: "?079"7: "! 212"8: "=KM6ZFL"9: "01"10: "?079"11: "! 212"12: "=KM6ZFL"13: ""length: 14[[Prototype]]: Array(0)
parser.js:26 Altitude100:040
parser.js:26 flightPhase:2
parser.js:26 flightTime:0010
parser.js:26 channelStatus:AB----
parser.js:26 velocity: 0213
(expecting acceleration: -001 here)
parser.js:26 voltage:079
parser.js:26 temperature: 212
parser.js:26 callSign:KM6ZFL
parser.js:26 voltage:079
parser.js:26 temperature: 212
parser.js:26 callSign:KM6ZFL
undefined
How would I keep or change the backslash so I don’t lose track of the data as the back slash is the only way I have to identify the data?