Last active
February 1, 2022 13:24
-
-
Save lukaszradziak/3507d17bb94c8e07ed915e12cb250590 to your computer and use it in GitHub Desktop.
tablica wyników
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SerialPort = require('serialport'); | |
const Readline = require('@serialport/parser-readline'); | |
const port = new SerialPort('/dev/tty.usbserial-A1071ZRT', { | |
baudRate: 57600 | |
}); | |
const parser = new Readline(); | |
port.pipe(parser); | |
const result = {}; | |
parser.on('data', function (data) { | |
const parse = data.toString().trim().split(" "); | |
console.log(`read DATA`, data); | |
if(d[0] == 'WGSP'){ | |
result.left_score = parse[1]; | |
} else if(d[0] == 'WGSC'){ | |
result.right_score = parse[1]; | |
} else if(d[0] == 'SGSP'){ | |
result.left_set = parse[1]; | |
} else if(d[0] == 'SGSC'){ | |
result.right_set = parse[1]; | |
} | |
console.log(`RESULT`, result); | |
}); | |
setInterval(() => { | |
port.write('STAN?\r\n') | |
console.log(`write STAN`) | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment