- Timestamp:
- Jul 28, 2015, 3:28:21 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 19 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CMakeLists.txt
r81 r89 84 84 # ======================================== 85 85 # add_subdirectory(Alasca) 86 #add_subdirectory(CanGateway)86 add_subdirectory(CanGateway) 87 87 # add_subdirectory(PtGreyCameras) 88 88 # add_subdirectory(Dualshock) … … 97 97 # add_subdirectory(NMEA0183) 98 98 # add_subdirectory(OpencvVideo) 99 add_subdirectory(Ladybug)99 # add_subdirectory(Ladybug) 100 100 101 101 # ======================================== -
trunk/CanGateway/CMakeLists.txt
r59 r89 37 37 ${PACPUS_LIB_DIR} 38 38 ${CanGateway_SOURCE_DIR}/driver/libs 39 ${CanGateway_SOURCE_DIR}/driver/libs/kvaser/MS 39 40 ) 40 41 … … 59 60 DbtRawCanReader.cpp 60 61 structureCan.h 62 driver/KVaserCanDriver.cpp 63 driver/KVaserCanDriver.h 61 64 ${PLUGIN_CPP} 62 65 ) … … 129 132 optimized vxlapi.lib debug vxlapi.lib 130 133 optimized PCANBasic.lib debug PCANBasic.lib 134 optimized canlib32.lib debug canlib32.lib 131 135 ) 132 136 endif(WIN32) -
trunk/CanGateway/Win32CanInterface.cpp
r41 r89 4 4 // 5 5 // author: Gerald Dherbomez 6 // Copyright Heudiasyc UMR UTC/CNRS 65996 // Copyright Heudiasyc UMR UTC/CNRS 7253 7 7 // 8 8 // version: $Id: $ 9 9 // 10 // purpose: Windows specific management of the Can Interface10 // purpose: Management of the Can Interface 11 11 // 12 12 *********************************************************************/ … … 115 115 case XLVectorCard: 116 116 vectorXlLoop(); 117 case KvaserCard: 118 kvaserLoop(); 117 119 break; 118 120 default: … … 145 147 /// The loop used for waiting CAN data from XL Vector card 146 148 void Win32CanInterface::vectorXlLoop() 149 { 150 while(continue_) { 151 // Wait incoming data from the CAN bus 152 if (canDriver_->receiveFrame(frame_) == 0) { 153 receivedFrames_[counter_].time = road_time(); 154 receivedFrames_[counter_].timerange = 0; 155 memcpy(&(receivedFrames_[counter_].frame), &frame_, sizeof(CanFrame)); 156 semaphore_->release(); 157 counter_++; 158 counter_ = counter_ % receivedFramesArraySize_; 159 } 160 } 161 } 162 163 /************************************************************************/ 164 /// The loop used for waiting CAN data from Kvaser card 165 void Win32CanInterface::kvaserLoop() 147 166 { 148 167 while(continue_) { -
trunk/CanGateway/Win32CanInterface.h
r74 r89 18 18 #ifdef WIN32 19 19 //# define CAN_DRIVER_TYPE VECTOR_CAN_DRIVER 20 # define CAN_DRIVER_TYPE VECTOR_CANXL_DRIVER20 //# define CAN_DRIVER_TYPE VECTOR_CANXL_DRIVER 21 21 //# define CAN_DRIVER_TYPE PEAK_CAN_DRIVER_WIN 22 # define CAN_DRIVER_TYPE KVASER_CAN_DRIVER_WIN 22 23 #else 23 24 # define CAN_DRIVER_TYPE IGEP_CAN_DRIVER … … 44 45 ~Win32CanInterface(); 45 46 46 enum DataSource {VectorCard, SharedMemory, PeakCard, XLVectorCard, igepCard };47 enum DataSource {VectorCard, SharedMemory, PeakCard, XLVectorCard, igepCard, KvaserCard}; 47 48 48 49 bool openInterface(const int number, const unsigned int speed); … … 62 63 void igepLoop(); 63 64 void vectorXlLoop(); 65 void kvaserLoop(); 66 64 67 65 68 private: -
trunk/CanGateway/driver/CanDriver.h
r86 r89 26 26 #define PEAK_CAN_DRIVER_WIN 6 27 27 #define SOFTING_CAN_DRIVER 7 28 #define KVASER_CAN_DRIVER_WIN 8 28 29 29 30 … … 49 50 #include "SoftingCanDriver.h" 50 51 #define CanDriverType SoftingCanDriver 52 #elif CAN_DRIVER_TYPE == KVASER_CAN_DRIVER_WIN 53 #include "KVaserCanDriver.h" 54 #define CanDriverType KVaserCanDriver 51 55 #else 52 56 #define CanDriverType CanDriverUnknown -
trunk/CanGateway/driver/XLVectorCanDriver.cpp
r40 r89 412 412 xlCanTransmit(this->port, this->accessMask, &count, &e)); 413 413 414 /* 415 Vstatus vErr; 416 Vevent event; 417 Vevent * pEvent = NULL; 418 419 // Create frame to send 420 event.tag = V_TRANSMIT_MSG; 421 event.tagData.msg.id = frame.id; 422 event.tagData.msg.flags = 0; 423 event.tagData.msg.dlc = frame.dlc; 424 425 for (int i = 0; i < frame.dlc; i++) 426 event.tagData.msg.data[i] = frame.data[i]; 427 428 // Send the frame 429 vErr = ncdTransmit (gPortHandle, gChannelMask, &event); 430 431 //printf("sendFrame ncdTransmit -- vErr=%d, event=0x%x\n", vErr, event); 432 433 if (vErr==VERR_QUEUE_IS_FULL) 434 { 435 printf("!"); 436 } 437 438 else if (vErr) 439 { 440 printf ("ERROR:(send frame) %s!\n", ncdGetErrorString (vErr)); 441 // ncdDeactivateChannel (gPortHandle, gChannelMask); 442 // cleanUpPort (); 443 return vErr; 444 } 445 446 return VSUCCESS; 447 448 // Wait the acknowledgement frame 449 waitReceivingFrame(); 450 451 // Read the acknowledgement frame in the buffer 452 vErr = ncdReceive1 (gPortHandle,&pEvent); 453 //printf("sendFrame ncdReceive1 -- vErr=%d, pEvent=0x%x\n", vErr, pEvent); 454 455 if ( (pEvent==NULL) && (vErr==VERR_QUEUE_IS_EMPTY) ) 456 { 457 printf ("%s\n",ncdGetErrorString (vErr)); 458 printf ("%s!\n",ncdGetErrorString (vErr)); 459 // ncdDeactivateChannel (gPortHandle, gChannelMask); 460 // cleanUpPort (); 461 return vErr; 462 } 463 464 // If frame is well acknoledged 465 if (pEvent->tagData.msg.flags & 0x40) 466 return VSUCCESS; 467 else 468 { 469 //printf("%x ",pEvent->tagData.msg.flags); 470 //printf (" no acknolegement of frame!\n"); 471 472 return VERROR; 473 }*/ 414 474 415 475 416 return 1; … … 497 438 498 439 int queueSize; 499 //bool found = false; 500 //DWORD begin = timeGetTime(); 501 //while ( !found ) { 502 /*DWORD now = timeGetTime(); 503 /DEBUG("begin: %ld, now: %ld", begin, now); 504 if ( now - begin >= timeout ) { 505 return NULL; 506 } 507 */ 440 508 441 traceXLCommand("xlGetReceiveQueueLevel", 509 442 xlGetReceiveQueueLevel(this->port, &queueSize)); … … 526 459 return 1; 527 460 } 528 //} 529 530 //return new CanMessage(e); 531 532 533 /* 534 int L ; 535 Vstatus vErr; 536 Vevent * pEvent = NULL; 537 538 do { 539 // Read frame in the buffer 540 ncdGetReceiveQueueLevel( gPortHandle , &L ); 541 if( L <= 0 ) 542 { 543 if (WaitForSingleObject (gEventHandle,WAIT_RECEIVING_FRAME_TIMEOUT) == WAIT_TIMEOUT) 544 { 545 //printf("no frame receiving in the %d last seconds\n", WAIT_RECEIVING_FRAME_TIMEOUT/1000); 546 return VERR_QUEUE_IS_EMPTY; 547 } 548 } 549 550 vErr = ncdReceive1 (gPortHandle,&pEvent); 551 if( vErr == VERROR ) 552 { 553 printf ("receiveframe ERROR - ERROR: %s\n", ncdGetErrorString (vErr)); 554 // ncdDeactivateChannel (gPortHandle, gChannelMask); 555 // cleanUpPort (); 556 557 return vErr; 558 } 559 560 } while((( pEvent==NULL ) && ( vErr==VERR_QUEUE_IS_EMPTY )) || ( vErr == VERROR )); 561 562 // Return the flags field, dlc field and data field of the sent frame 563 //frame.flags = pEvent->tagData.msg.flags; 564 frame.dlc = pEvent->tagData.msg.dlc; 565 frame.id = pEvent->tagData.msg.id; 566 if( ( frame.dlc > 8 ) || ( frame.dlc < 0 )) 567 frame.dlc = 8; 568 569 memcpy(frame.data,pEvent->tagData.msg.data, frame.dlc); 570 571 return VSUCCESS;*/ 461 572 462 573 463 } -
trunk/build/build.bat
r29 r89 1 cmake ..1 cmake -G "Visual Studio 10" .. 2 2 pause
Note:
See TracChangeset
for help on using the changeset viewer.