34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import Interrupts from '../src/interrupts'
|
|
|
|
const PINS = [9,10]
|
|
|
|
const EDGE = process.env.EDGE || 'both'
|
|
const REMOTE_HOST = process.env.REMOTE_HOST || 'sbc'
|
|
const REMOTE_PORT = process.env.REMOTE_PORT || 9001
|
|
|
|
let interrupts = new Interrupts(PINS, { id:'multi-interrupt', cmd:'interrupt.find', resetCmd:'interrupt.reset', resetInterval:0, edge:EDGE })
|
|
|
|
interrupts.amendConsumerCommands( {reply:() => {}} )
|
|
|
|
interrupts.on('log', ev => {
|
|
if (ev.level !== 'debug' && ev.level !== 'trace') console.log(`LOG:'--${ev.level}-- ${ev.msg}`)
|
|
// console.log(`LOG:'--${ev.level}-- ${ev.msg}`)
|
|
})
|
|
|
|
interrupts.on('connection:socket', ev => {
|
|
console.log(`remote socket connection event ${ev.socketName}: ${ev.state}`)
|
|
})
|
|
|
|
;
|
|
(async () => {
|
|
|
|
interrupts.registerSocket('interrupt','c','t',{host:REMOTE_HOST, port:REMOTE_PORT, name:'interrupt', data:{pins:PINS, type:'interrupt'}})
|
|
// interrupts.registerSocket('listen','s','t',{port:1777})
|
|
await interrupts.init()
|
|
await interrupts.socketsInit()
|
|
|
|
})().catch(err => {
|
|
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
|
|
// process.kill(process.pid, 'SIGTERM')
|
|
})
|