Bugs in example code, problems with force mode and missing ioctl#84
Bugs in example code, problems with force mode and missing ioctl#84fhwe71 wants to merge 1 commit intoboschsensortec:masterfrom
Conversation
How did you make this work? Like this, ioctl is never started and device address is nowhere used. Besides that, setting dev_addr was done after ioctl call, Consequently, it failed. With the proposed changed it runs on my Raspberry Pi Zero. Nevertheless the proposed force mode code only returns static values. Could be fixed by using the normal mode with code as proposed in the project's documentation. Error handling for user read would be fine, but ok, it's up to each user. Still I have some doubts when I compare this to I2C read&write methods of WiringPi, which calls ioctl before each access. Did not follow up here, but guess it's needed when you want to access different devices within a program.
Had same problems, used your fix and the force mode return values can be fixed by increasing the req_delay (would be nice if it was requested frequency instead of delay time). I didn't need that high rate of reading anyway so on my rpi4 I just multiplied req_delay by 10k, just mentioning in case someone else just wants a quick and dirty solution. |
|
I also had the same problems, and independently made just about the same changes to the code in order to always use ioctl to set the slave address, after which it worked. (I'm running on an ODroid, rather than a RPi, but I don't think that should make a difference to why this code didn't work in the first place.) |
| #endif | ||
| //#endif | ||
|
|
||
| /* Make sure to select BME280_I2C_ADDR_PRIM or BME280_I2C_ADDR_SEC as needed */ |
There was a problem hiding this comment.
Given that you've moved the line of code that this is referring to, you probably want to move the comment too =)
How did you make this work?
Like this, ioctl is never started and device address is nowhere used. Besides that, setting dev_addr was done after ioctl call,
Consequently, it failed.
With the proposed changed it runs on my Raspberry Pi Zero.
Nevertheless the proposed force mode code only returns static values.
Could be fixed by using the normal mode with code as proposed in the project's documentation.
Error handling for user read would be fine, but ok, it's up to each user.
Still I have some doubts when I compare this to I2C read&write methods of WiringPi, which calls ioctl before each access.
Did not follow up here, but guess it's needed when you want to access different devices within a program.