Closed VaderMester closed 4 years ago
Is the value being passed to writeByte
an unsigned integer?
In other words, does Number.isInteger(values)
return true?
If not, that would explain the problem.
Yep, you were right. It is strange, because all of my variables are declared in hex, like
var REGISTER_GPIOA = 0x00,
REGISTER_GPIOB = 0x01,
REGISTER_GPIOA_PULLUP = 0x0C,
REGISTER_GPIOB_PULLUP = 0x0D,
READ_GPIOA_ADDR = 0x12,
READ_GPIOB_ADDR = 0x13,
WRITE_GPIOA_ADDR = 0x14,
WRITE_GPIOB_ADDR = 0x15;
Putting this into my calling functions brute-force solved the issue :)
. . var reg = (cmd & 0xff); var data = (values & 0xff); i2c1.writeByte(this.address, reg, data, function (err) { . .
Thank you for providing the feedback and good to hear that it's working now.
I'm using this lib in my Homebridge plugin. I'm getting checkbyte errors. Below byteToPass value is the byte my function is passing to i2c, I write it out in console to see if I'm doing something wrong.
As you can see the Byte I'm passing is correct. It first got the error with a value 255, and tried it with 254. No idea what can be the issue. Init of the bus is done like this:
this.i2c1 = i2c.openSync(1); //open /dev/i2c-1
Function call: