Changeset 94 in pacpussensors for trunk/CanGateway/driver/KVaserCanDriver.cpp


Ignore:
Timestamp:
Sep 28, 2015, 10:49:02 PM (9 years ago)
Author:
DHERBOMEZ Gérald
Message:

kvaser CAN driver testing on Linux. Works fine.
TODO: test back the code on Windows.

File:
1 edited

Legend:

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

    r91 r94  
    44
    55#include "KVaserCanDriver.h"
    6 #include "kvaser/canlib.h"
    7 
     6#ifdef WIN32
     7#include "kvaser/windows/canlib.h"
     8#else
     9#include "kvaser/linux/canlib.h"
     10#endif
    811#include <cassert>
    912#include <cstdio>
     
    1114#include <iostream>
    1215#include <string>
     16#include <string.h>
    1317
    1418#include "Pacpus/kernel/Log.h"
     
    4650        buf[0] = '\0';
    4751        canGetErrorText(stat, buf, sizeof(buf));
    48         LOG_ERROR("%s: failed, stat=%d (%s)\n", id, (int)stat, buf);
     52        LOG_ERROR(id << ": failed, stat=" << (int)stat << " (" << buf << ")");
    4953        //exit(1);
    5054    }
     
    175179short KVaserCanDriver::initPort (void)
    176180{
    177         //
     181#ifdef WIN32
    178182    // Initialize CANLIB.
    179183    //
    180184    canInitializeLibrary();
    181 
     185#endif
     186   
    182187        // open the physical CAN interface
    183188        initialize(kvaserHardwareType_, canChannel_, canBitRate_);
     
    229234        unsigned int dlc, flags;
    230235        unsigned char msg[8];
    231         DWORD time;
     236        //DWORD timestamp;
     237        unsigned long timestamp;
    232238       
    233         canStatus stat = canReadWait(canHandle_, &id, msg, &dlc, &flags, &time, WAIT_RECEIVING_FRAME_TIMEOUT);
     239        canStatus stat = canReadWait(canHandle_, &id, msg, &dlc, &flags, &timestamp, WAIT_RECEIVING_FRAME_TIMEOUT);
    234240        if (stat == canOK )
    235241        {
Note: See TracChangeset for help on using the changeset viewer.