The PHP file is shown here:
<?phpecho shell_exec('/home/pi/Documents/tom/tom/Debug/tom');?>
The relevant C++ code is here for I2C bus is here
const char *fileName = "/dev/i2c-1"; // change to /dev/i2c-0 if you are using a revision 0002 or 0003 model Bvoid write_byte_data(char address, char reg, char value) { if ((i2cbus = open(fileName, O_RDWR)) < 0) { printf(".Failed to open i2c port for write\n"); This message pops up when started by the PHP file!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! exit(1); } if (ioctl(i2cbus, I2C_SLAVE, address) < 0) { printf("..Failed to write to i2c port for write\n"); exit(1); } buf[0] = reg; buf[1] = value; if ((write(i2cbus, buf, 2)) != 2) { printf("...Failed to write to i2c device for write\n"); exit(1); } close(i2cbus);}
Can somebody please explain/I think it is a problem with the userrights of the Raspb and can please exactly what to program in Linux
and also please how parameters can be checked in Linux. PS program also dont work when using root rights (sudo -i)
Thank you for help Tom
PS im using a Raspberry 3 B /////// the parameter O_RDWR is no where declared...is this correct?