- Timestamp:
- Jun 16, 2014, 4:04:34 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Sick/SickComponent.h
r42 r52 49 49 */ 50 50 class SICK_API SickComponent 51 : public QThread 52 , public ComponentBase 51 : /*public QThread 52 , */ 53 public QObject, public ComponentBase 53 54 { 54 55 Q_OBJECT … … 61 62 ~SickComponent(); 62 63 63 void run() {}64 // void run() {} 64 65 65 66 virtual void stopActivity(); /*!< To stop the processing thread */ -
trunk/Sick/SickLDMRSData.h
r43 r52 54 54 u_int64_t ntpTime; //!< Time of the sensor when the message is created 55 55 }; 56 56 57 57 58 /*! 58 59 * \brief The ScanHeader struct -
trunk/Sick/SickLDMRSSensor.cpp
r42 r52 320 320 } 321 321 322 LOG_TRACE("(Packet reconstitution) Message complete ! "); 322 323 // we have a complete message available that we can add to the list 323 324 MessageLDMRS msg; 324 325 325 326 // we copy the bytes in the body message 326 char* messageData = (char*)malloc(msgSize); 327 memcpy(messageData, pendingBytes.data.c_str() + index, msgSize); 328 329 msg.body = messageData; 327 // char* messageData = (char*)malloc(msgSize); 328 // if(messageData == NULL){ 329 // LOG_FATAL("(Packet reconstitution) Malloc FAILED. Packet lost."); 330 // return; 331 // } 332 memcpy(msg.body, pendingBytes.data.c_str() + index, msgSize); 333 334 // msg->body = messageData; 330 335 331 336 // we set the timestamp of the message … … 358 363 359 364 int index = 24 + 44; // data header + scan header 360 ScanPoint* scanPoints = (ScanPoint*) malloc(sizeof(ScanPoint) * msg.hScan.numPoints); 361 int position = 0; 362 365 366 if(sizeof(ScanPoint) * msg.hScan.numPoints > BODY_MAX_SIZE){ 367 LOG_FATAL("Size of the message is too long !"); 368 return 0; 369 } 370 371 ScanPoint scanPoints[msg.hScan.numPoints]; 372 373 // replace memory with structured data 363 374 for (int i = 0; i < msg.hScan.numPoints; ++i) { 364 ((ScanPoint*)(scanPoints + position))->layerEcho = *((uchar*)(msg.body + index)); 365 ((ScanPoint*)(scanPoints + position))->flags = *((uchar*)(msg.body + index + 1)); 366 ((ScanPoint*)(scanPoints + position))->angle = *((u_int16_t*)(msg.body + index + 2)); 367 ((ScanPoint*)(scanPoints + position))->distance = *((u_int16_t*)(msg.body + index + 4)); 368 ((ScanPoint*)(scanPoints + position))->echoPulseWidth = *((u_int16_t*)(msg.body + index + 6)); 369 index += 10; 370 position += sizeof(ScanPoint); 371 } 372 373 // raw data (message) no longer needed, free memory and replace with structured data 374 free(msg.body); 375 msg.body = (char*) scanPoints; 375 scanPoints[i].layerEcho = *((uchar*)(msg.body + index)); 376 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)); 380 } 381 382 memcpy(msg.body, scanPoints, sizeof(ScanPoint) * msg.hScan.numPoints); 376 383 } 377 384 else if (msg.hData.dataType == SICKLDMRS_OBJECTDATA_TYPE){ 378 385 LOG_TRACE("(Process Message) Object Data Type!"); 379 386 380 381 382 387 // TODO 383 384 // raw message no longer needed, free memory 385 free(msg.body); 386 // msg.body = (char*) scanObjects; 387 } 388 else // irrelevant data type 389 free(msg.body); // free raw data 388 } 389 else {// irrelevant data type 390 // TODO 391 } 392 390 393 391 394 return msg.hData.dataType; … … 405 408 // entry.timerange = msg.timerange; 406 409 410 LOG_TRACE("Writing into DBT + UTC files.."); 411 407 412 // write DBT 408 413 try { … … 421 426 dataFile_.write(reinterpret_cast<char*>(&(utcMagicWord)), sizeof(int32_t)); 422 427 428 LOG_TRACE("Writing done !"); 429 423 430 } 424 431 … … 446 453 while ( !msgList.empty() ) 447 454 { 455 LOG_TRACE("Message waiting"); 448 456 // get the first (the eldest) message and process it 449 457 MessageLDMRS msgToProcess = msgList.front(); 450 458 unsigned long type = processMessage(msgToProcess); 459 LOG_TRACE("Message processed !"); 451 460 452 461 if (type == SICKLDMRS_SCANDATA_TYPE) … … 480 489 481 490 // removes the processed item of the list 491 // free(msgList.front().body); 482 492 msgList.pop_front(); 483 493 } -
trunk/Sick/SickLDMRSSensor.h
r42 r52 25 25 #include <fstream> 26 26 #include <string> 27 28 #define BODY_MAX_SIZE 10000 27 29 28 30 // Export macro for SickLDMRS DLL for Windows only … … 79 81 //! An array of characters : raw data then array of points or objects, depending on data type. 80 82 /** 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. */ 81 char * body;83 char body[BODY_MAX_SIZE]; 82 84 83 85 //! Time when the message is received. -
trunk/StdDbtPlayerComponents/CMakeLists.txt
r50 r52 21 21 22 22 set(HDRS 23 DbtPlyImageManager.h24 DbtPlyStereoManager.h25 ImageViewer.h26 23 StdDbtPlayerComponentsConfig.h 27 24 # DbtPlySickLMSManager.h … … 35 32 set( 36 33 PROJECT_SRCS 37 DbtPlyImageManager.cpp38 DbtPlyStereoManager.cpp39 34 # DbtPlySickLMSManager.cpp 40 35 # DbtPlySickLDMRSManager.cpp 41 ImageViewer.cpp42 36 ${HDRS} 43 37 ${PLUGIN_CPP} … … 49 43 set( 50 44 FILES_TO_MOC 51 DbtPlyImageManager.h52 DbtPlyStereoManager.h53 45 DbtPlySickLMSManager.h 54 46 DbtPlySickLDMRSManager.h 55 ImageViewer.h56 47 ${PLUGIN_H} 57 48 )
Note:
See TracChangeset
for help on using the changeset viewer.