Commit c5983f5f authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Fix javascript trace parser to handle zero sized packets.

parent e471d053
/*
Javascript for receiving traces over websocket
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2013
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2013, 2015
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -291,8 +291,16 @@ trace_stream.prototype.handle = function() {
}
}
// console.log("esc found at " + i);
var pkt_off = newoff;
var pkt = new DataView(this.rx_buffer, newoff, pkt_len);
newoff = i + 1;
if (pkt_len < 1) {
/* empty packet */
continue;
}
var pkt = new DataView(this.rx_buffer, pkt_off, pkt_len);
p++;
......@@ -372,10 +380,6 @@ trace_stream.prototype.handle = function() {
default:
console.log("ptype: " + this.rx_buffer[0]);
}
//this.rx_buffer = this.rx_buffer.subarray(i + 1);
newoff = i + 1;
// console.log("rx_buffer.length: " + this.rx_buffer.length);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment