Hello,
This is my first time using mbed, so I am sorry for the mistake i will make. I will update the subject based on your suggestions. For example, i didn’t find a proper way to share my code.
I am trying to get data from a Lidar using the STM Nucleo-F401RG.
It used to be able to see the data using a serial bus, output in mbed console, using RawSerial :
RawSerial se_lidar(PA_11, PA_12, BAUDERATE); Serial PC(SERIAL_TX,SERIAL_RX);
I am using rplidar(lidar supplier) functions to use the lidar :
//Getting data
buf = tim.read_ms();
while(tim.read_ms()-buf<=readTime){//Crashes after around 400
_PC.printf(“tim.read_ms() : %d\n”,tim.read_ms());
lidar.waitPoint(0);//Causes the crash
}
But as i have written in the comment, the program crashes after a while, giving me an hardfault error. Looking at the fault registers, the only fault bit set to 1 is UFSR[2] : integrity check error.
I tried to find posts with similar problem but i got no result.
On the other hand, the debugger led me to SIGSEGV fault (top left of the picture, which relates to a segmentation fault) and the error message :
except.S: No such file or directory
I couldn’t actually find where this error came from.
I obviously understand that you need more of my code to help me out here. I am looking for a proper way to attach it.
In short, i am using the RPLidar method “waitpoint” to get the data,
RPLidar lidar;
lidar.waitPoint(0);//Causes the crash
then i used the stored data :
lidar.Data[j]
“waitpoint” is defined by the supplier as :
u_result RPLidar::waitPoint(uint32_t timeout){
uint8_t recvPos = 0;
uint32_t startTs = timers.read_ms();
uint32_t waitTime;
rplidar_response_measurement_node_t node;
uint8_t* nodebuf = (uint8_t*)&node;
uint8_t currentByte;
while ((waitTime = timers.read_ms() - startTs) <= timeout) {
if(_binded_serialdev->readable())
currentByte = _binded_serialdev->getc();
else
continue;
switch (recvPos) {
case 0: // expect the sync bit and its reverse in this byte {
{
uint8_t tmp = (currentByte >> 1);
if ((tmp ^ currentByte) & 0x1) {
// pass
}
else {
continue;
}
}
break;
case 1: // expect the Check bit to be 1
{
if (currentByte & RPLIDAR_RESP_MEASUREMENT_CHECKBIT) {
// pass
}
else {
recvPos = 0;
continue;
}
}
break;
}
nodebuf[recvPos++] = currentByte;
if (recvPos == sizeof(rplidar_response_measurement_node_t)) {
// store the data ...
_currentMeasurement.distance = node.distance_q2 / 4.0f;
_currentMeasurement.angle = (node.angle_q6_checkbit >> RPLIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) / 64.0f;
_currentMeasurement.quality = (node.sync_quality >> RPLIDAR_RESP_MEASUREMENT_QUALITY_SHIFT);
_currentMeasurement.startBit = (node.sync_quality & RPLIDAR_RESP_MEASUREMENT_SYNCBIT);
ang = (int)_currentMeasurement.angle;
//dis = _currentMeasurement.distance;
if (ang >= angMin && ang <= angMax) Data[ang] = _currentMeasurement;
//.distance;// (float) ang;
//wait_ms(200);
/* for(int i = 0; i < size_t(nodebuf); i++)
Data[i] = nodebuf[i]*/
//if (ang >= angMin && ang <= angMax)Data[ang] = 12.0;//_currentMeasurement.distance;
//continue;
return RESULT_OK;
}
}
return RESULT_OPERATION_TIMEOUT;
}
If you can lead me to a related topic, help me on my specific error or help me with the code upload to the forum, that would be awesome.
Thanks in advance, i will update this post as much as possible.