S-function hangs with Arduino c++ code

1 Ansicht (letzte 30 Tage)
Alberto Prud'homme
Alberto Prud'homme am 26 Apr. 2016
Hello;
I'm trying to implement a S-function block with the code of arduino to read a IMU sensor. I have the code in c++ and when I send it to the Arduino it works fine, but when I insert to the S-function block during the debug didn't receive any error, but when I turn on the Arduino it hangs.
By testing I found that the program debug in the line: imu.read(); (from the wrapper file)
Following the instruction I found that the program hangs in these lines:
void LSM6::readGyro(void)
{
Wire.beginTransmission(address);
// automatic increment of register address is enabled by default (IF_INC in CTRL3_C)
Wire.write(OUTX_L_G);
Wire.endTransmission();
Wire.requestFrom(address, (uint8_t)6);
uint16_t millis_start = millis();
while (Wire.available() < 6) {
if (io_timeout > 0 && ((uint16_t)millis() - millis_start) > io_timeout)
{
did_timeout = true;
return;
}
}
In the While instruction the value of Wire.available() always send a 0, so never pass from the while.
I can't found the origin of the problem, and it's harder to find because the code works fine directly from the INO and the C++ code.
Note: From the same libraries of Arduino I made other S-function blocks without problem, but this I can make it works.
I'm attaching all the file, because there are a lot of c++ and headers for it.
I hope you can help me because I can't find the solution or any way to find it.
Thanks a lot.

Antworten (0)

Kategorien

Mehr zu MATLAB Support Package for Arduino Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by