-
Notifications
You must be signed in to change notification settings - Fork 59
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
I2C bit banging #12
Comments
Looks quite straightforward, I'll seee what I can do. |
I've made the changes locally, not had time to test it though. Will do so ASAP and commit once done. |
Great, thanks for the quick reply! |
To be clear I've added this to the pigpio Java wrapper only at this stage. I don't think it will be possible to add this in a device agnostic fashion as it would be extremely difficult to add to all other providers assuming that most if not all of them don't support this. |
I think that's reasonable, and works for me. |
Finally had a chance to simply check the code compiles which it does. Have committed changes to github, plus updated the compiled library. Note this is currently untested, please let me know of any issues. I will test with an I2C LCD display over the weekend. |
Hi, I'm probably missing something here, but i don't seem to find the implementation. The 'diozero-provider-pigpio' has not been updated with your last commit. Thanks again |
Sorry, just realised you have updated the 'pigpioj' project. I'll give it a try. |
Yes, I should have said. I've incorporated the equivalent but slightly more useable wrapper methods into the pigpio provider. Will commit the changes today. Let me know of any issues. |
Hi, I've tried it, and i always get the error: PI_BAD_I2C_RLEN. I can see that the write operation works, but then something goes wrong with the reading. The same transaction over the Python wrapper works just fine. The set of operations, a repeated start transaction, is as follows: [0x04, 0x62, 0x02, 0x07, 0x01, 0x01, 0x02, 0x06, 0x32, 0x03, 0x00]. Still trying to figure it out... |
Also there seems to be a small typo/bug on the pigpio C library: It should probably read PI_BAD_I2C_WLEN and not PI_BAD_I2C_RLEN |
I wonder if I need to set the ByteOrder... I've checked in a fix for the wrong BAD_I2C constants as well as set the byte order in the pigpio provider class |
Thanks, i'll give it a try this evening. Btw, for my implementation i'm using the pigpioj code directly, and not the diozero wrapper. About the wrong error code. It looks to me like a problem with the actual pigpio C implementation, and not your wrapper. Would you agree? |
So, i got it work. The problem was not with the endianness but rather with a small "mismatch" in the expected buffer sizes. Looking at the C implementation in pigpio.c (https://github.com/joan2937/pigpio/blob/master/pigpio.c#L10351) the outBuf must be at least 1 byte larger than the number of bytes you want to read. I think this line should rather read: "if ((bytes + outPos) <= outLen)", otherwise the behaviour is a bit unexpected. |
Good work, let me know if I need to make any changes otherwise I'll close this issue. |
On pigpioj i wouldn't change anything. On the diozero-provider-pigpio you can remove the line that sets the endianness. Otherwise, keep up the good work, and thanks again! |
Done, thanks for testing this out. I'm always happy to receive feedback and suggestions. |
Hi,
First of all thanks for the great library. I use the pigpio Python library, and i find the I2C bit banging functions very useful. They don't seem to be included in the current release (?) Are there any plans to bring them into diozero?
Thanks
Tiago
The text was updated successfully, but these errors were encountered: