From 1f9ce3e3ed7a3c1668dcfbd870c7f52aebf9adf5 Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Fri, 9 Oct 2020 10:34:14 -0400 Subject: [PATCH] fix: retry setting the tx pgn list on ngt-1 --- lib/serial.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/serial.js b/lib/serial.js index 9a9fc8f..7846ea3 100644 --- a/lib/serial.js +++ b/lib/serial.js @@ -69,6 +69,7 @@ function SerialStream (options) { this.reconnect = options.reconnect || true this.serial = null this.options = options + this.transmitPGNRetries = 2 this.transmitPGNs = defaultTransmitPGNs if ( this.options.transmitPGNs ) { @@ -351,12 +352,24 @@ function processNTGMessage(that, buffer, len) }) debug('needed pgns: %j', that.neededTransmitPGNs) } else if ( command === 0x49 && buffer[3] === 4 ) { - if ( that.neededTransmitPGNs.length ) { + //I think this means done receiving the pgns list + if ( !that.neededTransmitPGNs ) { + if ( that.transmitPGNRetries-- > 0 ) { + debug('did not get tx pgn list, retrying...') + that.serial.write(composeRequestTXPGNList()) + } else { + const msg = 'could not set transmit pgn list' + that.options.app.setProviderStatus(msg) + console.warn(msg) + enableOutput(that) + } + } else if ( that.neededTransmitPGNs.length ) { enableTXPGN(that.serial, that.neededTransmitPGNs[0]) } else { enableOutput(that) } } else if ( command === 0x47 ) { + //response from enable a pgn if ( buffer[3] === 1 ) { debug('enabled %d', that.neededTransmitPGNs[0]) that.neededTransmitPGNs = that.neededTransmitPGNs.slice(1)