Commit 2e6304315fe49b9fd7f90eae3a65ad51418482f8

Authored by Adhidarma Hadiwinoto
1 parent 798813367a
Exists in master

Kembali ke parserReadLine

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

1 1 // const REGEX_WAIT_FOR_OK_OR_ERROR = /\n(?:OK|ERROR)\r/;
2   -const REGEX_WAIT_FOR_OK_OR_ERROR = /\nOK\r/;
  2 +// const REGEX_WAIT_FOR_OK_OR_ERROR = /\nOK\r/;
3 3  
4 4 const SerialPort = require('serialport');
5 5  
6 6 const config = require('komodo-sdk/config');
7 7 const logger = require('komodo-sdk/logger');
8 8  
9   -/*
10 9 const ParserReadline = require('@serialport/parser-readline');
11 10  
12   -const parserCRLF = new ParserReadline({ delimiter: '\r\n' });
13   -parserCRLF.on('data', (data) => {
  11 +const parser = new ParserReadline({ delimiter: '\r\n' });
  12 +parser.on('data', (data) => {
14 13 logger.verbose('INCOMING', { parser: 'parserReadLine', data: data.toString() });
15 14 });
16   -*/
17 15  
  16 +/*
18 17 const ParserRegex = require('@serialport/parser-regex');
19 18  
20   -const parserWaitForOkOrError = new ParserRegex({ regex: REGEX_WAIT_FOR_OK_OR_ERROR });
21   -parserWaitForOkOrError.on('data', (data) => {
  19 +const parser = new ParserRegex({ regex: REGEX_WAIT_FOR_OK_OR_ERROR });
  20 +parser.on('data', (data) => {
22 21 logger.verbose('INCOMING', { parser: 'parserWaitForOkOrError', data: data.toString() });
23 22 });
  23 +*/
24 24  
25 25 let port;
26 26  
... ... @@ -72,4 +72,4 @@ port = new SerialPort(config.modem.device, { baudRate: 115200 }, async (err) =>
72 72 if (isNotBlacklistedCommand('CMGD')) await writeToPortDelayed('AT+CMGD=0,4\r', 1000);
73 73 });
74 74  
75   -port.pipe(parserWaitForOkOrError);
  75 +port.pipe(parser);