Changeset 72 in pacpussensors for trunk/Sick


Ignore:
Timestamp:
Dec 4, 2014, 1:02:02 PM (10 years ago)
Author:
DHERBOMEZ Gérald
Message:
  • Correction of a little bug in gps component (property recording bad)
  • Improvement of sick lms151 component
  • Correction of bug in sick LDRMS : buffer overflow in a memcpy
Location:
trunk/Sick
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Sick/AbstractSickSensor.h

    r37 r72  
    1515#define ABSTRACTSICKSENSOR_H
    1616
    17 #include <QThread>
     17#include <QObject>
    1818#include "SickSocket.h"
    1919
     
    4545 * interfaces using SickComponent, used with the PACPUS Framework.
    4646 */
    47 class AbstractSickSensor : public QThread
     47class AbstractSickSensor : public QObject
    4848{
    4949    Q_OBJECT
    5050public:
    51     void run(){}
    5251
    5352    virtual void stopActivity() = 0 ; /*!< to stop the processing thread */
  • trunk/Sick/SickLDMRSSensor.cpp

    r71 r72  
    322322        // we have a complete message available that we can add to the list
    323323        MessageLDMRS msg;
    324         memcpy(msg.body, pendingBytes.data.c_str() + index, msgSize);
    325 
     324                if (msgSize <= sizeof(msg.body))
     325                        memcpy(msg.body, pendingBytes.data.c_str() + index, msgSize);
     326                else
     327                        LOG_ERROR("Impossible to copy the pending bytes in the MessageLDMRS, checked the size of the body in the code! Data might be corrupted...");
    326328//        msg->body = messageData;
    327329
  • trunk/Sick/SickLDMRSSensor.h

    r71 r72  
    2626#include <string>
    2727
    28 #define BODY_MAX_SIZE   10000
     28// Constants for Sick LDMRS
     29static const uint32_t DATA_HEADER_SIZE = 24; // in bytes
     30static const uint32_t SCAN_HEADER_SIZE = 44; // in bytes
     31static const uint32_t MEASURED_POINT_DATA_SIZE = 10; // in bytes
     32// @12.5Hz, the sensor has a multiresolution:
     33// - lateral range (50 to 30 degrees and -30 to -60 degrees): 0.5 degrees
     34// - medium range (30 to 10 degrees and -10 to -30 degrees): 0.25 degrees
     35// - central range (10 to -10 degrees): 0.125 degrees
     36// So theorically, the max number of points per layer is (20+30)/0.5 + (20+20)/0.25 + 20/0.125 + 1 = 321
     37static const uint32_t MAX_SCAN_POINT_PER_LAYER = 321;
     38static const uint32_t MAX_SCAN_POINT = 4 * MAX_SCAN_POINT_PER_LAYER; // 4 layers sensor
     39static const uint32_t BODY_MAX_SIZE = DATA_HEADER_SIZE + SCAN_HEADER_SIZE + MEASURED_POINT_DATA_SIZE *  MAX_SCAN_POINT; // 12 908
    2940
    3041// Export macro for SickLDMRS DLL for Windows only
     
    8293    /** This array pointer points to allocated in memory (basically, in heap (malloc)) and then must be freed (free) when the whole message is decoded and stored. */
    8394    char body[BODY_MAX_SIZE];
    84 
     95       
    8596    //! Time when the message is received.
    8697    road_time_t time;
     
    120131    ~SickLDMRSSensor();
    121132
    122     void run() {}
    123133
    124134    void stopActivity(); /*!< To stop the processing thread */
  • trunk/Sick/SickLMSSensor.cpp

    r71 r72  
    321321    message->splitMessage = new std::vector<std::string>();
    322322
    323     for(int i; i < message->msgSize; ++i){
     323    for(int i=0; i < message->msgSize; ++i){
    324324        std::string* str = new std::string();
    325325        while(message->body[i] != ' ' && i < message->msgSize){
  • trunk/Sick/SickLMSSensor.h

    r42 r72  
    104104    ~SickLMSSensor();
    105105
    106     void run() {}
    107 
    108106    void stopActivity(); /*!< To stop the processing thread. */
    109107    void startActivity(); /*!< To start the processing thread. */
  • trunk/Sick/SickSocket.cpp

    r42 r72  
    8080
    8181  frame->size = socket->read(frame->msg, (qint64) frame->size);
    82 
    83   SickFrameEvent *e = new SickFrameEvent;
     82 
     83          SickFrameEvent *e = new SickFrameEvent;
    8484  e->frame = frame;
    8585  QCoreApplication::postEvent((QObject*)myParent, e);
Note: See TracChangeset for help on using the changeset viewer.