New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MCP23017 driver and Raspberry Pi - Read Buffer not correct #568
Comments
@ulisesflynn any comments on this? |
@barrowkwan I am looking into this now, I'll get back to you on this issue by tomorrow. |
Hi @barrowkwan there is a PR from @ulisesflynn that appears should fix things that is located here: Are you able to test it out and ensure it solves your specific issues? |
Yes that fixed it. thanks! |
Hi After looking at the code, I think the problem is with the WriteGPIO. We should be able to set 1 or 0 to the pin ( ie on or off ). However, if we try to send a value "1" ( ie write 1 to the output pin, it will change the pin to be input instead of output ). |
The problem is with the WriteGPIO function. It should always use clearBit and write to IODIR. so instead of
it should just
|
@ulisesflynn can you please help out again? Seems I need to obtain a MCP23017 for the workshop so I can also help test this out. |
I'll look at this tomorrow and see what's going on, I apologize for my slow response.
|
@barrowkwan I've pushed up a PR for the writegpio/readgpio code, let me know if this fixes it. |
yes, that fixed it. thanks! |
Thanks again @barrowkwan for testing this out. |
This has just been released as part of v1.11.1 so now closing. Thanks again! |
The rework of read() and other cleanups (except leftover #810) in PR #569 and #576 are fine and improve the code readability. So, for completeness only, after some investigation for #810: The first assumption of the issuer, that "return buf[register-1], nil" would fix the bug, could maybe work in special cases, but will not work in general. The smallest fix would be adding following lines before start reading, e.g. (first 3 lines with code added):
|
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.
The text was updated successfully, but these errors were encountered: