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

Added a delay at connection to be compatible with fm-dx-tuner

This commit is contained in:
Sjef Verhoeven PE5PVB
2024-07-18 12:54:45 +02:00
parent 63df75ab23
commit 5c3f4b983e

View File

@@ -64,7 +64,6 @@ connectToSerial();
// Serial Connection
function connectToSerial() {
let okReceived = false;
if (serverConfig.xdrd.wirelessConnection === false) {
serialport = new SerialPort({path: serverConfig.xdrd.comPort, baudRate: 115200 });
@@ -72,12 +71,7 @@ function connectToSerial() {
serialport.on('open', () => {
logInfo('Using COM device: ' + serverConfig.xdrd.comPort);
serialport.write('x\n');
serialport.on('data', (data) => {
const receivedData = data.toString();
if (receivedData.startsWith('OK')) {
// Send the remaining commands
setTimeout(() => {
serialport.write('Q0\n');
serialport.write('M0\n');
serialport.write('Z0\n');
@@ -96,10 +90,10 @@ function connectToSerial() {
serialport.write('D0\n');
serialport.write('G00\n');
serverConfig.audio.startupVolume ? serialport.write('Y' + (serverConfig.audio.startupVolume * 100).toFixed(0) + '\n') : serialport.write('Y100\n');
} else {
// Continue handling data normally if it's not the "OK" message
}, 3000);
serialport.on('data', (data) => {
helpers.resolveDataBuffer(data, wss);
}
});
});