add mcp interrupt processing commands, find, reset

master
David Kebler 2018-02-23 21:16:35 -08:00
parent 5833f42464
commit cb1977a8ea
1 changed files with 19 additions and 5 deletions

View File

@ -99,15 +99,29 @@ export const pin = {
}, },
// will create packet to determine pin caused interrupt, packet will come from interrupt module // will create packet to determine pin caused interrupt, packet will come from interrupt module
interrupt: { interrupt: {
find: async function (packet) { reset: async function (port) {
console.log('interrupt fired',packet) console.log('resetting interrupt for port', (port ? 'B' : 'A'))
return Promise.resolve({cmd:null}) 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 report: ()=>{}, // come here after determining which pin to report to requester
async: async ()=>{}
}
} }
} // end pin.
const parsePins = function(pins) { const parsePins = function(pins) {
if (typeof pins==='number') pins = [pins] if (typeof pins==='number') pins = [pins]
if (typeof pins==='string') { if (typeof pins==='string') {