Changeset 61 in pacpussensors for trunk/Sick/SickLDMRSSensor.cpp


Ignore:
Timestamp:
Jul 22, 2014, 4:36:25 PM (10 years ago)
Author:
DHERBOMEZ Gérald
Message:

commit after experiments on track
Issue with GPS receiver, no data recorded

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Sick/SickLDMRSSensor.cpp

    r52 r61  
    138138    LOG_TRACE("destructor (" << this->name_ << ")");
    139139
    140     S_socket->sendToServer(QString((u_int32_t)0x0021));
     140    S_socket->sendToServer(QString((uint32_t)0x0021));
    141141
    142142    S_socket->closeSocket();
     
    157157
    158158
    159 u_int32_t SickLDMRSSensor::findMagicWord(const char * message, const unsigned length)
     159uint32_t SickLDMRSSensor::findMagicWord(const char * message, const unsigned length)
    160160{
    161161    if (length < 4) {
     
    164164
    165165    unsigned long i = 0;
    166     while(*((u_int32_t*)(message+i)) != 0xC2C0FEAF){ // BigE
     166    while(*((uint32_t*)(message+i)) != 0xC2C0FEAF){ // BigE
    167167        if (i == length) {
    168168            return -1;
     
    175175
    176176
    177 u_int32_t SickLDMRSSensor::getMessageSize(const char * message, const unsigned length, const long magicWordIndex)
     177uint32_t SickLDMRSSensor::getMessageSize(const char * message, const unsigned length, const long magicWordIndex)
    178178{
    179179
     
    202202{
    203203    // address = base + Data header size (24-byte long) + offset
    204     msg.hScan.scanNumber = *((u_int16_t*)(msg.body+24));
    205     msg.hScan.scannerStatus = *((u_int16_t*)(msg.body+24+2));
    206     msg.hScan.phaseOffset = *((u_int16_t*)(msg.body+24+4));
    207     msg.hScan.startNtpTime = *((u_int64_t*)(msg.body+24+6));
    208     msg.hScan.endNtpTime = *((u_int64_t*)(msg.body+24+14));
    209     msg.hScan.ticksPerRot= *((u_int16_t*)(msg.body+24+22)); // needed to compute angle (°)
     204    msg.hScan.scanNumber = *((uint16_t*)(msg.body+24));
     205    msg.hScan.scannerStatus = *((uint16_t*)(msg.body+24+2));
     206    msg.hScan.phaseOffset = *((uint16_t*)(msg.body+24+4));
     207    msg.hScan.startNtpTime = *((uint64_t*)(msg.body+24+6));
     208    msg.hScan.endNtpTime = *((uint64_t*)(msg.body+24+14));
     209    msg.hScan.ticksPerRot= *((uint16_t*)(msg.body+24+22)); // needed to compute angle (°)
    210210    msg.hScan.startAngle = *((int16_t*)(msg.body+24+24));
    211211    msg.hScan.endAngle = *((int16_t*)(msg.body+24+26));
    212     msg.hScan.numPoints = *((u_int16_t*)(msg.body+24+28));
     212    msg.hScan.numPoints = *((uint16_t*)(msg.body+24+28));
    213213
    214214//    msg.hScan.mountingYawAngle = *((int16_t*)(msg.body+24+30));
     
    369369        }
    370370
    371         ScanPoint scanPoints[msg.hScan.numPoints];
     371        ScanPoint * scanPoints = new ScanPoint[msg.hScan.numPoints];
    372372
    373373        // replace memory with structured data
     
    375375            scanPoints[i].layerEcho = *((uchar*)(msg.body + index));
    376376            scanPoints[i].flags = *((uchar*)(msg.body + index + 1));
    377             scanPoints[i].angle = *((u_int16_t*)(msg.body + index + 2));
    378             scanPoints[i].distance = *((u_int16_t*)(msg.body + index + 4));
    379             scanPoints[i].echoPulseWidth = *((u_int16_t*)(msg.body + index + 6));
     377            scanPoints[i].angle = *((uint16_t*)(msg.body + index + 2));
     378            scanPoints[i].distance = *((uint16_t*)(msg.body + index + 4));
     379            scanPoints[i].echoPulseWidth = *((uint16_t*)(msg.body + index + 6));
    380380        }
    381381
    382382        memcpy(msg.body, scanPoints, sizeof(ScanPoint) * msg.hScan.numPoints);
     383
     384                delete[] scanPoints;
    383385    }
    384386    else if (msg.hData.dataType == SICKLDMRS_OBJECTDATA_TYPE){
     
    434436void SickLDMRSSensor::configure(){
    435437    // Start measuring
    436     // S_socket->sendToServer(QString((u_int32_t)0x0020));
     438    // S_socket->sendToServer(QString((uint32_t)0x0020));
    437439
    438440    // LOG_TRACE(this->name_ +" configured.");
Note: See TracChangeset for help on using the changeset viewer.