Changeset 94 in pacpussensors for trunk


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.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/CMakeLists.txt

    r89 r94  
    6262# Find dependencies
    6363# ========================================
    64 find_package(Qt4 REQUIRED)
    65 if(QT4_FOUND)
    66     set(QT_USE_QTNETWORK TRUE)
    67     set(QT_USE_QTOPENGL TRUE)
    68     set(QT_USE_QTXML TRUE)
    69     include(${QT_USE_FILE})
    70     add_definitions( ${QT_DEFINITIONS} )
    71     add_definitions( -DQT_PLUGIN )
    72 endif(QT4_FOUND)
     64#find_package(Qt4 REQUIRED)
     65#if(QT4_FOUND)
     66#    set(QT_USE_QTNETWORK TRUE)
     67#    set(QT_USE_QTOPENGL TRUE)
     68 #   set(QT_USE_QTXML TRUE)
     69 #   include(${QT_USE_FILE})
     70 #   add_definitions( ${QT_DEFINITIONS} )
     71 #   add_definitions( -DQT_PLUGIN )
     72#endif(QT4_FOUND)
    7373
    74 include_directories(
    75   ${PACPUS_DEPENDENCIES_INC}
    76   ${PACPUS_INCLUDE_DIR}
    77   ${PACPUS_INCLUDE_HINT}
    78   ${PACPUS_INCLUDE_HINT}/Pacpus
    79   ./PACPUS/include
    80 )
     74#include_directories(
     75#  ${PACPUS_DEPENDENCIES_INC}
     76#  ${PACPUS_INCLUDE_DIR}
     77#  ${PACPUS_INCLUDE_HINT}
     78#  ${PACPUS_INCLUDE_HINT}/Pacpus
     79#  ./PACPUS/include
     80#)
     81
    8182
    8283# ========================================
     
    9192# add_subdirectory(StereoVisionDisparity)
    9293# add_subdirectory(SensorsApplication)
    93 # add_subdirectory(StdDbtPlayerComponents)
     94add_subdirectory(StdDbtPlayerComponents)
    9495# add_subdirectory(Wifibot)
    9596# add_subdirectory(Gps)
     
    133134    message(WARNING "The source directory is the same as build directory. \"make clean\" may damage the source tree")
    134135endif()
     136
  • trunk/CanGateway/CMakeLists.txt

    r89 r94  
    102102# Call MOC
    103103# ========================================
    104 qt4_wrap_cpp(
     104qt_wrap_cpp(
    105105    PROJECT_MOC_SRCS
    106106    ${FILES_TO_MOC}
    107107)
    108108
    109 qt4_wrap_ui(
     109qt_wrap_ui(
    110110    PROJECT_UI_SRCS
    111111    ${UI_FILES}
     
    140140        # add your specific libraries to link here
    141141        # pcan
     142        canlib
    142143    )
    143144endif(UNIX)
  • trunk/CanGateway/Win32CanInterface.cpp

    r89 r94  
    1414#include "Win32CanInterface.h"
    1515
    16 #include "Pacpus/PacpusTools/ShMem.h"
     16// #include "Pacpus/PacpusTools/ShMem.h" // runtime crash because PosixShMem
    1717
    1818namespace pacpus {
     
    104104    vectorLoop();
    105105    break;
    106   case SharedMemory:
    107     shMemLoop();
    108     break;
     106  // case SharedMemory:  // runtime crash because PosixShMem
     107  //   shMemLoop();
     108  //   break;
    109109  case PeakCard:
    110110    peakLoop();
     
    181181/* The loop used for waiting CAN data from a shared memory
    182182/************************************************************************/
    183 void Win32CanInterface::shMemLoop()
    184 {
    185   shMem_ = new ShMem("CARMEN_CAN_2200", sizeof(TimestampedCanFrame));
    186   while (continue_)
    187   {
    188     // Wait incoming data from the shared memory
    189     if ( shMem_->wait(100) )
    190     {
    191       TimestampedCanFrame* ptr = (TimestampedCanFrame*)(shMem_->read());
    192       memcpy(&frame_, &(ptr->frame), sizeof(CanFrame));
    193       receivedFrames_[counter_].time = ptr->time;
    194       receivedFrames_[counter_].timerange = ptr->timerange;
    195       memcpy(&(receivedFrames_[counter_].frame), &frame_, sizeof(CanFrame) );
    196       semaphore_->release();
    197       counter_++;
    198       counter_ = counter_ % receivedFramesArraySize_;
    199     }
    200   } // END while (continue_)
     183// void Win32CanInterface::shMemLoop()  // runtime crash because PosixShMem
     184// {
     185//   shMem_ = new ShMem("CARMEN_CAN_2200", sizeof(TimestampedCanFrame));
     186//   while (continue_)
     187//   {
     188//     // Wait incoming data from the shared memory
     189//     if ( shMem_->wait(100) )
     190//     {
     191//       TimestampedCanFrame* ptr = (TimestampedCanFrame*)(shMem_->read());
     192//       memcpy(&frame_, &(ptr->frame), sizeof(CanFrame));
     193//       receivedFrames_[counter_].time = ptr->time;
     194//       receivedFrames_[counter_].timerange = ptr->timerange;
     195//       memcpy(&(receivedFrames_[counter_].frame), &frame_, sizeof(CanFrame) );
     196//       semaphore_->release();
     197//       counter_++;
     198//       counter_ = counter_ % receivedFramesArraySize_;
     199//     }
     200//   } // END while (continue_)
    201201 
    202   delete shMem_;
    203 }
     202//   delete shMem_;
     203// }
    204204
    205205/************************************************************************/
  • trunk/CanGateway/Win32CanInterface.h

    r89 r94  
    2222#   define CAN_DRIVER_TYPE         KVASER_CAN_DRIVER_WIN
    2323#else
    24 #   define CAN_DRIVER_TYPE       IGEP_CAN_DRIVER
     24//#   define CAN_DRIVER_TYPE       IGEP_CAN_DRIVER
     25#   define CAN_DRIVER_TYPE         KVASER_CAN_DRIVER_WIN
    2526#endif
    2627
     
    3637namespace pacpus {
    3738
    38 class ShMem;
     39// class ShMem; // runtime crash because PosixShMem
    3940
    4041class Win32CanInterface
     
    5960  void run();
    6061  void vectorLoop();
    61   void shMemLoop();
     62  //void shMemLoop(); // runtime crash because PosixShMem
    6263  void peakLoop();
    6364  void igepLoop();
     
    7576  int receivedFramesArraySize_;
    7677
    77   ShMem * shMem_;
     78  // ShMem * shMem_; // runtime crash because PosixShMem
    7879
    7980  int counter_;
  • 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        {
  • trunk/StdDbtPlayerComponents/CMakeLists.txt

    r74 r94  
    5858# Call MOC
    5959# ========================================
    60 qt4_wrap_cpp(
     60qt_wrap_cpp(
    6161    PROJECT_MOC_SRCS
    6262    ${FILES_TO_MOC}
    6363)
    6464
    65 qt4_wrap_ui(
     65qt_wrap_ui(
    6666    PROJECT_UI_SRCS
    6767    ${UI_FILES}
Note: See TracChangeset for help on using the changeset viewer.