You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-26 22:13:53 +01:00
optimised serialport code using export
This commit is contained in:
committed by
GitHub
parent
fbcdda2941
commit
b23211f408
@@ -433,15 +433,19 @@ function handleData(wss, receivedData, rdsWss) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Serialport retry code when port is open but communication is lost (additional code in index.js)
|
// Serialport retry code when port is open but communication is lost (additional code in index.js)
|
||||||
isSerialportAlive = true;
|
let state = {
|
||||||
lastFrequencyAlive = '87.500';
|
isSerialportAlive: true,
|
||||||
|
isSerialportRetrying: false,
|
||||||
|
lastFrequencyAlive: '87.500'
|
||||||
|
};
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
lastFrequencyAlive = initialData.freq;
|
state.lastFrequencyAlive = initialData.freq;
|
||||||
const serialportElapsedTime = process.hrtime(serialportUpdateTime)[0];
|
const serialportElapsedTime = process.hrtime(serialportUpdateTime)[0];
|
||||||
// Activate serialport retry if handleData has not been executed for over 8 seconds
|
// Activate serialport retry if handleData has not been executed for over 8 seconds
|
||||||
if (checkSerialport && (serialportElapsedTime > 8) && !isSerialportRetrying && serverConfig.xdrd.wirelessConnection === false) {
|
if (checkSerialport && (serialportElapsedTime > 8) && !state.isSerialportRetrying && serverConfig.xdrd.wirelessConnection === false) {
|
||||||
isSerialportAlive = false;
|
state.isSerialportAlive = false;
|
||||||
isSerialportRetrying = true;
|
state.isSerialportRetrying = true;
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
@@ -498,5 +502,5 @@ function processSignal(receivedData, st, stForced) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
handleData, showOnlineUsers, dataToSend, initialData, resetToDefault
|
handleData, showOnlineUsers, dataToSend, initialData, resetToDefault, state
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user