1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

some changes with the rds

This commit is contained in:
2026-02-25 10:44:37 +01:00
parent 42a20330af
commit e14b3f8d11
3 changed files with 17 additions and 16 deletions

View File

@@ -185,18 +185,21 @@ function handleData(wss, receivedData, rdsWss) {
modifiedData += errorsNew.toString(16).padStart(2, '0'); modifiedData += errorsNew.toString(16).padStart(2, '0');
} }
rdsWss.clients.forEach((client) => { const a = modifiedData.slice(0, 4);
const b = modifiedData.slice(4, 8);
const c = modifiedData.slice(8, 12);
const d = modifiedData.slice(12, 16);
const errors = parseInt(modifiedData.slice(-2), 16); const errors = parseInt(modifiedData.slice(-2), 16);
let data = (((errors & 0xC0) == 0) ? modifiedData.slice(0, 4) : '----'); rdsWss.clients.forEach((client) => {
data += (((errors & 0x30) == 0) ? modifiedData.slice(4, 8) : '----'); let data = ((((errors >> 6) & 3) < 3) ? a : '----');
data += (((errors & 0x0C) == 0) ? modifiedData.slice(8, 12) : '----'); data += ((((errors >> 4) & 3) < 3) ? b : '----');
data += (((errors & 0x03) == 0) ? modifiedData.slice(12, 16) : '----'); data += ((((errors >> 2) & 3) < 3) ? c : '----');
data += (((errors & 3) < 3) ? d : '----');
const newDataString = "G:\r\n" + data + "\r\n\r\n"; client.send("G:\r\n" + data + "\r\n\r\n");
client.send(newDataString);
}); });
rdsdec.decodeGroup(parseInt(modifiedData.slice(0, 4), 16), parseInt(modifiedData.slice(4, 8), 16), parseInt(modifiedData.slice(8, 12), 16), parseInt(modifiedData.slice(12, 16), 16)); rdsdec.decodeGroup(parseInt(a, 16), parseInt(b, 16), parseInt(c, 16), parseInt(d, 16), errors);
legacyRdsPiBuffer = null; legacyRdsPiBuffer = null;
break; break;
} }

View File

@@ -36,9 +36,9 @@ class RDSDecoder {
} }
decodeGroup(blockA, blockB, blockC, blockD, error) { decodeGroup(blockA, blockB, blockC, blockD, error) {
const a_error = (error & 0xC0) >> 6; const a_error = (error >> 6) & 3;
const b_error = (error & 0x30) >> 4; const b_error = (error >> 4) & 3;
const c_error = (error & 0xc) >> 2; const c_error = (error >> 2) & 3;
const d_error = error & 3; const d_error = error & 3;
if(this.last_pi_error > a_error) { if(this.last_pi_error > a_error) {
@@ -46,7 +46,7 @@ class RDSDecoder {
this.last_pi_error = a_error; this.last_pi_error = a_error;
} }
if(b_error != 0) return; // B chooses what group this is, if this has errors, we are screwed if(b_error !== 0) return; // B chooses what group this is, if this has errors, we are screwed
const group = (blockB >> 12) & 0xF; const group = (blockB >> 12) & 0xF;
const version = (blockB >> 11) & 0x1; const version = (blockB >> 11) & 0x1;

View File

@@ -1,7 +1,7 @@
/* Libraries / Imports */ /* Libraries / Imports */
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const { logDebug, logError, logInfo, logWarn } = require('./console'); const { logError, logInfo } = require('./console');
let configName = 'config'; let configName = 'config';
@@ -135,9 +135,7 @@ function addMissingFields(target, source) {
if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) { if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) {
if (!target[key]) target[key] = {}; // Create missing object if (!target[key]) target[key] = {}; // Create missing object
addMissingFields(target[key], source[key]); // Recursively add missing fields addMissingFields(target[key], source[key]); // Recursively add missing fields
} else { } else if(target[key] === undefined) target[key] = source[key]; // Add missing fields only
if (target[key] === undefined) target[key] = source[key]; // Add missing fields only
}
}); });
} }