00001 /**************************************************************** 00002 * 00003 * Copyright (c) 2012 00004 * 00005 * Fraunhofer Institute for Manufacturing Engineering 00006 * and Automation (IPA) 00007 * 00008 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: CIN-Reha 00011 * ROS stack name: cob_drivers 00012 * ROS package name: cob_generic_can 00013 * Description: 00014 * 00015 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 * 00017 * Author: 00018 * Supervised by: 00019 * 00020 * Date of creation: Jan 2012 00021 * 00022 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00023 * 00024 * Redistribution and use in source and binary forms, with or without 00025 * modification, are permitted provided that the following conditions are met: 00026 * 00027 * * Redistributions of source code must retain the above copyright 00028 * notice, this list of conditions and the following disclaimer. 00029 * * Redistributions in binary form must reproduce the above copyright 00030 * notice, this list of conditions and the following disclaimer in the 00031 * documentation and/or other materials provided with the distribution. 00032 * * Neither the name of the Fraunhofer Institute for Manufacturing 00033 * Engineering and Automation (IPA) nor the names of its 00034 * contributors may be used to endorse or promote products derived from 00035 * this software without specific prior written permission. 00036 * 00037 * This program is free software: you can redistribute it and/or modify 00038 * it under the terms of the GNU Lesser General Public License LGPL as 00039 * published by the Free Software Foundation, either version 3 of the 00040 * License, or (at your option) any later version. 00041 * 00042 * This program is distributed in the hope that it will be useful, 00043 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00044 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00045 * GNU Lesser General Public License LGPL for more details. 00046 * 00047 * You should have received a copy of the GNU Lesser General Public 00048 * License LGPL along with this program. 00049 * If not, see <http://www.gnu.org/licenses/>. 00050 * 00051 ****************************************************************/ 00052 00053 #ifndef CANOpenMaster_INCLUDEDEF_H 00054 #define CANOpenMaster_INCLUDEDEF_H 00055 //----------------------------------------------- 00056 00057 // std includes 00058 #include <pthread.h> 00059 #include <queue> 00060 00061 // ros includes 00062 #include <cob_utilities/Mutex.h> 00063 #include <cob_generic_can/CanItf.h> 00064 #include <cob_generic_can/CanPeakSysUSB.h> 00065 00066 // own includes 00067 //#include <CANOpen_driver.h> 00068 #include <CANOpen_buffer.h> 00069 #include <CANOpenCiA401_Schunk.h> 00070 00071 00072 // TODO make this variable, attention to CANOpen_buffer! 00073 #define MAX_PDOS 32 //8 nodes with 4 PDOs 00074 #define MAX_InBuffer_Lenght 32 00075 00076 CANOpenCiA401_Schunk CANObj; 00077 CANOpen_buffer* PDO_buffer; 00078 CANPeakSysUSB* can_itf; 00079 std::queue<CanMsg> InBuffer; 00080 00081 00082 // as API to use 00083 void InitMaster(); 00084 void StartMasterThread(double); 00085 void AcitvatePDO(int, int, double); 00086 void AssignValue2PDO(int, char*); 00087 int GetRecievedMsgs(CanMsg* ); 00088 00089 /*=============================================*/ 00090 //protected 00091 00092 struct Thread_data 00093 { 00094 double Cycle_Freq_HZ; 00095 }TD_Master; 00096 00097 void *MasterThreadFunc(void*); 00098 void *EvaluateBuffers(void*); 00099 void SendSYNC(); 00100 00101 00102 #endif //CANOpenMaster_INCLUDEDEF_H