A Node.js module for a JRT laser distance sensor
const JRT = require('jrt')
const id = '/dev/tty.usbserial-0000'
JRT.open(id).then(async (jrt) => {
jrt.on('message', (data) => {
console.log('message', data)
})
console.log(await jrt.oneshot_auto())
console.log({
read_status: await jrt.read_status().then(r => r.value),
read_measurement: await jrt.read_measurement().then(r => r.value),
read_hw: await jrt.read_hw().then(r => r.value),
read_sw: await jrt.read_sw().then(r => r.value),
read_sn: await jrt.read_sn().then(r => r.value),
read_voltage: await jrt.read_voltage().then(r => r.value),
laser_on: await jrt.laser_on().then(r => r.value),
laser_off: await jrt.laser_off().then(r => r.value),
})
await jrt.continuous_auto()
setTimeout(jrt.continuous_exit, 30000)
})
Emits the raw data received.
Emitted when an error (EE
) message is received.
Emitted when a measurement message is received.
Emits all parsed messages.