https://support.virtuagym.com/s/article/Honeywell-Genesis-7580g-Installation-Guide?language=en_US
Last active
June 27, 2023 18:09
-
-
Save phstc/63068dc38873e815086f95ae170db887 to your computer and use it in GitHub Desktop.
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') | |
async function listSerialPorts() { | |
await SerialPort.list().then((ports, err) => { | |
if (err) { | |
// document.getElementById('error').textContent = err.message | |
console.error(err.message) | |
return | |
} else { | |
// document.getElementById('error').textContent = '' | |
} | |
console.log('ports', ports) | |
if (ports.length === 0) { | |
// document.getElementById('error').textContent = 'No ports discovered' | |
console.error('No ports discovered') | |
} | |
// tableHTML = tableify(ports) | |
// document.getElementById('ports').innerHTML = tableHTML | |
}) | |
} | |
function listPorts() { | |
listSerialPorts() | |
setTimeout(listPorts, 2000) | |
} | |
// Set a timeout that will check for new serialPorts every 2 seconds. | |
// This timeout reschedules itself. | |
setTimeout(listPorts, 2000) | |
listSerialPorts() |
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
{ | |
"name": "turnstile-app", | |
"version": "1.0.0", | |
"description": "", | |
"main": "test.js", | |
"scripts": { | |
"test": "node test.js", | |
"list": "node list.js" | |
}, | |
"author": "", | |
"license": "ISC" | |
} |
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') | |
async function listSerialPorts() { | |
await SerialPort.list().then((ports, err) => { | |
if (err) { | |
// document.getElementById('error').textContent = err.message | |
console.error(err.message) | |
return | |
} else { | |
// document.getElementById('error').textContent = '' | |
} | |
console.log('ports', ports) | |
if (ports.length === 0) { | |
// document.getElementById('error').textContent = 'No ports discovered' | |
console.error('No ports discovered') | |
} | |
// tableHTML = tableify(ports) | |
// document.getElementById('ports').innerHTML = tableHTML | |
}) | |
} | |
function listPorts() { | |
listSerialPorts() | |
setTimeout(listPorts, 2000) | |
} | |
// Set a timeout that will check for new serialPorts every 2 seconds. | |
// This timeout reschedules itself. | |
// setTimeout(listPorts, 2000) | |
// listSerialPorts() | |
const ON = [0xff, 0x01, 0x01] | |
const OFF = [0xff, 0x01, 0x00] | |
const path = '/dev/tty.usbserial-AB0LBJ9Q' | |
const serialport = new SerialPort({ path, baudRate: 9600 }) | |
serialport.on('open', function() { | |
console.log(serialport + ' is open') | |
async function test(param) { | |
serialport.write(Buffer.from(param)) | |
console.log('changed to', param === ON ? 'ON' : 'OFF') | |
setTimeout(() => { | |
test(ON === param ? OFF : ON) | |
}, 1000) | |
} | |
test(ON) | |
}) | |
async function test(param) { | |
const x = serialport.write(param) | |
console.log('changed to', param === ON ? 'ON' : 'OFF') | |
setTimeout(() => { | |
test(ON === param ? OFF : ON) | |
}, 1000) | |
} | |
// test(ON) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment