I have a big problem:
the compoment I'm developing / fixing is almost finished, but the error handling does not work the proper way.
I've opened a ticket at the i2c developer's fork, but I'm not sure if it's a component error, or NR problem?
opened 10:01AM - 14 Sep 21 UTC
Hi,
I'm fixing / enhacing currently an MPC chip node for NodeRed: https://git… hub.com/PizzaProgram/mcp23017chip
I'm inserting lot's of try .. catch lines to make the old code of @willhey stable.
# But it seems, the code runs a few lines more, and does not stop at .openSync error !
```javascript
try {
if (log2consol) console.log("myTimer: opening bus... Time: " + new Date( _readTime ).toISOString().slice(11, -1) );
let _aBus = null;
// start async error handling: << does not work either
// this.on('error', function( i2cErr ) { timerErrorHandler(i2cErr) } );
let ipA;
let ipB;
_aBus = i2cModule.openSync(globalChipNode.busNum + 999); // << FORCING an ERROR ... should stop at this line !
if (_aBus) { // << 2. problem: _aBus is not null, even, if it could not open the bus !
if (log2consol) console.log("OK. Bus Opened. Now reading A+B banks... Typeof _aBUS:" + typeof(_aBus));
_processState = 1;
ipA = _aBus.readByteSync(_addr, 0x12);
ipB = _aBus.readByteSync(_addr, 0x13);
if (log2consol) console.log("Read success ipA=" + ipA + " ipB=" + ipB);
_processState = 3;
_aBus.closeSync();
...
```
2. problem: _aBus is not null, even, if it could not open the bus !
The i2c code developer answered: .openSync() works async way · Issue #105 · fivdi/i2c-bus · GitHub
As it turns out, the openSync
command does not do anything, just creates an object.
The i2c bus is opened only at the first attempt to write a byte to the bus.
system
Closed
1 October 2021 08:11
3
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.