Commit 324414622031c6ec4cce055377811620e6f731e2
1 parent
82903c1e83
Exists in
master
Hapus parser test
Showing 1 changed file with 0 additions and 49 deletions Side-by-side Diff
tools/parser-test.js
... | ... | @@ -1,49 +0,0 @@ |
1 | -'use strict'; | |
2 | - | |
3 | -/* eslint-disable no-console */ | |
4 | - | |
5 | -const devicePath = '/dev/ttyUSB0'; | |
6 | - | |
7 | -const moment = require('moment'); | |
8 | -const SerialPort = require('serialport'); | |
9 | - | |
10 | -console.log(Buffer.from('OK')); | |
11 | -console.log(Buffer.from('\r')); | |
12 | -console.log(Buffer.from('\n')); | |
13 | -console.log(Buffer.from('\x1a')); | |
14 | -console.log(Buffer.from([0x1A])); | |
15 | - | |
16 | -const InterByteTimeout = require('@serialport/parser-inter-byte-timeout') | |
17 | -// const Delimiter = require('@serialport/parser-delimiter'); | |
18 | -const ParserReadline = require('@serialport/parser-readline'); | |
19 | - | |
20 | - | |
21 | -const port = new SerialPort(devicePath, { baudRate: 115200 }); | |
22 | - | |
23 | -const parserReadline = new ParserReadline(); | |
24 | -parserReadline.on('data', (data) => { | |
25 | - console.log(`READLINE: ${data}`); | |
26 | -}); | |
27 | - | |
28 | -port.pipe(parserReadline); | |
29 | - | |
30 | -const parserInterByteTimeout = new InterByteTimeout({ interval: 1000 }); | |
31 | -parserInterByteTimeout.on('data', (data) => { | |
32 | - console.log('INTERBYTETIMEOUT:'); | |
33 | - console.log(data); | |
34 | -}); | |
35 | -// port.pipe(parserInterByteTimeout); | |
36 | - | |
37 | - | |
38 | -port.on('open', () => { | |
39 | - console.log('====='); | |
40 | - port.write('ATE0\r') | |
41 | - // port.write('AT+CIMI\r'); | |
42 | - // port.write('OK'); | |
43 | - port.write('AT\r'); | |
44 | - port.write('AT+CMGF=1\r'); | |
45 | - port.write('AT+CMGS="+6282210008543"\r'); | |
46 | - port.write(`Coba dari parser-test ${moment().format('HHmmss')}`); | |
47 | - port.write(Buffer.from('\x1a')); | |
48 | - | |
49 | -}); |