Changeset 94 in pacpussensors for trunk/CanGateway
- Timestamp:
- Sep 28, 2015, 10:49:02 PM (9 years ago)
- Location:
- trunk/CanGateway
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CanGateway/CMakeLists.txt
r89 r94 102 102 # Call MOC 103 103 # ======================================== 104 qt 4_wrap_cpp(104 qt_wrap_cpp( 105 105 PROJECT_MOC_SRCS 106 106 ${FILES_TO_MOC} 107 107 ) 108 108 109 qt 4_wrap_ui(109 qt_wrap_ui( 110 110 PROJECT_UI_SRCS 111 111 ${UI_FILES} … … 140 140 # add your specific libraries to link here 141 141 # pcan 142 canlib 142 143 ) 143 144 endif(UNIX) -
trunk/CanGateway/Win32CanInterface.cpp
r89 r94 14 14 #include "Win32CanInterface.h" 15 15 16 #include "Pacpus/PacpusTools/ShMem.h" 16 // #include "Pacpus/PacpusTools/ShMem.h" // runtime crash because PosixShMem 17 17 18 18 namespace pacpus { … … 104 104 vectorLoop(); 105 105 break; 106 case SharedMemory:107 shMemLoop();108 break;106 // case SharedMemory: // runtime crash because PosixShMem 107 // shMemLoop(); 108 // break; 109 109 case PeakCard: 110 110 peakLoop(); … … 181 181 /* The loop used for waiting CAN data from a shared memory 182 182 /************************************************************************/ 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 memory189 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_) 201 201 202 delete shMem_;203 }202 // delete shMem_; 203 // } 204 204 205 205 /************************************************************************/ -
trunk/CanGateway/Win32CanInterface.h
r89 r94 22 22 # define CAN_DRIVER_TYPE KVASER_CAN_DRIVER_WIN 23 23 #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 25 26 #endif 26 27 … … 36 37 namespace pacpus { 37 38 38 class ShMem; 39 // class ShMem; // runtime crash because PosixShMem 39 40 40 41 class Win32CanInterface … … 59 60 void run(); 60 61 void vectorLoop(); 61 void shMemLoop();62 //void shMemLoop(); // runtime crash because PosixShMem 62 63 void peakLoop(); 63 64 void igepLoop(); … … 75 76 int receivedFramesArraySize_; 76 77 77 ShMem * shMem_;78 // ShMem * shMem_; // runtime crash because PosixShMem 78 79 79 80 int counter_; -
trunk/CanGateway/driver/KVaserCanDriver.cpp
r91 r94 4 4 5 5 #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 8 11 #include <cassert> 9 12 #include <cstdio> … … 11 14 #include <iostream> 12 15 #include <string> 16 #include <string.h> 13 17 14 18 #include "Pacpus/kernel/Log.h" … … 46 50 buf[0] = '\0'; 47 51 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 << ")"); 49 53 //exit(1); 50 54 } … … 175 179 short KVaserCanDriver::initPort (void) 176 180 { 177 // 181 #ifdef WIN32 178 182 // Initialize CANLIB. 179 183 // 180 184 canInitializeLibrary(); 181 185 #endif 186 182 187 // open the physical CAN interface 183 188 initialize(kvaserHardwareType_, canChannel_, canBitRate_); … … 229 234 unsigned int dlc, flags; 230 235 unsigned char msg[8]; 231 DWORD time; 236 //DWORD timestamp; 237 unsigned long timestamp; 232 238 233 canStatus stat = canReadWait(canHandle_, &id, msg, &dlc, &flags, &time , WAIT_RECEIVING_FRAME_TIMEOUT);239 canStatus stat = canReadWait(canHandle_, &id, msg, &dlc, &flags, ×tamp, WAIT_RECEIVING_FRAME_TIMEOUT); 234 240 if (stat == canOK ) 235 241 {
Note:
See TracChangeset
for help on using the changeset viewer.