Commit 5d95abfb2972f6820ff2fddcded1a947a86a09c0
1 parent
2e6304315f
Exists in
master
MODEM-TESTER: interbytetimeout
Showing 1 changed file with 14 additions and 5 deletions Side-by-side Diff
modem-tester.js
... | ... | @@ -6,12 +6,14 @@ const SerialPort = require('serialport'); |
6 | 6 | const config = require('komodo-sdk/config'); |
7 | 7 | const logger = require('komodo-sdk/logger'); |
8 | 8 | |
9 | +/* | |
9 | 10 | const ParserReadline = require('@serialport/parser-readline'); |
10 | 11 | |
11 | 12 | const parser = new ParserReadline({ delimiter: '\r\n' }); |
12 | 13 | parser.on('data', (data) => { |
13 | 14 | logger.verbose('INCOMING', { parser: 'parserReadLine', data: data.toString() }); |
14 | 15 | }); |
16 | +*/ | |
15 | 17 | |
16 | 18 | /* |
17 | 19 | const ParserRegex = require('@serialport/parser-regex'); |
... | ... | @@ -22,6 +24,13 @@ parser.on('data', (data) => { |
22 | 24 | }); |
23 | 25 | */ |
24 | 26 | |
27 | +const ParserInterByteTimeout = require('@serialport/parser-inter-byte-timeout'); | |
28 | + | |
29 | +const parser = new ParserInterByteTimeout({ interval: 1000 }); | |
30 | +parser.on('data', (data) => { | |
31 | + logger.verbose('INCOMING', { parser: 'ParserInterByteTimeout', data: data.toString() }); | |
32 | +}); | |
33 | + | |
25 | 34 | let port; |
26 | 35 | |
27 | 36 | function sleep(ms) { |
... | ... | @@ -65,11 +74,11 @@ port = new SerialPort(config.modem.device, { baudRate: 115200 }, async (err) => |
65 | 74 | } |
66 | 75 | |
67 | 76 | await writeToPortDelayed('AT\r'); |
68 | - if (isNotBlacklistedCommand('CGSN')) await writeToPortDelayed('AT+CGSN\r', 1000); | |
69 | - if (isNotBlacklistedCommand('CIMI')) await writeToPortDelayed('AT+CIMI\r', 1000); | |
70 | - if (isNotBlacklistedCommand('CSQ')) await writeToPortDelayed('AT+CSQ\r', 1000); | |
71 | - if (isNotBlacklistedCommand('COPS?')) await writeToPortDelayed('AT+COPS?\r', 1000); | |
72 | - if (isNotBlacklistedCommand('CMGD')) await writeToPortDelayed('AT+CMGD=0,4\r', 1000); | |
77 | + if (isNotBlacklistedCommand('CGSN')) await writeToPortDelayed('AT+CGSN\r', 2000); | |
78 | + if (isNotBlacklistedCommand('CIMI')) await writeToPortDelayed('AT+CIMI\r', 2000); | |
79 | + if (isNotBlacklistedCommand('CSQ')) await writeToPortDelayed('AT+CSQ\r', 2000); | |
80 | + if (isNotBlacklistedCommand('COPS?')) await writeToPortDelayed('AT+COPS?\r', 2000); | |
81 | + if (isNotBlacklistedCommand('CMGD')) await writeToPortDelayed('AT+CMGD=0,4\r', 2000); | |
73 | 82 | }); |
74 | 83 | |
75 | 84 | port.pipe(parser); |