Skip to content

Conversation

@fhwe71
Copy link

@fhwe71 fhwe71 commented Mar 2, 2021

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.

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.
@fhwe71 fhwe71 changed the title Update linux_userspace.c Bugs in example code, problems with force mode and missing ioctl Mar 2, 2021
@Graerth
Copy link

Graerth commented Aug 24, 2021

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.

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.

@lauralindzey
Copy link
Contributor

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 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that you've moved the line of code that this is referring to, you probably want to move the comment too =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants