Commit 1030ff0a6cc674d2a7708849f3305a2cfbea3337

Authored by Adhidarma Hadiwinoto
1 parent 97d8bd49cb
Exists in master

Register modem before opening port

Showing 1 changed file with 1 additions and 2 deletions Side-by-side Diff

... ... @@ -310,6 +310,7 @@ async function sendSMS(destination, msg) {
310 310 }
311 311  
312 312 function init() {
  313 + registerModem(modemInfo);
313 314 port = new SerialPort(config.modem.device, { baudRate: 115200 }, (err) => {
314 315 if (err) {
315 316 logger.warn(`Error opening modem. ${err}. Terminating modem ${config.modem.device}.`);
... ... @@ -318,8 +319,6 @@ function init() {
318 319 });
319 320 port.pipe(parserReadLine);
320 321  
321   - registerModem(modemInfo);
322   -
323 322 setInterval(() => {
324 323 if ((new Date() - lastTs) > MAX_LAST_DATA_AGE_MS) {
325 324 logger.warn(`No data for more than ${MAX_LAST_DATA_AGE_MS} ms. Modem might be unresponsive. Terminating modem ${config.modem.device}.`);