Changeset 89 in pacpussensors for trunk/CanGateway/driver/XLVectorCanDriver.cpp


Ignore:
Timestamp:
Jul 28, 2015, 3:28:21 PM (9 years ago)
Author:
DHERBOMEZ Gérald
Message:

Add KVASER CAN driver support for CanGateway component. Tested only for Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CanGateway/driver/XLVectorCanDriver.cpp

    r40 r89  
    412412                xlCanTransmit(this->port, this->accessMask, &count, &e));
    413413
    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       
    474415
    475416        return 1;
     
    497438
    498439        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
    508441                traceXLCommand("xlGetReceiveQueueLevel",
    509442                        xlGetReceiveQueueLevel(this->port, &queueSize));
     
    526459                        return 1;
    527460                }
    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       
    572462       
    573463}
Note: See TracChangeset for help on using the changeset viewer.