Skip to content
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

Bugs in example code, problems with force mode and missing ioctl #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions examples/linux_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
* \include linux_userspace.c
*/

#ifdef __KERNEL__
//#ifdef __KERNEL__
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#endif
//#endif

/******************************************************************************/
/*! System header files */
Expand Down Expand Up @@ -153,18 +153,19 @@ int main(int argc, char* argv[])
fprintf(stderr, "Failed to open the i2c bus %s\n", argv[1]);
exit(1);
}

#ifdef __KERNEL__

id.dev_addr = BME280_I2C_ADDR_PRIM;
//#ifdef __KERNEL__
if (ioctl(id.fd, I2C_SLAVE, id.dev_addr) < 0)
{
fprintf(stderr, "Failed to acquire bus access and/or talk to slave.\n");
exit(1);
}

#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 =)

id.dev_addr = BME280_I2C_ADDR_PRIM;


dev.intf = BME280_I2C_INTF;
dev.read = user_i2c_read;
Expand Down