MCP23017 driver and Raspberry Pi - Read Buffer not correct #568
Closed
Description
I am trying to use MCP23017 with Raspberry PI to turn PortA pin 0-7 ON ( ie write "1" to port A , pin 0-7). However, the driver didn't keep already "ON" pin to stay "ON". Basically it can only keep one and only one of the pin 0-7 "ON". There is no way to turn more than one pin ON at the same time.
After some debugging, it turns out the "read" function in mcp23017_driver.go return the wrong buffer. "IODIR" supposed to be in buf[20] but it was in buf[19].
I don't know if this is a problem specific to RPi. I have tried both RPi2 and RPi3. In order to fix this, I have to change "read" function to return buf[register-1] instead.
if register != 0 {
return buf[register-1], nil
} else {
return buf[register], nil
}