From a253578a1b2a3bf3b277925771845eb8745032da Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Thu, 3 Sep 2020 23:06:01 +0200 Subject: [PATCH] Make SmartSource header less verbose. PostgreSQL NOTIFY has an 8,000 bytes payload limit and we were going over that. --- lib/www/server/lib/headers/smartsource.js | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/www/server/lib/headers/smartsource.js b/lib/www/server/lib/headers/smartsource.js index edea4dc..ac999b8 100644 --- a/lib/www/server/lib/headers/smartsource.js +++ b/lib/www/server/lib/headers/smartsource.js @@ -31,23 +31,23 @@ function parse (buffer) { throw new NavHeaderError("Expected SmartSource marker not found at position " + s, buf); } }, - + blk_siz: (buf, ctx) => { return Number(ascii(4)); }, - + line: (buf, ctx) => { return ascii(30).trim(); }, - + shot: (buf, ctx) => { return Number(ascii(10)); }, - + mask: (buf, ctx) => { return Number(ascii(2)); }, - + trg_mode: (buf, ctx) => { const trg_mode = ascii(1); switch (trg_mode) { @@ -59,81 +59,81 @@ function parse (buffer) { throw new NavHeaderError("Unknown SmartSource trigger mode: " + trg_mode, buf); } }, - + time: (buf, ctx) => { const time = ascii(17); '20/08/30:05:45:58' return new Date(time.replace(/(\d{2})\/(\d{2})\/(\d{2}):(\d{2}):(\d{2}):(\d{2})/, "20$1-$2-$3T$4:$5:$6Z")); }, - + src_number: (buf, ctx) => { return Number(ascii(1)); }, - + num_subarray: (buf, ctx) => { return Number(ascii(1)); }, - + num_guns: (buf, ctx) => { return Number(ascii(2)); }, - + num_active: (buf, ctx) => { return Number(ascii(2)); }, - + num_delta: (buf, ctx) => { return Number(ascii(2)); }, - + num_auto: (buf, ctx) => { return Number(ascii(2)); }, - + num_nofire: (buf, ctx) => { return Number(ascii(2)); }, - + spread: (buf, ctx) => { // Convert to ms return Number(ascii(4))/10; }, - + volume: (buf, ctx) => { return Number(ascii(6)); }, - + avg_delta: (buf, ctx) => { return Number(ascii(5)); }, - + std_delta: (buf, ctx) => { return Number(ascii(5)); }, - + baroPress: (buf, ctx) => { // Converted to millibars return Number(ascii(6))/100; }, - + manifold: (buf, ctx) => { return Number(ascii(4)); // PSI }, - + spare: (buf, ctx) => { return ascii(88).trim(); }, }; - + const gun = { string: (buf, ctx) => { return Number(ascii(1)); }, - + gun: (buf, ctx) => { return Number(ascii(2)); }, - + source: (buf, ctx) => { return Number(ascii(1)); }, @@ -217,12 +217,12 @@ function parse (buffer) { for (const key of Object.keys(header)) { smartsource[key] = header[key](buffer, smartsource); } - + smartsource.guns = []; for (let n=0; n