Answer the question
In order to leave comments, you need to log in
How to access /dev/mem?
Using the pigpio library, there is no way to access the GPIO two I2C ports through /dev/mem without root. I can access /dev/gpiomem but there is no source for Tinker Board to recompile it, what can I do?
Everything works with root:
/dev/mem access test:
/dev/gpiomem access:
No access after group modification and write permission for everyone:
Answer the question
In order to leave comments, you need to log in
How to write to I2C port of Tinker Board for imu sensors without using /dev/mem:
#include <sys/ioctl.h>
#include <unistd.h>
#define I2C_SLAVE 0x0703
fd_1 = open("/dev/i2c-1", O_RDWR /*чтение и запись*/);
ioctl( fd_1, I2C_SLAVE, _address /* Адресс устройства*/ );
bool BNO055::write8(bno055_reg_t reg, uint8_t value /*регистр устройства, данные*/)
{
uint8_t buf[2] = { reg, value };
if(write( fd_1, &buf, 2) != 2) {
qDebug()<<"Ошибка записи I2C в регистр: "<<reg;
return -1;
}
return true;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question