node-red-contrib-i2c icon indicating copy to clipboard operation
node-red-contrib-i2c copied to clipboard

msg.bus not working

Open Support-GMI opened this issue 4 years ago • 4 comments

Hello,

The use of the msg.bus variable as input to the i2c scan node does not work and systematically uses bus 1. I have not tested with the i2c In and i2c Out nodes. After looking at the code it even seems that msg.bus is not even expected.

regards,

Support-GMI avatar Dec 02 '21 09:12 Support-GMI

Finally msg.bus is not implemented. Here is an example of the modification in "26-i2c.js" for the implementation in I2C scan. The same can be done on I2CIn and I2COut. In function I2CScanNode :

//node.port = I2C.openSync( node.busno ); node.on("input", function(msg) { var busno = isNaN(parseInt(msg.bus)) ? node.busno : parseInt(msg.bus); node.port = I2C.openSync(busno); node.port.scan(function(err, res) { ....

If it can help anyone ! regards,

Support-GMI avatar Dec 02 '21 11:12 Support-GMI

A pull request to fix the node would help everyone :-) Thanks in advance !

dceejay avatar Dec 02 '21 11:12 dceejay

A pull request to fix the node would help everyone :-) Thanks in advance !

Hi dceejay,

I'm not used to how GitHub works because this is the first time I've raised an issue on GitHub. I will try to write a correct "pull request" regarding the assignment of the i2C bus number by msg.bus.

( sorry for my english, thanks google translator :) )

Support-GMI avatar Dec 02 '21 11:12 Support-GMI

Great - welcome aboard !
(don't worry we can help you fix it if it needs it.)

dceejay avatar Dec 02 '21 14:12 dceejay