tomme 1) To insert printf() is correct "vi ~/RTIMULib/RTIMULib/RTIMUSettings.cpp"?
Well, if you are familiar with vi, then yes! Otherwise, nano is more intuitive
tomme 3) what command must I run after printf() insertions?
Rebuild and rerun the program. The line below is a more generic version of the make and ./Output/RTIMULibDrive commands above. This version you can run it regardless of what folders you are currently in:
make -C /root/RTIMULib/Linux/RTIMULibDrive/ && /root/RTIMULib/Linux/RTIMULibDrive/Output/RTIMULibDrive
tomme 2) Where I must put printf() in ~/RTIMULib/RTIMULib/RTIMUSettings.cpp ?
printf() allows to print arbitrary strings. I am suggesting that you could add a printf("mystring\n);" statement at some meaningful places, to verify that the code is indeed going through that path. The\n` symbol at the end of the string indicates "newline".
For instance, around line 78:
if (HALOpen()) {
printf("HALOpened\n");
if (HALRead(MPU9150_ADDRESS0, MPU9150_WHO_AM_I, 1, &result, "")) {
if (result == MPU9250_ID) {
if HALOpened is printed to the screen, then you know that the program has indeed successfully reached that line of code. You could add some more further below, around line 200:
printf("About to read L3GD20H_ADDRESS1\n");
if (HALRead(L3GD20H_ADDRESS1, L3GD20H_WHO_AM_I, 1, &result, "")) {
printf("Reading L3GD20H_ADDRESS1 was successful, WHO_AM_I returned 0x%x\n", result);
if (result == L3GD20H_ID) {
printf("The result matched L3GD20H_ID\n");
if (HALRead(LSM303D_ADDRESS1, LSM303D_WHO_AM_I, 1, &altResult, "")) {
Now, if the detection was working properly, you should see printed, after the Settings file RTIMULib.ini loaded line:
HALOpened
About to read L3GD20H_ADDRESS1
Reading L3GD20H_ADDRESS1 was successful, WHO_AM_I returned 0xd7
The result matched L3GD20H_ID.
if it is not successful, only some of these will be printed. We can then work from there.
Note that the line
printf("Reading L3GD20H_ADDRESS1 was successful, WHO_AM_I returned 0x%x\n", result);
is printing a "formatted string", where the symbol %x is replaced by the hexadecimal representation of the value stored in the variable result. If you want to know more about printf, see, e.g.: here.