add mcp interrupt processing commands, find, reset
parent
5833f42464
commit
cb1977a8ea
|
@ -99,15 +99,29 @@ export const pin = {
|
|||
},
|
||||
// will create packet to determine pin caused interrupt, packet will come from interrupt module
|
||||
interrupt: {
|
||||
find: async function (packet) {
|
||||
console.log('interrupt fired',packet)
|
||||
return Promise.resolve({cmd:null})
|
||||
reset: async function (port) {
|
||||
console.log('resetting interrupt for port', (port ? 'B' : 'A'))
|
||||
return await this.bus.read(sreg(PIN.cmd.intcap,port))
|
||||
},
|
||||
find: async function (inter) {
|
||||
console.log('lookup info on device and port for pin fired',inter.pin, inter.times)
|
||||
let port = null
|
||||
let packet = {pins:'all',reg:'intf', port:port}
|
||||
let res = await this.pin.status(packet)
|
||||
this.pin.interrupt.reset()
|
||||
let pin = _.byteFormat(res.status.port, { in: 'ARY', out: 'PLC' })[0]
|
||||
console.log('pin that caused the interrupt', pin)
|
||||
// found it now tell someone what relay(s) to fire
|
||||
res.pin = pin
|
||||
res.times = inter.times
|
||||
res.inter = inter.pin
|
||||
return res
|
||||
},
|
||||
report: ()=>{}, // come here after determining which pin to report to requester
|
||||
async: async ()=>{}
|
||||
}
|
||||
}
|
||||
|
||||
} // end pin.
|
||||
|
||||
const parsePins = function(pins) {
|
||||
if (typeof pins==='number') pins = [pins]
|
||||
if (typeof pins==='string') {
|
||||
|
|
Loading…
Reference in New Issue