I am attempting to increase the frequency at which I read samples from the I2C dedicated pins. I have attempted this through the wiringPi library (C code), from which I reached just about 900Hz. As well as with python, I was able to reach roughly the same figures. I did some research and was lead to multi-byte reads via ioctl and read(), write() functions which as far as I understand are more low level, direct access of the I2C bus as opposed to the wiringPi library and any other python library I could've used prior. Though after some code testing, I am stagnating at just about 1.1KHz for a 14 byte read (9 seconds for 10K samples). I am unsure what I am missing here or how I can improve this as I would like to hit around 2KHz.
Reason being is I would like to thread in between and around the I2C communication. Also if anyone has any pointers as how this should be approached that would be appreciated.
Code for reading data, file printing adds 2 seconds, without any of the commented out code the time for 10000 samples is roughly 7 seconds.
while(counter<10000){
buf[0] = 0x3B;
write(fd,buf,1);
read(fd,buf,14);
// if ((write(fd, buf, 1)) != 1){
// // Send the register to read from
// fprintf(stderr, "Error writing to MPU6050\n");
// }
// if (read(fd, buf, 14) != 14){
// fprintf(stderr, "Error reading from MPU6050\n");
// }else{}
// for(int i=0;i<14;i++){
// fprintf(new_file,"%.0f,",(float)buf[i]);
// }
// fprintf(new_file, "%s\n","");
counter++;
}