uci-interrupt/test/interrupt.test.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-01-11 15:11:34 -08:00
'use strict'
2017-01-21 12:23:45 -08:00
// const expect = require('chai').expect
const Interrupt = require('../').Interrupt
2017-01-11 15:11:34 -08:00
//time-stamp for use when watching to distinguish reruns in console
// place in alpha first file only
let date = new Date(Date.now())
console.log(date.getMinutes(), "\:", date.getSeconds())
let inter17 = new Interrupt(17, {
hook: 'a hook to something to do'
// pullup: (num, state) => { return `someccommand using num and state` } // if rpi then specify a function that returns a command line line pullup tool using num and state
// pullup: 'external' // pullup not set with a command line utility - use alternative method such as device tree overlays
})
2017-01-11 15:11:34 -08:00
2017-01-21 23:48:17 -08:00
// inter17.on('fired', hook => {
// console.log('Listener fired and returned:', hook)
// })
2017-01-11 15:11:34 -08:00
inter17.init()
.then((resp) => {
console.log(resp)
console.log('initialzed, waiting for interrupt to fire')
})
.catch(err => console.log("returned error:\n", err))
inter17.on('fired', hook => { counter(hook) })
2017-01-21 12:21:16 -08:00
2017-01-21 23:48:17 -08:00
let count = 0
function counter(hook) {
count++
console.log(`******${count}********`)
console.log(hook)
console.log(`----------------------`)
}