add mcp interrupt processing commands, find, reset
parent
5833f42464
commit
cb1977a8ea
|
@ -99,14 +99,28 @@ 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]
|
||||||
|
|
Loading…
Reference in New Issue