我有一个简单的 NodeJS 程序,它使用johnny-five
包连接 3 个板上。
Object.keys(arduinosByKey).forEach(key => {
const arduino = arduinosByKey[key]
const board = new five.Board({
port: new etherPort(arduino.port)
})
board.on('ready', () => {
// Do something...
})
board.on('close', e => {
// ...
})
board.on('exit', e => {
// ...
})
board.on('fail', e => {
// ...
})
// How to catch timeouts here? None of above catches.
})
问题是当一个板出现故障(例如超时)时,整个 NodeJS 程序都会停止:
Device or Firmware Error A timeout occurred while connecting to the Board.
如何捕捉董事会异常?