S-function hangs with Arduino c++ code
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!