I have been experimenting with the BrickPi tank robot. I want to use C++11 for my project, so I have spent some time trying to get BrickPi.h to work in g++. I am able to run the “LEGO Motor - Test.c” when I compile it in C, but when I run that test program C++'ified with C++ BrickPi version there are multiple read retry failures. In order to understand why C++ was not working as expected, I started investigating the C version, and ran into a strange bug, which I suspect is timing related:
If I modify this code https://github.com/DexterInd/BrickPi_C/blob/master/Sensor_Examples/BrickPi.h#L753 to the following:
while(i < (ByteCount + 3)){
write(uart0_filestream, &tx_buffer[i], 1);
printf("Tx buffer %u: %u\n", i, tx_buffer[i]);
i++;
}
Then the BrickPiSetupSensors() times out on reading the output in BrickPiRx. I would appreciate any help with this. Does this have anything to do with I2C settings? You can find my code at the following github project: https://github.com/ayeganov/tank_roboto/tree/motor