# HG changeset patch # User nico # Date 1181287436 -7200 # Node ID f49e5a6b7804a9ad5316bea70d33345b76fb0dcd # Parent 003cc3c6385571459daa7c4f9988bfa06b9e27aa Manual and Documentation finish diff -r 003cc3c63855 -r f49e5a6b7804 doc/doxygen/html/Master_8c-source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/doxygen/html/Master_8c-source.html Fri Jun 08 09:23:56 2007 +0200 @@ -0,0 +1,252 @@ + +
+00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #include "Master.h" +00024 #include "Slave.h" +00025 #include "TestMasterSlave.h" +00026 +00027 /*****************************************************************************/ +00028 void TestMaster_heartbeatError(UNS8 heartbeatID) +00029 { +00030 eprintf("TestMaster_heartbeatError %d\n", heartbeatID); +00031 } +00032 +00033 /******************************************************** +00034 * ConfigureSlaveNode is responsible to +00035 * - setup master RPDO 1 to receive TPDO 1 from id 2 +00036 * - setup master RPDO 2 to receive TPDO 2 from id 2 +00037 ********************************************************/ +00038 void TestMaster_initialisation() +00039 { +00040 UNS32 PDO1_COBID = 0x0182; +00041 UNS32 PDO2_COBID = 0x0282; +00042 UNS8 size = sizeof(UNS32); +00043 +00044 eprintf("TestMaster_initialisation\n"); +00045 +00046 /***************************************** +00047 * Define RPDOs to match slave ID=2 TPDOs* +00048 *****************************************/ +00049 writeLocalDict( &TestMaster_Data, /*CO_Data* d*/ +00050 0x1400, /*UNS16 index*/ +00051 0x01, /*UNS8 subind*/ +00052 &PDO1_COBID, /*void * pSourceData,*/ +00053 &size, /* UNS8 * pExpectedSize*/ +00054 RW); /* UNS8 checkAccess */ +00055 +00056 writeLocalDict( &TestMaster_Data, /*CO_Data* d*/ +00057 0x1401, /*UNS16 index*/ +00058 0x01, /*UNS8 subind*/ +00059 &PDO2_COBID, /*void * pSourceData,*/ +00060 &size, /* UNS8 * pExpectedSize*/ +00061 RW); /* UNS8 checkAccess */ +00062 } +00063 +00064 // Step counts number of times ConfigureSlaveNode is called +00065 static init_step = 0; +00066 +00067 /*Froward declaration*/ +00068 static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId); +00069 +00070 +00071 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId) +00072 { +00073 UNS32 abortCode; +00074 if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED) +00075 eprintf("Master : Failed in initializing slave %2.2x, step %d, AbortCode :%4.4x \n", nodeId, init_step, abortCode); +00076 +00077 /* Finalise last SDO transfer with this node */ +00078 closeSDOtransfer(&TestMaster_Data, nodeId, SDO_CLIENT); +00079 +00080 ConfigureSlaveNode(d, nodeId); +00081 } +00082 +00083 /******************************************************** +00084 * ConfigureSlaveNode is responsible to +00085 * - setup slave TPDO 1 transmit time +00086 * - setup slave TPDO 2 transmit time +00087 * - switch to operational mode +00088 * - send NMT to slave +00089 ******************************************************** +00090 * This an example of : +00091 * Network Dictionary Access (SDO) with Callback +00092 * Slave node state change request (NMT) +00093 ******************************************************** +00094 * This is called first by TestMaster_preOperational +00095 * then it called again each time a SDO exchange is +00096 * finished. +00097 ********************************************************/ +00098 +00099 static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId) +00100 { +00101 /* Master configure heartbeat producer time at 1000 ms +00102 * for slave node-id 0x02 by DCF concise */ +00103 +00104 UNS8 Transmission_Type = 0x01; +00105 UNS32 abortCode; +00106 UNS8 res; +00107 eprintf("Master : ConfigureSlaveNode %2.2x\n", nodeId); +00108 +00109 switch(++init_step){ +00110 case 1: /*First step : setup Slave's TPDO 1 to be transmitted on SYNC*/ +00111 eprintf("Master : set slave %2.2x TPDO 1 transmit type\n", nodeId); +00112 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00113 nodeId, /*UNS8 nodeId*/ +00114 0x1800, /*UNS16 index*/ +00115 0x02, /*UNS8 subindex*/ +00116 1, /*UNS8 count*/ +00117 0, /*UNS8 dataType*/ +00118 &Transmission_Type,/*void *data*/ +00119 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00120 break; +00121 +00122 case 2: /*Second step*/ +00123 eprintf("Master : set slave %2.2x TPDO 2 transmit type\n", nodeId); +00124 writeNetworkDictCallBack (d, /*CO_Data* d*/ +00125 nodeId, /*UNS8 nodeId*/ +00126 0x1801, /*UNS16 index*/ +00127 0x02, /*UNS16 index*/ +00128 1, /*UNS8 count*/ +00129 0, /*UNS8 dataType*/ +00130 &Transmission_Type,/*void *data*/ +00131 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00132 break; +00133 case 3: +00134 +00135 /****************************** START *******************************/ +00136 +00137 /* Put the master in operational mode */ +00138 setState(d, Operational); +00139 +00140 /* Ask slave node to go in operational mode */ +00141 masterSendNMTstateChange (d, nodeId, NMT_Start_Node); +00142 +00143 } +00144 } +00145 +00146 void TestMaster_preOperational() +00147 { +00148 +00149 eprintf("TestMaster_preOperational\n"); +00150 ConfigureSlaveNode(&TestMaster_Data, 0x02); +00151 +00152 } +00153 +00154 void TestMaster_operational() +00155 { +00156 eprintf("TestMaster_operational\n"); +00157 } +00158 +00159 void TestMaster_stopped() +00160 { +00161 eprintf("TestMaster_stopped\n"); +00162 } +00163 +00164 void TestMaster_post_sync() +00165 { +00166 eprintf("TestMaster_post_sync\n"); +00167 eprintf("Master: %d %d %d %d %d %d %d %d %d %x %x\n",MasterMap1,MasterMap2 ,MasterMap3, MasterMap4,MasterMap5,MasterMap6,MasterMap7,MasterMap8,MasterMap9,MasterMap10,MasterMap11); +00168 } +00169 +00170 char query_result = 0; +00171 char waiting_answer = 0; +00172 +00173 void TestMaster_post_TPDO() +00174 { +00175 eprintf("TestMaster_post_TPDO\n"); +00176 // +00177 // { +00178 // char zero = 0; +00179 // if(MasterMap4 > 0x80){ +00180 // writeNetworkDict ( +00181 // &TestMaster_Data, +00182 // TestSlave_Data->bDeviceNodeId, +00183 // 0x2002, +00184 // 0x00, +00185 // 1, +00186 // 0, +00187 // &zero); +00188 // } +00189 // } +00190 +00191 if(waiting_answer){ +00192 UNS32 abortCode; +00193 UNS8 size; +00194 switch(getReadResultNetworkDict ( +00195 &TestMaster_Data, +00196 0x02, +00197 &query_result, +00198 &size, +00199 &abortCode)) +00200 { +00201 case SDO_FINISHED: +00202 /* Do something with result here !!*/ +00203 eprintf("Got SDO answer (0x2002, 0x00), %d %d\n",query_result,size); +00204 case SDO_ABORTED_RCV: +00205 case SDO_ABORTED_INTERNAL: +00206 case SDO_RESET: +00207 waiting_answer = 0; +00208 closeSDOtransfer( +00209 &TestMaster_Data, +00210 0x02, +00211 SDO_CLIENT); +00212 break; +00213 case SDO_DOWNLOAD_IN_PROGRESS: +00214 case SDO_UPLOAD_IN_PROGRESS: +00215 break; +00216 } +00217 }else if(MasterMap1 % 10 == 0){ +00218 readNetworkDict ( +00219 &TestMaster_Data, +00220 0x02, +00221 0x2002, +00222 0x00, +00223 0); +00224 waiting_answer = 1; +00225 } +00226 } +
#include "Master.h"
#include "Slave.h"
#include "TestMasterSlave.h"
+Include dependency graph for Master.c:
+Go to the source code of this file.
Functions | |
void | TestMaster_heartbeatError (UNS8 heartbeatID) |
void | TestMaster_initialisation () |
void | TestMaster_preOperational () |
void | TestMaster_operational () |
void | TestMaster_stopped () |
void | TestMaster_post_sync () |
void | TestMaster_post_TPDO () |
Variables | |
char | query_result = 0 |
char | waiting_answer = 0 |
void TestMaster_heartbeatError | +( | +UNS8 | +heartbeatID | +) | ++ |
void TestMaster_initialisation | +( | +void | ++ | ) | ++ |
void TestMaster_operational | +( | +void | ++ | ) | ++ |
void TestMaster_post_sync | +( | +void | ++ | ) | ++ |
void TestMaster_post_TPDO | +( | +void | ++ | ) | ++ |
void TestMaster_preOperational | +( | +void | ++ | ) | ++ |
void TestMaster_stopped | +( | +void | ++ | ) | ++ |
+
char query_result = 0 | +
char waiting_answer = 0 | +
+
00001 #include "TestMaster.h" +00002 +00003 void TestMaster_heartbeatError(UNS8); +00004 +00005 UNS8 TestMaster_canSend(Message *); +00006 +00007 void TestMaster_initialisation(void); +00008 void TestMaster_preOperational(void); +00009 void TestMaster_operational(void); +00010 void TestMaster_stopped(void); +00011 +00012 void TestMaster_post_sync(void); +00013 void TestMaster_post_TPDO(void); +
#include "TestMaster.h"
+Include dependency graph for Master.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Functions | |
void | TestMaster_heartbeatError (UNS8) |
UNS8 | TestMaster_canSend (Message *) |
void | TestMaster_initialisation (void) |
void | TestMaster_preOperational (void) |
void | TestMaster_operational (void) |
void | TestMaster_stopped (void) |
void | TestMaster_post_sync (void) |
void | TestMaster_post_TPDO (void) |
UNS8 TestMaster_canSend | +( | +Message * | ++ | ) | ++ |
+ +
void TestMaster_heartbeatError | +( | +UNS8 | ++ | ) | ++ |
void TestMaster_initialisation | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 38 of file Master.c. +
+References eprintf, RW, slavenodeid, TestMaster_Data, UNS32, UNS8, and writeLocalDict(). +
+Here is the call graph for this function:
void TestMaster_operational | +( | +void | ++ | ) | ++ |
void TestMaster_post_sync | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 164 of file Master.c. +
+References DI1, DI2, DI3, DI4, DI5, DI6, DI7, DI8, DO, eprintf, MasterMap1, MasterMap10, MasterMap11, MasterMap2, MasterMap3, MasterMap4, MasterMap5, MasterMap6, MasterMap7, MasterMap8, and MasterMap9. +
void TestMaster_post_TPDO | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 173 of file Master.c. +
+References closeSDOtransfer(), eprintf, getReadResultNetworkDict(), MasterMap1, readNetworkDict(), SDO_ABORTED_INTERNAL, SDO_ABORTED_RCV, SDO_CLIENT, SDO_DOWNLOAD_IN_PROGRESS, SDO_FINISHED, SDO_RESET, SDO_UPLOAD_IN_PROGRESS, TestMaster_Data, UNS32, and UNS8. +
+Here is the call graph for this function:
void TestMaster_preOperational | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 146 of file Master.c. +
+References eprintf, slavenodeid, and TestMaster_Data. +
void TestMaster_stopped | +( | +void | ++ | ) | ++ |
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #include "Slave.h" +00024 #include "Master.h" +00025 #include "TestMasterSlave.h" +00026 +00027 /*****************************************************************************/ +00028 void TestSlave_heartbeatError(UNS8 heartbeatID) +00029 { +00030 eprintf("TestSlave_heartbeatError %d\n", heartbeatID); +00031 } +00032 +00033 void TestSlave_initialisation() +00034 { +00035 eprintf("TestSlave_initialisation\n"); +00036 } +00037 +00038 void TestSlave_preOperational() +00039 { +00040 eprintf("TestSlave_preOperational\n"); +00041 } +00042 +00043 void TestSlave_operational() +00044 { +00045 eprintf("TestSlave_operational\n"); +00046 } +00047 +00048 void TestSlave_stopped() +00049 { +00050 eprintf("TestSlave_stopped\n"); +00051 } +00052 +00053 void TestSlave_post_sync() +00054 { +00055 eprintf("TestSlave_post_sync\n"); +00056 +00057 SlaveMap1=1; +00058 SlaveMap2=1; +00059 SlaveMap3=0; +00060 SlaveMap4=0; +00061 SlaveMap5=1; +00062 SlaveMap6=0; +00063 SlaveMap7=1; +00064 SlaveMap8=0; +00065 SlaveMap9=16; +00066 SlaveMap10 = 0xff00ff00; +00067 SlaveMap11 = 0xabcd; +00068 eprintf("Slave: %d %d %d %d %d %d %d %d %d %x %x\n",SlaveMap1, SlaveMap2, SlaveMap3, SlaveMap4, SlaveMap5, SlaveMap6, SlaveMap7, SlaveMap8, SlaveMap9, SlaveMap10,SlaveMap11); +00069 } +00070 +00071 void TestSlave_post_TPDO() +00072 { +00073 eprintf("TestSlave_post_TPDO\n"); +00074 } +00075 +00076 void TestSlave_storeODSubIndex(UNS16 wIndex, UNS8 bSubindex) +00077 { +00078 /*TODO : +00079 * - call getODEntry for index and subindex, +00080 * - save content to file, database, flash, nvram, ... +00081 * +00082 * To ease flash organisation, index of variable to store +00083 * can be established by scanning d->objdict[d->ObjdictSize] +00084 * for variables to store. +00085 * +00086 * */ +00087 eprintf("TestSlave_storeODSubIndex : %4.4x %2.2x\n", wIndex, bSubindex); +00088 } +
#include "Slave.h"
#include "Master.h"
#include "TestMasterSlave.h"
+Include dependency graph for Slave.c:
+Go to the source code of this file.
Functions | |
void | TestSlave_heartbeatError (UNS8 heartbeatID) |
void | TestSlave_initialisation () |
void | TestSlave_preOperational () |
void | TestSlave_operational () |
void | TestSlave_stopped () |
void | TestSlave_post_sync () |
void | TestSlave_post_TPDO () |
void | TestSlave_storeODSubIndex (UNS16 wIndex, UNS8 bSubindex) |
void TestSlave_heartbeatError | +( | +UNS8 | +heartbeatID | +) | ++ |
void TestSlave_initialisation | +( | +void | ++ | ) | ++ |
void TestSlave_operational | +( | +void | ++ | ) | ++ |
void TestSlave_post_sync | +( | +void | ++ | ) | ++ |
void TestSlave_post_TPDO | +( | +void | ++ | ) | ++ |
void TestSlave_preOperational | +( | +void | ++ | ) | ++ |
void TestSlave_stopped | +( | +void | ++ | ) | ++ |
void TestSlave_storeODSubIndex | +( | +UNS16 | +wIndex, | +|
+ | + | UNS8 | +bSubindex | + |
+ | ) | ++ |
+
00001 #include "TestSlave.h" +00002 +00003 void TestSlave_heartbeatError(UNS8); +00004 +00005 UNS8 TestSlave_canSend(Message *); +00006 +00007 void TestSlave_initialisation(void); +00008 void TestSlave_preOperational(void); +00009 void TestSlave_operational(void); +00010 void TestSlave_stopped(void); +00011 +00012 void TestSlave_post_sync(void); +00013 void TestSlave_post_TPDO(void); +00014 void TestSlave_storeODSubIndex(UNS16 wIndex, UNS8 bSubindex); +
#include "TestSlave.h"
+Include dependency graph for Slave.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Functions | |
void | TestSlave_heartbeatError (UNS8) |
UNS8 | TestSlave_canSend (Message *) |
void | TestSlave_initialisation (void) |
void | TestSlave_preOperational (void) |
void | TestSlave_operational (void) |
void | TestSlave_stopped (void) |
void | TestSlave_post_sync (void) |
void | TestSlave_post_TPDO (void) |
void | TestSlave_storeODSubIndex (UNS16 wIndex, UNS8 bSubindex) |
UNS8 TestSlave_canSend | +( | +Message * | ++ | ) | ++ |
+ +
void TestSlave_heartbeatError | +( | +UNS8 | ++ | ) | ++ |
void TestSlave_initialisation | +( | +void | ++ | ) | ++ |
void TestSlave_operational | +( | +void | ++ | ) | ++ |
void TestSlave_post_sync | +( | +void | ++ | ) | ++ |
void TestSlave_post_TPDO | +( | +void | ++ | ) | ++ |
void TestSlave_preOperational | +( | +void | ++ | ) | ++ |
void TestSlave_stopped | +( | +void | ++ | ) | ++ |
void TestSlave_storeODSubIndex | +( | +UNS16 | +wIndex, | +|
+ | + | UNS8 | +bSubindex | + |
+ | ) | ++ |
+
00001 +00002 /* File generated by gen_cfile.py. Should not be modified. */ +00003 +00004 #include "TestMaster.h" +00005 +00006 /**************************************************************************/ +00007 /* Declaration of the mapped variables */ +00008 /**************************************************************************/ +00009 UNS8 DO = 0x0; /* Mapped at index 0x2000, subindex 0x00 */ +00010 UNS8 DI1 = 0x0; /* Mapped at index 0x200F, subindex 0x00 */ +00011 UNS8 DI2 = 0x0; /* Mapped at index 0x2010, subindex 0x00 */ +00012 UNS8 DI3 = 0x0; /* Mapped at index 0x2011, subindex 0x00 */ +00013 UNS8 DI4 = 0x0; /* Mapped at index 0x2012, subindex 0x00 */ +00014 UNS8 DI5 = 0x0; /* Mapped at index 0x2013, subindex 0x00 */ +00015 UNS8 DI6 = 0x0; /* Mapped at index 0x2014, subindex 0x00 */ +00016 UNS8 DI7 = 0x0; /* Mapped at index 0x2015, subindex 0x00 */ +00017 UNS8 DI8 = 0x0; /* Mapped at index 0x2016, subindex 0x00 */ +00018 +00019 /**************************************************************************/ +00020 /* Declaration of the value range types */ +00021 /**************************************************************************/ +00022 +00023 UNS32 TestMaster_valueRangeTest (UNS8 typeValue, void * value) +00024 { +00025 switch (typeValue) { +00026 } +00027 return 0; +00028 } +00029 +00030 /**************************************************************************/ +00031 /* The node id */ +00032 /**************************************************************************/ +00033 /* node_id default value.*/ +00034 UNS8 TestMaster_bDeviceNodeId = 0x01; +00035 +00036 /**************************************************************************/ +00037 /* Array of message processing information */ +00038 +00039 const UNS8 TestMaster_iam_a_slave = 0; +00040 +00041 TIMER_HANDLE TestMaster_heartBeatTimers[1] = {TIMER_NONE,}; +00042 +00043 /* +00044 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +00045 +00046 OBJECT DICTIONARY +00047 +00048 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +00049 */ +00050 +00051 /* index 0x1000 : Device Type. */ +00052 UNS32 TestMaster_obj1000 = 0x191; /* 401 */ +00053 subindex TestMaster_Index1000[] = +00054 { +00055 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1000 } +00056 }; +00057 +00058 /* index 0x1001 : Error Register. */ +00059 UNS8 TestMaster_obj1001 = 0x0; /* 0 */ +00060 subindex TestMaster_Index1001[] = +00061 { +00062 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_obj1001 } +00063 }; +00064 +00065 /* index 0x1005 : SYNC COB ID. */ +00066 UNS32 TestMaster_obj1005 = 0x40000080; /* 1073741952 */ +00067 ODCallback_t TestMaster_Index1005_callbacks[] = +00068 { +00069 NULL, +00070 }; +00071 subindex TestMaster_Index1005[] = +00072 { +00073 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1005 } +00074 }; +00075 +00076 /* index 0x1006 : Communication / Cycle Period. */ +00077 UNS32 TestMaster_obj1006 = 0xC350; /* 50000 */ +00078 ODCallback_t TestMaster_Index1006_callbacks[] = +00079 { +00080 NULL, +00081 }; +00082 subindex TestMaster_Index1006[] = +00083 { +00084 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1006 } +00085 }; +00086 +00087 /* index 0x1016 : Consumer Heartbeat Time. */ +00088 UNS8 TestMaster_highestSubIndex_obj1016 = 1; /* number of subindex - 1*/ +00089 UNS32 TestMaster_obj1016[] = +00090 { +00091 0x4005DC /* 4195804 */ +00092 }; +00093 subindex TestMaster_Index1016[] = +00094 { +00095 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1016 }, +00096 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1016[0] } +00097 }; +00098 +00099 /* index 0x1017 : Producer Heartbeat Time */ +00100 UNS16 TestMaster_obj1017 = 0x0; /* 0 */ +00101 +00102 /* index 0x1018 : Identity. */ +00103 UNS8 TestMaster_highestSubIndex_obj1018 = 4; /* number of subindex - 1*/ +00104 UNS32 TestMaster_obj1018_Vendor_ID = 0x0; /* 0 */ +00105 UNS32 TestMaster_obj1018_Product_Code = 0x0; /* 0 */ +00106 UNS32 TestMaster_obj1018_Revision_Number = 0x0; /* 0 */ +00107 UNS32 TestMaster_obj1018_Serial_Number = 0x0; /* 0 */ +00108 subindex TestMaster_Index1018[] = +00109 { +00110 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1018 }, +00111 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Vendor_ID }, +00112 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Product_Code }, +00113 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Revision_Number }, +00114 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Serial_Number } +00115 }; +00116 +00117 /* index 0x1280 : Client SDO 1 Parameter. */ +00118 UNS8 TestMaster_highestSubIndex_obj1280 = 3; /* number of subindex - 1*/ +00119 UNS32 TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO = 0x640; /* 1600 */ +00120 UNS32 TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO = 0x5C0; /* 1472 */ +00121 INTEGER32 TestMaster_obj1280_Node_ID_of_the_SDO_Server = 0x40; /* 64 */ +00122 subindex TestMaster_Index1280[] = +00123 { +00124 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1280 }, +00125 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO }, +00126 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO }, +00127 { RW, int32, sizeof (INTEGER32), (void*)&TestMaster_obj1280_Node_ID_of_the_SDO_Server } +00128 }; +00129 +00130 /* index 0x1400 : Receive PDO 1 Parameter. */ +00131 UNS8 TestMaster_highestSubIndex_obj1400 = 5; /* number of subindex - 1*/ +00132 UNS32 TestMaster_obj1400_COB_ID_used_by_PDO = 0x220; /* 544 */ +00133 UNS8 TestMaster_obj1400_Transmission_Type = 0x1; /* 1 */ +00134 UNS16 TestMaster_obj1400_Inhibit_Time = 0x0; /* 0 */ +00135 UNS8 TestMaster_obj1400_Compatibility_Entry = 0x0; /* 0 */ +00136 UNS16 TestMaster_obj1400_Event_Timer = 0x0; /* 0 */ +00137 subindex TestMaster_Index1400[] = +00138 { +00139 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1400 }, +00140 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1400_COB_ID_used_by_PDO }, +00141 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Transmission_Type }, +00142 { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Inhibit_Time }, +00143 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Compatibility_Entry }, +00144 { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Event_Timer } +00145 }; +00146 +00147 /* index 0x1600 : Receive PDO 1 Mapping. */ +00148 UNS8 TestMaster_highestSubIndex_obj1600 = 8; /* number of subindex - 1*/ +00149 UNS32 TestMaster_obj1600[] = +00150 { +00151 0x200F0001, /* 537853953 */ +00152 0x20100001, /* 537919489 */ +00153 0x20110001, /* 537985025 */ +00154 0x20120001, /* 538050561 */ +00155 0x20130001, /* 538116097 */ +00156 0x20140001, /* 538181633 */ +00157 0x20150001, /* 538247169 */ +00158 0x20160001 /* 538312705 */ +00159 }; +00160 subindex TestMaster_Index1600[] = +00161 { +00162 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1600 }, +00163 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[0] }, +00164 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[1] }, +00165 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[2] }, +00166 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[3] }, +00167 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[4] }, +00168 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[5] }, +00169 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[6] }, +00170 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[7] } +00171 }; +00172 +00173 /* index 0x1800 : Transmit PDO 1 Parameter. */ +00174 UNS8 TestMaster_highestSubIndex_obj1800 = 5; /* number of subindex - 1*/ +00175 UNS32 TestMaster_obj1800_COB_ID_used_by_PDO = 0x240; /* 576 */ +00176 UNS8 TestMaster_obj1800_Transmission_Type = 0x1; /* 1 */ +00177 UNS16 TestMaster_obj1800_Inhibit_Time = 0x0; /* 0 */ +00178 UNS8 TestMaster_obj1800_Compatibility_Entry = 0x0; /* 0 */ +00179 UNS16 TestMaster_obj1800_Event_Timer = 0x0; /* 0 */ +00180 subindex TestMaster_Index1800[] = +00181 { +00182 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1800 }, +00183 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1800_COB_ID_used_by_PDO }, +00184 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1800_Transmission_Type }, +00185 { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1800_Inhibit_Time }, +00186 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1800_Compatibility_Entry }, +00187 { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1800_Event_Timer } +00188 }; +00189 +00190 /* index 0x1A00 : Transmit PDO 1 Mapping. */ +00191 UNS8 TestMaster_highestSubIndex_obj1A00 = 1; /* number of subindex - 1*/ +00192 UNS32 TestMaster_obj1A00[] = +00193 { +00194 0x20000008 /* 536870920 */ +00195 }; +00196 subindex TestMaster_Index1A00[] = +00197 { +00198 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1A00 }, +00199 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1A00[0] } +00200 }; +00201 +00202 /* index 0x2000 : Mapped variable DO */ +00203 subindex TestMaster_Index2000[] = +00204 { +00205 { RW, uint8, sizeof (UNS8), (void*)&DO } +00206 }; +00207 +00208 /* index 0x200F : Mapped variable DI1 */ +00209 subindex TestMaster_Index200F[] = +00210 { +00211 { RW, boolean, sizeof (UNS8), (void*)&DI1 } +00212 }; +00213 +00214 /* index 0x2010 : Mapped variable DI2 */ +00215 subindex TestMaster_Index2010[] = +00216 { +00217 { RW, boolean, sizeof (UNS8), (void*)&DI2 } +00218 }; +00219 +00220 /* index 0x2011 : Mapped variable DI3 */ +00221 subindex TestMaster_Index2011[] = +00222 { +00223 { RW, boolean, sizeof (UNS8), (void*)&DI3 } +00224 }; +00225 +00226 /* index 0x2012 : Mapped variable DI4 */ +00227 subindex TestMaster_Index2012[] = +00228 { +00229 { RW, boolean, sizeof (UNS8), (void*)&DI4 } +00230 }; +00231 +00232 /* index 0x2013 : Mapped variable DI5 */ +00233 subindex TestMaster_Index2013[] = +00234 { +00235 { RW, boolean, sizeof (UNS8), (void*)&DI5 } +00236 }; +00237 +00238 /* index 0x2014 : Mapped variable DI6 */ +00239 subindex TestMaster_Index2014[] = +00240 { +00241 { RW, boolean, sizeof (UNS8), (void*)&DI6 } +00242 }; +00243 +00244 /* index 0x2015 : Mapped variable DI7 */ +00245 subindex TestMaster_Index2015[] = +00246 { +00247 { RW, boolean, sizeof (UNS8), (void*)&DI7 } +00248 }; +00249 +00250 /* index 0x2016 : Mapped variable DI8 */ +00251 subindex TestMaster_Index2016[] = +00252 { +00253 { RW, boolean, sizeof (UNS8), (void*)&DI8 } +00254 }; +00255 +00256 const indextable TestMaster_objdict[] = +00257 { +00258 { (subindex*)TestMaster_Index1000,sizeof(TestMaster_Index1000)/sizeof(TestMaster_Index1000[0]), 0x1000}, +00259 { (subindex*)TestMaster_Index1001,sizeof(TestMaster_Index1001)/sizeof(TestMaster_Index1001[0]), 0x1001}, +00260 { (subindex*)TestMaster_Index1005,sizeof(TestMaster_Index1005)/sizeof(TestMaster_Index1005[0]), 0x1005}, +00261 { (subindex*)TestMaster_Index1006,sizeof(TestMaster_Index1006)/sizeof(TestMaster_Index1006[0]), 0x1006}, +00262 { (subindex*)TestMaster_Index1016,sizeof(TestMaster_Index1016)/sizeof(TestMaster_Index1016[0]), 0x1016}, +00263 { (subindex*)TestMaster_Index1018,sizeof(TestMaster_Index1018)/sizeof(TestMaster_Index1018[0]), 0x1018}, +00264 { (subindex*)TestMaster_Index1280,sizeof(TestMaster_Index1280)/sizeof(TestMaster_Index1280[0]), 0x1280}, +00265 { (subindex*)TestMaster_Index1400,sizeof(TestMaster_Index1400)/sizeof(TestMaster_Index1400[0]), 0x1400}, +00266 { (subindex*)TestMaster_Index1600,sizeof(TestMaster_Index1600)/sizeof(TestMaster_Index1600[0]), 0x1600}, +00267 { (subindex*)TestMaster_Index1800,sizeof(TestMaster_Index1800)/sizeof(TestMaster_Index1800[0]), 0x1800}, +00268 { (subindex*)TestMaster_Index1A00,sizeof(TestMaster_Index1A00)/sizeof(TestMaster_Index1A00[0]), 0x1A00}, +00269 { (subindex*)TestMaster_Index2000,sizeof(TestMaster_Index2000)/sizeof(TestMaster_Index2000[0]), 0x2000}, +00270 { (subindex*)TestMaster_Index200F,sizeof(TestMaster_Index200F)/sizeof(TestMaster_Index200F[0]), 0x200F}, +00271 { (subindex*)TestMaster_Index2010,sizeof(TestMaster_Index2010)/sizeof(TestMaster_Index2010[0]), 0x2010}, +00272 { (subindex*)TestMaster_Index2011,sizeof(TestMaster_Index2011)/sizeof(TestMaster_Index2011[0]), 0x2011}, +00273 { (subindex*)TestMaster_Index2012,sizeof(TestMaster_Index2012)/sizeof(TestMaster_Index2012[0]), 0x2012}, +00274 { (subindex*)TestMaster_Index2013,sizeof(TestMaster_Index2013)/sizeof(TestMaster_Index2013[0]), 0x2013}, +00275 { (subindex*)TestMaster_Index2014,sizeof(TestMaster_Index2014)/sizeof(TestMaster_Index2014[0]), 0x2014}, +00276 { (subindex*)TestMaster_Index2015,sizeof(TestMaster_Index2015)/sizeof(TestMaster_Index2015[0]), 0x2015}, +00277 { (subindex*)TestMaster_Index2016,sizeof(TestMaster_Index2016)/sizeof(TestMaster_Index2016[0]), 0x2016}, +00278 }; +00279 +00280 const indextable * TestMaster_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks) +00281 { +00282 int i; +00283 *callbacks = NULL; +00284 switch(wIndex){ +00285 case 0x1000: i = 0;break; +00286 case 0x1001: i = 1;break; +00287 case 0x1005: i = 2;*callbacks = TestMaster_Index1005_callbacks; break; +00288 case 0x1006: i = 3;*callbacks = TestMaster_Index1006_callbacks; break; +00289 case 0x1016: i = 4;break; +00290 case 0x1018: i = 5;break; +00291 case 0x1280: i = 6;break; +00292 case 0x1400: i = 7;break; +00293 case 0x1600: i = 8;break; +00294 case 0x1800: i = 9;break; +00295 case 0x1A00: i = 10;break; +00296 case 0x2000: i = 11;break; +00297 case 0x200F: i = 12;break; +00298 case 0x2010: i = 13;break; +00299 case 0x2011: i = 14;break; +00300 case 0x2012: i = 15;break; +00301 case 0x2013: i = 16;break; +00302 case 0x2014: i = 17;break; +00303 case 0x2015: i = 18;break; +00304 case 0x2016: i = 19;break; +00305 default: +00306 *errorCode = OD_NO_SUCH_OBJECT; +00307 return NULL; +00308 } +00309 *errorCode = OD_SUCCESSFUL; +00310 return &TestMaster_objdict[i]; +00311 } +00312 +00313 /* To count at which received SYNC a PDO must be sent. +00314 * Even if no pdoTransmit are defined, at least one entry is computed +00315 * for compilations issues. +00316 */ +00317 UNS8 TestMaster_count_sync[1] = {0,}; +00318 +00319 quick_index TestMaster_firstIndex = { +00320 0, /* SDO_SVR */ +00321 6, /* SDO_CLT */ +00322 7, /* PDO_RCV */ +00323 8, /* PDO_RCV_MAP */ +00324 9, /* PDO_TRS */ +00325 10 /* PDO_TRS_MAP */ +00326 }; +00327 +00328 quick_index TestMaster_lastIndex = { +00329 0, /* SDO_SVR */ +00330 6, /* SDO_CLT */ +00331 7, /* PDO_RCV */ +00332 8, /* PDO_RCV_MAP */ +00333 9, /* PDO_TRS */ +00334 10 /* PDO_TRS_MAP */ +00335 }; +00336 +00337 UNS16 TestMaster_ObjdictSize = sizeof(TestMaster_objdict)/sizeof(TestMaster_objdict[0]); +00338 +00339 CO_Data TestMaster_Data = CANOPEN_NODE_DATA_INITIALIZER(TestMaster); +00340 +
#include "TestMaster.h"
+Include dependency graph for TestMaster.c:
+Go to the source code of this file.
const indextable* TestMaster_scanIndexOD | +( | +UNS16 | +wIndex, | +|
+ | + | UNS32 * | +errorCode, | +|
+ | + | ODCallback_t ** | +callbacks | + |
+ | ) | ++ |
+ +
+Definition at line 280 of file TestMaster.c. +
+References OD_NO_SUCH_OBJECT, OD_SUCCESSFUL, TestMaster_Index1005_callbacks, TestMaster_Index1006_callbacks, and TestMaster_objdict. +
UNS32 TestMaster_valueRangeTest | +( | +UNS8 | +typeValue, | +|
+ | + | void * | +value | + |
+ | ) | ++ |
+ +
+Definition at line 23 of file TestMaster.c. +
+
UNS8 DI1 = 0x0 | +
UNS8 DI2 = 0x0 | +
UNS8 DI3 = 0x0 | +
UNS8 DI4 = 0x0 | +
UNS8 DI5 = 0x0 | +
UNS8 DI6 = 0x0 | +
UNS8 DI7 = 0x0 | +
UNS8 DI8 = 0x0 | +
UNS8 DO = 0x0 | +
UNS8 TestMaster_bDeviceNodeId = 0x01 | +
+ +
+Definition at line 34 of file TestMaster.c. +
UNS8 TestMaster_count_sync[1] = {0,} | +
+ +
+Definition at line 317 of file TestMaster.c. +
CO_Data TestMaster_Data = CANOPEN_NODE_DATA_INITIALIZER(TestMaster) | +
+ +
+Definition at line 339 of file TestMaster.c. +
quick_index TestMaster_firstIndex | +
+Initial value:
{ + 0, + 6, + 7, + 8, + 9, + 10 +} +
+Definition at line 319 of file TestMaster.c. +
TIMER_HANDLE TestMaster_heartBeatTimers[1] = {TIMER_NONE,} | +
+ +
+Definition at line 41 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1016 = 1 | +
+ +
+Definition at line 88 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1018 = 4 | +
+ +
+Definition at line 103 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1280 = 3 | +
+ +
+Definition at line 118 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1400 = 5 | +
+ +
+Definition at line 131 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1600 = 8 | +
+ +
+Definition at line 148 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1800 = 5 | +
+ +
+Definition at line 174 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1A00 = 1 | +
+ +
+Definition at line 191 of file TestMaster.c. +
const UNS8 TestMaster_iam_a_slave = 0 | +
+ +
+Definition at line 39 of file TestMaster.c. +
subindex TestMaster_Index1000[] | +
+Initial value:
+ { + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1000 } + } +
+Definition at line 53 of file TestMaster.c. +
subindex TestMaster_Index1001[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_obj1001 } + } +
+Definition at line 60 of file TestMaster.c. +
subindex TestMaster_Index1005[] | +
+Initial value:
+ { + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1005 } + } +
+Definition at line 71 of file TestMaster.c. +
ODCallback_t TestMaster_Index1005_callbacks[] | +
subindex TestMaster_Index1006[] | +
+Initial value:
+ { + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1006 } + } +
+Definition at line 82 of file TestMaster.c. +
ODCallback_t TestMaster_Index1006_callbacks[] | +
subindex TestMaster_Index1016[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1016 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1016[0] } + } +
+Definition at line 93 of file TestMaster.c. +
subindex TestMaster_Index1018[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1018 }, + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Vendor_ID }, + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Product_Code }, + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Revision_Number }, + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Serial_Number } + } +
+Definition at line 108 of file TestMaster.c. +
subindex TestMaster_Index1280[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1280 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO }, + { RW, int32, sizeof (INTEGER32), (void*)&TestMaster_obj1280_Node_ID_of_the_SDO_Server } + } +
+Definition at line 122 of file TestMaster.c. +
subindex TestMaster_Index1400[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1400 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1400_COB_ID_used_by_PDO }, + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Transmission_Type }, + { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Inhibit_Time }, + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Compatibility_Entry }, + { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Event_Timer } + } +
+Definition at line 137 of file TestMaster.c. +
subindex TestMaster_Index1600[] | +
+Initial value:
+ { + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1600 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[0] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[1] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[2] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[3] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[4] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[5] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[6] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[7] } + } +
+Definition at line 160 of file TestMaster.c. +
subindex TestMaster_Index1800[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1800 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1800_COB_ID_used_by_PDO }, + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1800_Transmission_Type }, + { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1800_Inhibit_Time }, + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1800_Compatibility_Entry }, + { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1800_Event_Timer } + } +
+Definition at line 180 of file TestMaster.c. +
subindex TestMaster_Index1A00[] | +
+Initial value:
+ { + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1A00 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1A00[0] } + } +
+Definition at line 196 of file TestMaster.c. +
subindex TestMaster_Index2000[] | +
subindex TestMaster_Index200F[] | +
subindex TestMaster_Index2010[] | +
subindex TestMaster_Index2011[] | +
subindex TestMaster_Index2012[] | +
subindex TestMaster_Index2013[] | +
subindex TestMaster_Index2014[] | +
subindex TestMaster_Index2015[] | +
subindex TestMaster_Index2016[] | +
quick_index TestMaster_lastIndex | +
+Initial value:
{ + 0, + 6, + 7, + 8, + 9, + 10 +} +
+Definition at line 328 of file TestMaster.c. +
UNS32 TestMaster_obj1000 = 0x191 | +
+ +
+Definition at line 52 of file TestMaster.c. +
UNS8 TestMaster_obj1001 = 0x0 | +
+ +
+Definition at line 59 of file TestMaster.c. +
UNS32 TestMaster_obj1005 = 0x40000080 | +
+ +
+Definition at line 66 of file TestMaster.c. +
UNS32 TestMaster_obj1006 = 0xC350 | +
+ +
+Definition at line 77 of file TestMaster.c. +
UNS32 TestMaster_obj1016[] | +
UNS16 TestMaster_obj1017 = 0x0 | +
+ +
+Definition at line 100 of file TestMaster.c. +
UNS32 TestMaster_obj1018_Product_Code = 0x0 | +
+ +
+Definition at line 105 of file TestMaster.c. +
UNS32 TestMaster_obj1018_Revision_Number = 0x0 | +
+ +
+Definition at line 106 of file TestMaster.c. +
UNS32 TestMaster_obj1018_Serial_Number = 0x0 | +
+ +
+Definition at line 107 of file TestMaster.c. +
UNS32 TestMaster_obj1018_Vendor_ID = 0x0 | +
+ +
+Definition at line 104 of file TestMaster.c. +
UNS32 TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO = 0x640 | +
+ +
+Definition at line 119 of file TestMaster.c. +
UNS32 TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO = 0x5C0 | +
+ +
+Definition at line 120 of file TestMaster.c. +
INTEGER32 TestMaster_obj1280_Node_ID_of_the_SDO_Server = 0x40 | +
+ +
+Definition at line 121 of file TestMaster.c. +
UNS32 TestMaster_obj1400_COB_ID_used_by_PDO = 0x220 | +
+ +
+Definition at line 132 of file TestMaster.c. +
UNS8 TestMaster_obj1400_Compatibility_Entry = 0x0 | +
+ +
+Definition at line 135 of file TestMaster.c. +
UNS16 TestMaster_obj1400_Event_Timer = 0x0 | +
+ +
+Definition at line 136 of file TestMaster.c. +
UNS16 TestMaster_obj1400_Inhibit_Time = 0x0 | +
+ +
+Definition at line 134 of file TestMaster.c. +
UNS8 TestMaster_obj1400_Transmission_Type = 0x1 | +
+ +
+Definition at line 133 of file TestMaster.c. +
UNS32 TestMaster_obj1600[] | +
+Initial value:
+ { + 0x200F0001, + 0x20100001, + 0x20110001, + 0x20120001, + 0x20130001, + 0x20140001, + 0x20150001, + 0x20160001 + } +
+Definition at line 149 of file TestMaster.c. +
UNS32 TestMaster_obj1800_COB_ID_used_by_PDO = 0x240 | +
+ +
+Definition at line 175 of file TestMaster.c. +
UNS8 TestMaster_obj1800_Compatibility_Entry = 0x0 | +
+ +
+Definition at line 178 of file TestMaster.c. +
UNS16 TestMaster_obj1800_Event_Timer = 0x0 | +
+ +
+Definition at line 179 of file TestMaster.c. +
UNS16 TestMaster_obj1800_Inhibit_Time = 0x0 | +
+ +
+Definition at line 177 of file TestMaster.c. +
UNS8 TestMaster_obj1800_Transmission_Type = 0x1 | +
+ +
+Definition at line 176 of file TestMaster.c. +
UNS32 TestMaster_obj1A00[] | +
const indextable TestMaster_objdict[] | +
+Initial value:
+{ + { (subindex*)TestMaster_Index1000,sizeof(TestMaster_Index1000)/sizeof(TestMaster_Index1000[0]), 0x1000}, + { (subindex*)TestMaster_Index1001,sizeof(TestMaster_Index1001)/sizeof(TestMaster_Index1001[0]), 0x1001}, + { (subindex*)TestMaster_Index1005,sizeof(TestMaster_Index1005)/sizeof(TestMaster_Index1005[0]), 0x1005}, + { (subindex*)TestMaster_Index1006,sizeof(TestMaster_Index1006)/sizeof(TestMaster_Index1006[0]), 0x1006}, + { (subindex*)TestMaster_Index1016,sizeof(TestMaster_Index1016)/sizeof(TestMaster_Index1016[0]), 0x1016}, + { (subindex*)TestMaster_Index1018,sizeof(TestMaster_Index1018)/sizeof(TestMaster_Index1018[0]), 0x1018}, + { (subindex*)TestMaster_Index1280,sizeof(TestMaster_Index1280)/sizeof(TestMaster_Index1280[0]), 0x1280}, + { (subindex*)TestMaster_Index1400,sizeof(TestMaster_Index1400)/sizeof(TestMaster_Index1400[0]), 0x1400}, + { (subindex*)TestMaster_Index1600,sizeof(TestMaster_Index1600)/sizeof(TestMaster_Index1600[0]), 0x1600}, + { (subindex*)TestMaster_Index1800,sizeof(TestMaster_Index1800)/sizeof(TestMaster_Index1800[0]), 0x1800}, + { (subindex*)TestMaster_Index1A00,sizeof(TestMaster_Index1A00)/sizeof(TestMaster_Index1A00[0]), 0x1A00}, + { (subindex*)TestMaster_Index2000,sizeof(TestMaster_Index2000)/sizeof(TestMaster_Index2000[0]), 0x2000}, + { (subindex*)TestMaster_Index200F,sizeof(TestMaster_Index200F)/sizeof(TestMaster_Index200F[0]), 0x200F}, + { (subindex*)TestMaster_Index2010,sizeof(TestMaster_Index2010)/sizeof(TestMaster_Index2010[0]), 0x2010}, + { (subindex*)TestMaster_Index2011,sizeof(TestMaster_Index2011)/sizeof(TestMaster_Index2011[0]), 0x2011}, + { (subindex*)TestMaster_Index2012,sizeof(TestMaster_Index2012)/sizeof(TestMaster_Index2012[0]), 0x2012}, + { (subindex*)TestMaster_Index2013,sizeof(TestMaster_Index2013)/sizeof(TestMaster_Index2013[0]), 0x2013}, + { (subindex*)TestMaster_Index2014,sizeof(TestMaster_Index2014)/sizeof(TestMaster_Index2014[0]), 0x2014}, + { (subindex*)TestMaster_Index2015,sizeof(TestMaster_Index2015)/sizeof(TestMaster_Index2015[0]), 0x2015}, + { (subindex*)TestMaster_Index2016,sizeof(TestMaster_Index2016)/sizeof(TestMaster_Index2016[0]), 0x2016}, +} +
+Definition at line 256 of file TestMaster.c. +
UNS16 TestMaster_ObjdictSize = sizeof(TestMaster_objdict)/sizeof(TestMaster_objdict[0]) | +
+ +
+Definition at line 337 of file TestMaster.c. +
+
00001 +00002 /* File generated by gen_cfile.py. Should not be modified. */ +00003 +00004 #include "data.h" +00005 +00006 /* Prototypes of function provided by object dictionnary */ +00007 UNS32 TestMaster_valueRangeTest (UNS8 typeValue, void * value); +00008 const indextable * TestMaster_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks); +00009 +00010 /* Master node data struct */ +00011 extern CO_Data TestMaster_Data; +00012 +00013 extern UNS8 DO; /* Mapped at index 0x2000, subindex 0x00*/ +00014 extern UNS8 DI1; /* Mapped at index 0x200F, subindex 0x00*/ +00015 extern UNS8 DI2; /* Mapped at index 0x2010, subindex 0x00*/ +00016 extern UNS8 DI3; /* Mapped at index 0x2011, subindex 0x00*/ +00017 extern UNS8 DI4; /* Mapped at index 0x2012, subindex 0x00*/ +00018 extern UNS8 DI5; /* Mapped at index 0x2013, subindex 0x00*/ +00019 extern UNS8 DI6; /* Mapped at index 0x2014, subindex 0x00*/ +00020 extern UNS8 DI7; /* Mapped at index 0x2015, subindex 0x00*/ +00021 extern UNS8 DI8; /* Mapped at index 0x2016, subindex 0x00*/ +
#include "data.h"
+Include dependency graph for TestMaster.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Functions | |
UNS32 | TestMaster_valueRangeTest (UNS8 typeValue, void *value) |
const indextable * | TestMaster_scanIndexOD (UNS16 wIndex, UNS32 *errorCode, ODCallback_t **callbacks) |
Variables | |
CO_Data | TestMaster_Data |
UNS8 | DO |
UNS8 | DI1 |
UNS8 | DI2 |
UNS8 | DI3 |
UNS8 | DI4 |
UNS8 | DI5 |
UNS8 | DI6 |
UNS8 | DI7 |
UNS8 | DI8 |
const indextable* TestMaster_scanIndexOD | +( | +UNS16 | +wIndex, | +|
+ | + | UNS32 * | +errorCode, | +|
+ | + | ODCallback_t ** | +callbacks | + |
+ | ) | ++ |
+ +
+Definition at line 347 of file TestMaster.c. +
+References OD_NO_SUCH_OBJECT, OD_SUCCESSFUL, TestMaster_Index1005_callbacks, TestMaster_Index1006_callbacks, and TestMaster_objdict. +
UNS32 TestMaster_valueRangeTest | +( | +UNS8 | +typeValue, | +|
+ | + | void * | +value | + |
+ | ) | ++ |
+ +
+Definition at line 25 of file TestMaster.c. +
+
UNS8 DI1 | +
UNS8 DI2 | +
UNS8 DI3 | +
UNS8 DI4 | +
UNS8 DI5 | +
UNS8 DI6 | +
UNS8 DI7 | +
UNS8 DI8 | +
UNS8 DO | +
CO_Data TestMaster_Data | +
+ +
+Definition at line 411 of file TestMaster.c. +
+
00001 /* from http://www.pwilson.net/getopt.html */ +00002 +00003 /* Getopt for GNU. +00004 NOTE: getopt is now part of the C library, so if you don't know what +00005 "Keep this file name-space clean" means, talk to drepper@gnu.org +00006 before changing it! +00007 Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001 +00008 Free Software Foundation, Inc. +00009 This file is part of the GNU C Library. +00010 +00011 The GNU C Library is free software; you can redistribute it and/or +00012 modify it under the terms of the GNU Lesser General Public +00013 License as published by the Free Software Foundation; either +00014 version 2.1 of the License, or (at your option) any later version. +00015 +00016 The GNU C Library is distributed in the hope that it will be useful, +00017 but WITHOUT ANY WARRANTY; without even the implied warranty of +00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00019 Lesser General Public License for more details. +00020 +00021 You should have received a copy of the GNU Lesser General Public +00022 License along with the GNU C Library; if not, write to the Free +00023 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +00024 02111-1307 USA. */ +00025 +00026 /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. +00027 Ditto for AIX 3.2 and <stdlib.h>. */ +00028 #ifndef _NO_PROTO +00029 # define _NO_PROTO +00030 #endif +00031 +00032 #ifdef HAVE_CONFIG_H +00033 # include <config.h> +00034 #endif +00035 +00036 #if !defined __STDC__ || !__STDC__ +00037 /* This is a separate conditional since some stdc systems +00038 reject `defined (const)'. */ +00039 # ifndef const +00040 # define const +00041 # endif +00042 #endif +00043 +00044 #include <stdio.h> +00045 +00046 /* Comment out all this code if we are using the GNU C Library, and are not +00047 actually compiling the library itself. This code is part of the GNU C +00048 Library, but also included in many other GNU distributions. Compiling +00049 and linking in this code is a waste when using the GNU C library +00050 (especially if it is a shared library). Rather than having every GNU +00051 program understand `configure --with-gnu-libc' and omit the object files, +00052 it is simpler to just do this in the source for each such file. */ +00053 +00054 #define GETOPT_INTERFACE_VERSION 2 +00055 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +00056 # include <gnu-versions.h> +00057 # if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +00058 # define ELIDE_CODE +00059 # endif +00060 #endif +00061 +00062 #ifndef ELIDE_CODE +00063 +00064 +00065 /* This needs to come after some library #include +00066 to get __GNU_LIBRARY__ defined. */ +00067 #ifdef __GNU_LIBRARY__ +00068 /* Don't include stdlib.h for non-GNU C libraries because some of them +00069 contain conflicting prototypes for getopt. */ +00070 # include <stdlib.h> +00071 # include <unistd.h> +00072 #endif /* GNU C library. */ +00073 +00074 #ifdef VMS +00075 # include <unixlib.h> +00076 # if HAVE_STRING_H - 0 +00077 # include <string.h> +00078 # endif +00079 #endif +00080 +00081 #ifndef _ +00082 /* This is for other GNU distributions with internationalized messages. */ +00083 # if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC +00084 # include <libintl.h> +00085 # ifndef _ +00086 # define _(msgid) gettext (msgid) +00087 # endif +00088 # else +00089 # define _(msgid) (msgid) +00090 # endif +00091 # if defined _LIBC && defined USE_IN_LIBIO +00092 # include <wchar.h> +00093 # endif +00094 #endif +00095 +00096 /* This version of `getopt' appears to the caller like standard Unix `getopt' +00097 but it behaves differently for the user, since it allows the user +00098 to intersperse the options with the other arguments. +00099 +00100 As `getopt' works, it permutes the elements of ARGV so that, +00101 when it is done, all the options precede everything else. Thus +00102 all application programs are extended to handle flexible argument order. +00103 +00104 Setting the environment variable POSIXLY_CORRECT disables permutation. +00105 Then the behavior is completely standard. +00106 +00107 GNU application programs can use a third alternative mode in which +00108 they can distinguish the relative order of options and other arguments. */ +00109 +00110 #include "getopt.h" +00111 +00112 /* For communication from `getopt' to the caller. +00113 When `getopt' finds an option that takes an argument, +00114 the argument value is returned here. +00115 Also, when `ordering' is RETURN_IN_ORDER, +00116 each non-option ARGV-element is returned here. */ +00117 +00118 char *optarg; +00119 +00120 /* Index in ARGV of the next element to be scanned. +00121 This is used for communication to and from the caller +00122 and for communication between successive calls to `getopt'. +00123 +00124 On entry to `getopt', zero means this is the first call; initialize. +00125 +00126 When `getopt' returns -1, this is the index of the first of the +00127 non-option elements that the caller should itself scan. +00128 +00129 Otherwise, `optind' communicates from one call to the next +00130 how much of ARGV has been scanned so far. */ +00131 +00132 /* 1003.2 says this must be 1 before any call. */ +00133 int optind = 1; +00134 +00135 /* Formerly, initialization of getopt depended on optind==0, which +00136 causes problems with re-calling getopt as programs generally don't +00137 know that. */ +00138 +00139 int __getopt_initialized; +00140 +00141 /* The next char to be scanned in the option-element +00142 in which the last option character we returned was found. +00143 This allows us to pick up the scan where we left off. +00144 +00145 If this is zero, or a null string, it means resume the scan +00146 by advancing to the next ARGV-element. */ +00147 +00148 static char *nextchar; +00149 +00150 /* Callers store zero here to inhibit the error message +00151 for unrecognized options. */ +00152 +00153 int opterr = 1; +00154 +00155 /* Set to an option character which was unrecognized. +00156 This must be initialized on some systems to avoid linking in the +00157 system's own getopt implementation. */ +00158 +00159 int optopt = '?'; +00160 +00161 /* Describe how to deal with options that follow non-option ARGV-elements. +00162 +00163 If the caller did not specify anything, +00164 the default is REQUIRE_ORDER if the environment variable +00165 POSIXLY_CORRECT is defined, PERMUTE otherwise. +00166 +00167 REQUIRE_ORDER means don't recognize them as options; +00168 stop option processing when the first non-option is seen. +00169 This is what Unix does. +00170 This mode of operation is selected by either setting the environment +00171 variable POSIXLY_CORRECT, or using `+' as the first character +00172 of the list of option characters. +00173 +00174 PERMUTE is the default. We permute the contents of ARGV as we scan, +00175 so that eventually all the non-options are at the end. This allows options +00176 to be given in any order, even with programs that were not written to +00177 expect this. +00178 +00179 RETURN_IN_ORDER is an option available to programs that were written +00180 to expect options and other ARGV-elements in any order and that care about +00181 the ordering of the two. We describe each non-option ARGV-element +00182 as if it were the argument of an option with character code 1. +00183 Using `-' as the first character of the list of option characters +00184 selects this mode of operation. +00185 +00186 The special argument `--' forces an end of option-scanning regardless +00187 of the value of `ordering'. In the case of RETURN_IN_ORDER, only +00188 `--' can cause `getopt' to return -1 with `optind' != ARGC. */ +00189 +00190 static enum +00191 { +00192 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +00193 } ordering; +00194 +00195 /* Value of POSIXLY_CORRECT environment variable. */ +00196 static char *posixly_correct; +00197 +00198 #ifdef __GNU_LIBRARY__ +00199 /* We want to avoid inclusion of string.h with non-GNU libraries +00200 because there are many ways it can cause trouble. +00201 On some systems, it contains special magic macros that don't work +00202 in GCC. */ +00203 # include <string.h> +00204 # define my_index strchr +00205 #else +00206 +00207 # if HAVE_STRING_H || WIN32 /* Pete Wilson mod 7/28/02 */ +00208 # include <string.h> +00209 # else +00210 # include <strings.h> +00211 # endif +00212 +00213 /* Avoid depending on library functions or files +00214 whose names are inconsistent. */ +00215 +00216 #ifndef getenv +00217 extern char *getenv (); +00218 #endif +00219 +00220 static char * +00221 my_index (str, chr) +00222 const char *str; +00223 int chr; +00224 { +00225 while (*str) +00226 { +00227 if (*str == chr) +00228 return (char *) str; +00229 str++; +00230 } +00231 return 0; +00232 } +00233 +00234 /* If using GCC, we can safely declare strlen this way. +00235 If not using GCC, it is ok not to declare it. */ +00236 #ifdef __GNUC__ +00237 /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. +00238 That was relevant to code that was here before. */ +00239 # if (!defined __STDC__ || !__STDC__) && !defined strlen +00240 /* gcc with -traditional declares the built-in strlen to return int, +00241 and has done so at least since version 2.4.5. -- rms. */ +00242 extern int strlen (const char *); +00243 # endif /* not __STDC__ */ +00244 #endif /* __GNUC__ */ +00245 +00246 #endif /* not __GNU_LIBRARY__ */ +00247 +00248 /* Handle permutation of arguments. */ +00249 +00250 /* Describe the part of ARGV that contains non-options that have +00251 been skipped. `first_nonopt' is the index in ARGV of the first of them; +00252 `last_nonopt' is the index after the last of them. */ +00253 +00254 static int first_nonopt; +00255 static int last_nonopt; +00256 +00257 #ifdef _LIBC +00258 /* Stored original parameters. +00259 XXX This is no good solution. We should rather copy the args so +00260 that we can compare them later. But we must not use malloc(3). */ +00261 extern int __libc_argc; +00262 extern char **__libc_argv; +00263 +00264 /* Bash 2.0 gives us an environment variable containing flags +00265 indicating ARGV elements that should not be considered arguments. */ +00266 +00267 # ifdef USE_NONOPTION_FLAGS +00268 /* Defined in getopt_init.c */ +00269 extern char *__getopt_nonoption_flags; +00270 +00271 static int nonoption_flags_max_len; +00272 static int nonoption_flags_len; +00273 # endif +00274 +00275 # ifdef USE_NONOPTION_FLAGS +00276 # define SWAP_FLAGS(ch1, ch2) \ +00277 if (nonoption_flags_len > 0) \ +00278 { \ +00279 char __tmp = __getopt_nonoption_flags[ch1]; \ +00280 __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ +00281 __getopt_nonoption_flags[ch2] = __tmp; \ +00282 } +00283 # else +00284 # define SWAP_FLAGS(ch1, ch2) +00285 # endif +00286 #else /* !_LIBC */ +00287 # define SWAP_FLAGS(ch1, ch2) +00288 #endif /* _LIBC */ +00289 +00290 /* Exchange two adjacent subsequences of ARGV. +00291 One subsequence is elements [first_nonopt,last_nonopt) +00292 which contains all the non-options that have been skipped so far. +00293 The other is elements [last_nonopt,optind), which contains all +00294 the options processed since those non-options were skipped. +00295 +00296 `first_nonopt' and `last_nonopt' are relocated so that they describe +00297 the new indices of the non-options in ARGV after they are moved. */ +00298 +00299 #if defined __STDC__ && __STDC__ +00300 static void exchange (char **); +00301 #endif +00302 +00303 static void +00304 exchange (argv) +00305 char **argv; +00306 { +00307 int bottom = first_nonopt; +00308 int middle = last_nonopt; +00309 int top = optind; +00310 char *tem; +00311 +00312 /* Exchange the shorter segment with the far end of the longer segment. +00313 That puts the shorter segment into the right place. +00314 It leaves the longer segment in the right place overall, +00315 but it consists of two parts that need to be swapped next. */ +00316 +00317 #if defined _LIBC && defined USE_NONOPTION_FLAGS +00318 /* First make sure the handling of the `__getopt_nonoption_flags' +00319 string can work normally. Our top argument must be in the range +00320 of the string. */ +00321 if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) +00322 { +00323 /* We must extend the array. The user plays games with us and +00324 presents new arguments. */ +00325 char *new_str = malloc (top + 1); +00326 if (new_str == NULL) +00327 nonoption_flags_len = nonoption_flags_max_len = 0; +00328 else +00329 { +00330 memset (__mempcpy (new_str, __getopt_nonoption_flags, +00331 nonoption_flags_max_len), +00332 '\0', top + 1 - nonoption_flags_max_len); +00333 nonoption_flags_max_len = top + 1; +00334 __getopt_nonoption_flags = new_str; +00335 } +00336 } +00337 #endif +00338 +00339 while (top > middle && middle > bottom) +00340 { +00341 if (top - middle > middle - bottom) +00342 { +00343 /* Bottom segment is the short one. */ +00344 int len = middle - bottom; +00345 register int i; +00346 +00347 /* Swap it with the top part of the top segment. */ +00348 for (i = 0; i < len; i++) +00349 { +00350 tem = argv[bottom + i]; +00351 argv[bottom + i] = argv[top - (middle - bottom) + i]; +00352 argv[top - (middle - bottom) + i] = tem; +00353 SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); +00354 } +00355 /* Exclude the moved bottom segment from further swapping. */ +00356 top -= len; +00357 } +00358 else +00359 { +00360 /* Top segment is the short one. */ +00361 int len = top - middle; +00362 register int i; +00363 +00364 /* Swap it with the bottom part of the bottom segment. */ +00365 for (i = 0; i < len; i++) +00366 { +00367 tem = argv[bottom + i]; +00368 argv[bottom + i] = argv[middle + i]; +00369 argv[middle + i] = tem; +00370 SWAP_FLAGS (bottom + i, middle + i); +00371 } +00372 /* Exclude the moved top segment from further swapping. */ +00373 bottom += len; +00374 } +00375 } +00376 +00377 /* Update records for the slots the non-options now occupy. */ +00378 +00379 first_nonopt += (optind - last_nonopt); +00380 last_nonopt = optind; +00381 } +00382 +00383 /* Initialize the internal data when the first call is made. */ +00384 +00385 #if defined __STDC__ && __STDC__ +00386 static const char *_getopt_initialize (int, char *const *, const char *); +00387 #endif +00388 static const char * +00389 _getopt_initialize (argc, argv, optstring) +00390 int argc; +00391 char *const *argv; +00392 const char *optstring; +00393 { +00394 /* Start processing options with ARGV-element 1 (since ARGV-element 0 +00395 is the program name); the sequence of previously skipped +00396 non-option ARGV-elements is empty. */ +00397 +00398 first_nonopt = last_nonopt = optind; +00399 +00400 nextchar = NULL; +00401 +00402 posixly_correct = getenv ("POSIXLY_CORRECT"); +00403 +00404 /* Determine how to handle the ordering of options and nonoptions. */ +00405 +00406 if (optstring[0] == '-') +00407 { +00408 ordering = RETURN_IN_ORDER; +00409 ++optstring; +00410 } +00411 else if (optstring[0] == '+') +00412 { +00413 ordering = REQUIRE_ORDER; +00414 ++optstring; +00415 } +00416 else if (posixly_correct != NULL) +00417 ordering = REQUIRE_ORDER; +00418 else +00419 ordering = PERMUTE; +00420 +00421 #if defined _LIBC && defined USE_NONOPTION_FLAGS +00422 if (posixly_correct == NULL +00423 && argc == __libc_argc && argv == __libc_argv) +00424 { +00425 if (nonoption_flags_max_len == 0) +00426 { +00427 if (__getopt_nonoption_flags == NULL +00428 || __getopt_nonoption_flags[0] == '\0') +00429 nonoption_flags_max_len = -1; +00430 else +00431 { +00432 const char *orig_str = __getopt_nonoption_flags; +00433 int len = nonoption_flags_max_len = strlen (orig_str); +00434 if (nonoption_flags_max_len < argc) +00435 nonoption_flags_max_len = argc; +00436 __getopt_nonoption_flags = +00437 (char *) malloc (nonoption_flags_max_len); +00438 if (__getopt_nonoption_flags == NULL) +00439 nonoption_flags_max_len = -1; +00440 else +00441 memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), +00442 '\0', nonoption_flags_max_len - len); +00443 } +00444 } +00445 nonoption_flags_len = nonoption_flags_max_len; +00446 } +00447 else +00448 nonoption_flags_len = 0; +00449 #endif +00450 +00451 return optstring; +00452 } +00453 +00454 /* Scan elements of ARGV (whose length is ARGC) for option characters +00455 given in OPTSTRING. +00456 +00457 If an element of ARGV starts with '-', and is not exactly "-" or "--", +00458 then it is an option element. The characters of this element +00459 (aside from the initial '-') are option characters. If `getopt' +00460 is called repeatedly, it returns successively each of the option characters +00461 from each of the option elements. +00462 +00463 If `getopt' finds another option character, it returns that character, +00464 updating `optind' and `nextchar' so that the next call to `getopt' can +00465 resume the scan with the following option character or ARGV-element. +00466 +00467 If there are no more option characters, `getopt' returns -1. +00468 Then `optind' is the index in ARGV of the first ARGV-element +00469 that is not an option. (The ARGV-elements have been permuted +00470 so that those that are not options now come last.) +00471 +00472 OPTSTRING is a string containing the legitimate option characters. +00473 If an option character is seen that is not listed in OPTSTRING, +00474 return '?' after printing an error message. If you set `opterr' to +00475 zero, the error message is suppressed but we still return '?'. +00476 +00477 If a char in OPTSTRING is followed by a colon, that means it wants an arg, +00478 so the following text in the same ARGV-element, or the text of the following +00479 ARGV-element, is returned in `optarg'. Two colons mean an option that +00480 wants an optional arg; if there is text in the current ARGV-element, +00481 it is returned in `optarg', otherwise `optarg' is set to zero. +00482 +00483 If OPTSTRING starts with `-' or `+', it requests different methods of +00484 handling the non-option ARGV-elements. +00485 See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. +00486 +00487 Long-named options begin with `--' instead of `-'. +00488 Their names may be abbreviated as long as the abbreviation is unique +00489 or is an exact match for some defined option. If they have an +00490 argument, it follows the option name in the same ARGV-element, separated +00491 from the option name by a `=', or else the in next ARGV-element. +00492 When `getopt' finds a long-named option, it returns 0 if that option's +00493 `flag' field is nonzero, the value of the option's `val' field +00494 if the `flag' field is zero. +00495 +00496 The elements of ARGV aren't really const, because we permute them. +00497 But we pretend they're const in the prototype to be compatible +00498 with other systems. +00499 +00500 LONGOPTS is a vector of `struct option' terminated by an +00501 element containing a name which is zero. +00502 +00503 LONGIND returns the index in LONGOPT of the long-named option found. +00504 It is only valid when a long-named option has been found by the most +00505 recent call. +00506 +00507 If LONG_ONLY is nonzero, '-' as well as '--' can introduce +00508 long-named options. */ +00509 +00510 int +00511 _getopt_internal (argc, argv, optstring, longopts, longind, long_only) +00512 int argc; +00513 char *const *argv; +00514 const char *optstring; +00515 const struct option *longopts; +00516 int *longind; +00517 int long_only; +00518 { +00519 int print_errors = opterr; +00520 if (optstring[0] == ':') +00521 print_errors = 0; +00522 +00523 if (argc < 1) +00524 return -1; +00525 +00526 optarg = NULL; +00527 +00528 if (optind == 0 || !__getopt_initialized) +00529 { +00530 if (optind == 0) +00531 optind = 1; /* Don't scan ARGV[0], the program name. */ +00532 optstring = _getopt_initialize (argc, argv, optstring); +00533 __getopt_initialized = 1; +00534 } +00535 +00536 /* Test whether ARGV[optind] points to a non-option argument. +00537 Either it does not have option syntax, or there is an environment flag +00538 from the shell indicating it is not an option. The later information +00539 is only used when the used in the GNU libc. */ +00540 #if defined _LIBC && defined USE_NONOPTION_FLAGS +00541 # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ +00542 || (optind < nonoption_flags_len \ +00543 && __getopt_nonoption_flags[optind] == '1')) +00544 #else +00545 # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +00546 #endif +00547 +00548 if (nextchar == NULL || *nextchar == '\0') +00549 { +00550 /* Advance to the next ARGV-element. */ +00551 +00552 /* Give FIRST_NONOPT and LAST_NONOPT rational values if OPTIND has been +00553 moved back by the user (who may also have changed the arguments). */ +00554 if (last_nonopt > optind) +00555 last_nonopt = optind; +00556 if (first_nonopt > optind) +00557 first_nonopt = optind; +00558 +00559 if (ordering == PERMUTE) +00560 { +00561 /* If we have just processed some options following some non-options, +00562 exchange them so that the options come first. */ +00563 +00564 if (first_nonopt != last_nonopt && last_nonopt != optind) +00565 exchange ((char **) argv); +00566 else if (last_nonopt != optind) +00567 first_nonopt = optind; +00568 +00569 /* Skip any additional non-options +00570 and extend the range of non-options previously skipped. */ +00571 +00572 while (optind < argc && NONOPTION_P) +00573 optind++; +00574 last_nonopt = optind; +00575 } +00576 +00577 /* The special ARGV-element `--' means premature end of options. +00578 Skip it like a null option, +00579 then exchange with previous non-options as if it were an option, +00580 then skip everything else like a non-option. */ +00581 +00582 if (optind != argc && !strcmp (argv[optind], "--")) +00583 { +00584 optind++; +00585 +00586 if (first_nonopt != last_nonopt && last_nonopt != optind) +00587 exchange ((char **) argv); +00588 else if (first_nonopt == last_nonopt) +00589 first_nonopt = optind; +00590 last_nonopt = argc; +00591 +00592 optind = argc; +00593 } +00594 +00595 /* If we have done all the ARGV-elements, stop the scan +00596 and back over any non-options that we skipped and permuted. */ +00597 +00598 if (optind == argc) +00599 { +00600 /* Set the next-arg-index to point at the non-options +00601 that we previously skipped, so the caller will digest them. */ +00602 if (first_nonopt != last_nonopt) +00603 optind = first_nonopt; +00604 return -1; +00605 } +00606 +00607 /* If we have come to a non-option and did not permute it, +00608 either stop the scan or describe it to the caller and pass it by. */ +00609 +00610 if (NONOPTION_P) +00611 { +00612 if (ordering == REQUIRE_ORDER) +00613 return -1; +00614 optarg = argv[optind++]; +00615 return 1; +00616 } +00617 +00618 /* We have found another option-ARGV-element. +00619 Skip the initial punctuation. */ +00620 +00621 nextchar = (argv[optind] + 1 +00622 + (longopts != NULL && argv[optind][1] == '-')); +00623 } +00624 +00625 /* Decode the current option-ARGV-element. */ +00626 +00627 /* Check whether the ARGV-element is a long option. +00628 +00629 If long_only and the ARGV-element has the form "-f", where f is +00630 a valid short option, don't consider it an abbreviated form of +00631 a long option that starts with f. Otherwise there would be no +00632 way to give the -f short option. +00633 +00634 On the other hand, if there's a long option "fubar" and +00635 the ARGV-element is "-fu", do consider that an abbreviation of +00636 the long option, just like "--fu", and not "-f" with arg "u". +00637 +00638 This distinction seems to be the most useful approach. */ +00639 +00640 if (longopts != NULL +00641 && (argv[optind][1] == '-' +00642 || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) +00643 { +00644 char *nameend; +00645 const struct option *p; +00646 const struct option *pfound = NULL; +00647 int exact = 0; +00648 int ambig = 0; +00649 int indfound = -1; +00650 int option_index; +00651 +00652 for (nameend = nextchar; *nameend && *nameend != '='; nameend++) +00653 /* Do nothing. */ ; +00654 +00655 /* Test all long options for either exact match +00656 or abbreviated matches. */ +00657 for (p = longopts, option_index = 0; p->name; p++, option_index++) +00658 if (!strncmp (p->name, nextchar, nameend - nextchar)) +00659 { +00660 if ((unsigned int) (nameend - nextchar) +00661 == (unsigned int) strlen (p->name)) +00662 { +00663 /* Exact match found. */ +00664 pfound = p; +00665 indfound = option_index; +00666 exact = 1; +00667 break; +00668 } +00669 else if (pfound == NULL) +00670 { +00671 /* First nonexact match found. */ +00672 pfound = p; +00673 indfound = option_index; +00674 } +00675 else if (long_only +00676 || pfound->has_arg != p->has_arg +00677 || pfound->flag != p->flag +00678 || pfound->val != p->val) +00679 /* Second or later nonexact match found. */ +00680 ambig = 1; +00681 } +00682 +00683 if (ambig && !exact) +00684 { +00685 if (print_errors) +00686 { +00687 #if defined _LIBC && defined USE_IN_LIBIO +00688 char *buf; +00689 +00690 __asprintf (&buf, _("%s: option `%s' is ambiguous\n"), +00691 argv[0], argv[optind]); +00692 +00693 if (_IO_fwide (stderr, 0) > 0) +00694 __fwprintf (stderr, L"%s", buf); +00695 else +00696 fputs (buf, stderr); +00697 +00698 free (buf); +00699 #else +00700 fprintf (stderr, _("%s: option `%s' is ambiguous\n"), +00701 argv[0], argv[optind]); +00702 #endif +00703 } +00704 nextchar += strlen (nextchar); +00705 optind++; +00706 optopt = 0; +00707 return '?'; +00708 } +00709 +00710 if (pfound != NULL) +00711 { +00712 option_index = indfound; +00713 optind++; +00714 if (*nameend) +00715 { +00716 /* Don't test has_arg with >, because some C compilers don't +00717 allow it to be used on enums. */ +00718 if (pfound->has_arg) +00719 optarg = nameend + 1; +00720 else +00721 { +00722 if (print_errors) +00723 { +00724 #if defined _LIBC && defined USE_IN_LIBIO +00725 char *buf; +00726 #endif +00727 +00728 if (argv[optind - 1][1] == '-') +00729 { +00730 /* --option */ +00731 #if defined _LIBC && defined USE_IN_LIBIO +00732 __asprintf (&buf, _("\ +00733 %s: option `--%s' doesn't allow an argument\n"), +00734 argv[0], pfound->name); +00735 #else +00736 fprintf (stderr, _("\ +00737 %s: option `--%s' doesn't allow an argument\n"), +00738 argv[0], pfound->name); +00739 #endif +00740 } +00741 else +00742 { +00743 /* +option or -option */ +00744 #if defined _LIBC && defined USE_IN_LIBIO +00745 __asprintf (&buf, _("\ +00746 %s: option `%c%s' doesn't allow an argument\n"), +00747 argv[0], argv[optind - 1][0], +00748 pfound->name); +00749 #else +00750 fprintf (stderr, _("\ +00751 %s: option `%c%s' doesn't allow an argument\n"), +00752 argv[0], argv[optind - 1][0], pfound->name); +00753 #endif +00754 } +00755 +00756 #if defined _LIBC && defined USE_IN_LIBIO +00757 if (_IO_fwide (stderr, 0) > 0) +00758 __fwprintf (stderr, L"%s", buf); +00759 else +00760 fputs (buf, stderr); +00761 +00762 free (buf); +00763 #endif +00764 } +00765 +00766 nextchar += strlen (nextchar); +00767 +00768 optopt = pfound->val; +00769 return '?'; +00770 } +00771 } +00772 else if (pfound->has_arg == 1) +00773 { +00774 if (optind < argc) +00775 optarg = argv[optind++]; +00776 else +00777 { +00778 if (print_errors) +00779 { +00780 #if defined _LIBC && defined USE_IN_LIBIO +00781 char *buf; +00782 +00783 __asprintf (&buf, +00784 _("%s: option `%s' requires an argument\n"), +00785 argv[0], argv[optind - 1]); +00786 +00787 if (_IO_fwide (stderr, 0) > 0) +00788 __fwprintf (stderr, L"%s", buf); +00789 else +00790 fputs (buf, stderr); +00791 +00792 free (buf); +00793 #else +00794 fprintf (stderr, +00795 _("%s: option `%s' requires an argument\n"), +00796 argv[0], argv[optind - 1]); +00797 #endif +00798 } +00799 nextchar += strlen (nextchar); +00800 optopt = pfound->val; +00801 return optstring[0] == ':' ? ':' : '?'; +00802 } +00803 } +00804 nextchar += strlen (nextchar); +00805 if (longind != NULL) +00806 *longind = option_index; +00807 if (pfound->flag) +00808 { +00809 *(pfound->flag) = pfound->val; +00810 return 0; +00811 } +00812 return pfound->val; +00813 } +00814 +00815 /* Can't find it as a long option. If this is not getopt_long_only, +00816 or the option starts with '--' or is not a valid short +00817 option, then it's an error. +00818 Otherwise interpret it as a short option. */ +00819 if (!long_only || argv[optind][1] == '-' +00820 || my_index (optstring, *nextchar) == NULL) +00821 { +00822 if (print_errors) +00823 { +00824 #if defined _LIBC && defined USE_IN_LIBIO +00825 char *buf; +00826 #endif +00827 +00828 if (argv[optind][1] == '-') +00829 { +00830 /* --option */ +00831 #if defined _LIBC && defined USE_IN_LIBIO +00832 __asprintf (&buf, _("%s: unrecognized option `--%s'\n"), +00833 argv[0], nextchar); +00834 #else +00835 fprintf (stderr, _("%s: unrecognized option `--%s'\n"), +00836 argv[0], nextchar); +00837 #endif +00838 } +00839 else +00840 { +00841 /* +option or -option */ +00842 #if defined _LIBC && defined USE_IN_LIBIO +00843 __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"), +00844 argv[0], argv[optind][0], nextchar); +00845 #else +00846 fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), +00847 argv[0], argv[optind][0], nextchar); +00848 #endif +00849 } +00850 +00851 #if defined _LIBC && defined USE_IN_LIBIO +00852 if (_IO_fwide (stderr, 0) > 0) +00853 __fwprintf (stderr, L"%s", buf); +00854 else +00855 fputs (buf, stderr); +00856 +00857 free (buf); +00858 #endif +00859 } +00860 nextchar = (char *) ""; +00861 optind++; +00862 optopt = 0; +00863 return '?'; +00864 } +00865 } +00866 +00867 /* Look at and handle the next short option-character. */ +00868 +00869 { +00870 char c = *nextchar++; +00871 char *temp = my_index (optstring, c); +00872 +00873 /* Increment `optind' when we start to process its last character. */ +00874 if (*nextchar == '\0') +00875 ++optind; +00876 +00877 if (temp == NULL || c == ':') +00878 { +00879 if (print_errors) +00880 { +00881 #if defined _LIBC && defined USE_IN_LIBIO +00882 char *buf; +00883 #endif +00884 +00885 if (posixly_correct) +00886 { +00887 /* 1003.2 specifies the format of this message. */ +00888 #if defined _LIBC && defined USE_IN_LIBIO +00889 __asprintf (&buf, _("%s: illegal option -- %c\n"), +00890 argv[0], c); +00891 #else +00892 fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); +00893 #endif +00894 } +00895 else +00896 { +00897 #if defined _LIBC && defined USE_IN_LIBIO +00898 __asprintf (&buf, _("%s: invalid option -- %c\n"), +00899 argv[0], c); +00900 #else +00901 fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); +00902 #endif +00903 } +00904 +00905 #if defined _LIBC && defined USE_IN_LIBIO +00906 if (_IO_fwide (stderr, 0) > 0) +00907 __fwprintf (stderr, L"%s", buf); +00908 else +00909 fputs (buf, stderr); +00910 +00911 free (buf); +00912 #endif +00913 } +00914 optopt = c; +00915 return '?'; +00916 } +00917 /* Convenience. Treat POSIX -W foo same as long option --foo */ +00918 if (temp[0] == 'W' && temp[1] == ';') +00919 { +00920 char *nameend; +00921 const struct option *p; +00922 const struct option *pfound = NULL; +00923 int exact = 0; +00924 int ambig = 0; +00925 int indfound = 0; +00926 int option_index; +00927 +00928 /* This is an option that requires an argument. */ +00929 if (*nextchar != '\0') +00930 { +00931 optarg = nextchar; +00932 /* If we end this ARGV-element by taking the rest as an arg, +00933 we must advance to the next element now. */ +00934 optind++; +00935 } +00936 else if (optind == argc) +00937 { +00938 if (print_errors) +00939 { +00940 /* 1003.2 specifies the format of this message. */ +00941 #if defined _LIBC && defined USE_IN_LIBIO +00942 char *buf; +00943 +00944 __asprintf (&buf, _("%s: option requires an argument -- %c\n"), +00945 argv[0], c); +00946 +00947 if (_IO_fwide (stderr, 0) > 0) +00948 __fwprintf (stderr, L"%s", buf); +00949 else +00950 fputs (buf, stderr); +00951 +00952 free (buf); +00953 #else +00954 fprintf (stderr, _("%s: option requires an argument -- %c\n"), +00955 argv[0], c); +00956 #endif +00957 } +00958 optopt = c; +00959 if (optstring[0] == ':') +00960 c = ':'; +00961 else +00962 c = '?'; +00963 return c; +00964 } +00965 else +00966 /* We already incremented `optind' once; +00967 increment it again when taking next ARGV-elt as argument. */ +00968 optarg = argv[optind++]; +00969 +00970 /* optarg is now the argument, see if it's in the +00971 table of longopts. */ +00972 +00973 for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) +00974 /* Do nothing. */ ; +00975 +00976 /* Test all long options for either exact match +00977 or abbreviated matches. */ +00978 for (p = longopts, option_index = 0; p->name; p++, option_index++) +00979 if (!strncmp (p->name, nextchar, nameend - nextchar)) +00980 { +00981 if ((unsigned int) (nameend - nextchar) == strlen (p->name)) +00982 { +00983 /* Exact match found. */ +00984 pfound = p; +00985 indfound = option_index; +00986 exact = 1; +00987 break; +00988 } +00989 else if (pfound == NULL) +00990 { +00991 /* First nonexact match found. */ +00992 pfound = p; +00993 indfound = option_index; +00994 } +00995 else +00996 /* Second or later nonexact match found. */ +00997 ambig = 1; +00998 } +00999 if (ambig && !exact) +01000 { +01001 if (print_errors) +01002 { +01003 #if defined _LIBC && defined USE_IN_LIBIO +01004 char *buf; +01005 +01006 __asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), +01007 argv[0], argv[optind]); +01008 +01009 if (_IO_fwide (stderr, 0) > 0) +01010 __fwprintf (stderr, L"%s", buf); +01011 else +01012 fputs (buf, stderr); +01013 +01014 free (buf); +01015 #else +01016 fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), +01017 argv[0], argv[optind]); +01018 #endif +01019 } +01020 nextchar += strlen (nextchar); +01021 optind++; +01022 return '?'; +01023 } +01024 if (pfound != NULL) +01025 { +01026 option_index = indfound; +01027 if (*nameend) +01028 { +01029 /* Don't test has_arg with >, because some C compilers don't +01030 allow it to be used on enums. */ +01031 if (pfound->has_arg) +01032 optarg = nameend + 1; +01033 else +01034 { +01035 if (print_errors) +01036 { +01037 #if defined _LIBC && defined USE_IN_LIBIO +01038 char *buf; +01039 +01040 __asprintf (&buf, _("\ +01041 %s: option `-W %s' doesn't allow an argument\n"), +01042 argv[0], pfound->name); +01043 +01044 if (_IO_fwide (stderr, 0) > 0) +01045 __fwprintf (stderr, L"%s", buf); +01046 else +01047 fputs (buf, stderr); +01048 +01049 free (buf); +01050 #else +01051 fprintf (stderr, _("\ +01052 %s: option `-W %s' doesn't allow an argument\n"), +01053 argv[0], pfound->name); +01054 #endif +01055 } +01056 +01057 nextchar += strlen (nextchar); +01058 return '?'; +01059 } +01060 } +01061 else if (pfound->has_arg == 1) +01062 { +01063 if (optind < argc) +01064 optarg = argv[optind++]; +01065 else +01066 { +01067 if (print_errors) +01068 { +01069 #if defined _LIBC && defined USE_IN_LIBIO +01070 char *buf; +01071 +01072 __asprintf (&buf, _("\ +01073 %s: option `%s' requires an argument\n"), +01074 argv[0], argv[optind - 1]); +01075 +01076 if (_IO_fwide (stderr, 0) > 0) +01077 __fwprintf (stderr, L"%s", buf); +01078 else +01079 fputs (buf, stderr); +01080 +01081 free (buf); +01082 #else +01083 fprintf (stderr, +01084 _("%s: option `%s' requires an argument\n"), +01085 argv[0], argv[optind - 1]); +01086 #endif +01087 } +01088 nextchar += strlen (nextchar); +01089 return optstring[0] == ':' ? ':' : '?'; +01090 } +01091 } +01092 nextchar += strlen (nextchar); +01093 if (longind != NULL) +01094 *longind = option_index; +01095 if (pfound->flag) +01096 { +01097 *(pfound->flag) = pfound->val; +01098 return 0; +01099 } +01100 return pfound->val; +01101 } +01102 nextchar = NULL; +01103 return 'W'; /* Let the application handle it. */ +01104 } +01105 if (temp[1] == ':') +01106 { +01107 if (temp[2] == ':') +01108 { +01109 /* This is an option that accepts an argument optionally. */ +01110 if (*nextchar != '\0') +01111 { +01112 optarg = nextchar; +01113 optind++; +01114 } +01115 else +01116 optarg = NULL; +01117 nextchar = NULL; +01118 } +01119 else +01120 { +01121 /* This is an option that requires an argument. */ +01122 if (*nextchar != '\0') +01123 { +01124 optarg = nextchar; +01125 /* If we end this ARGV-element by taking the rest as an arg, +01126 we must advance to the next element now. */ +01127 optind++; +01128 } +01129 else if (optind == argc) +01130 { +01131 if (print_errors) +01132 { +01133 /* 1003.2 specifies the format of this message. */ +01134 #if defined _LIBC && defined USE_IN_LIBIO +01135 char *buf; +01136 +01137 __asprintf (&buf, +01138 _("%s: option requires an argument -- %c\n"), +01139 argv[0], c); +01140 +01141 if (_IO_fwide (stderr, 0) > 0) +01142 __fwprintf (stderr, L"%s", buf); +01143 else +01144 fputs (buf, stderr); +01145 +01146 free (buf); +01147 #else +01148 fprintf (stderr, +01149 _("%s: option requires an argument -- %c\n"), +01150 argv[0], c); +01151 #endif +01152 } +01153 optopt = c; +01154 if (optstring[0] == ':') +01155 c = ':'; +01156 else +01157 c = '?'; +01158 } +01159 else +01160 /* We already incremented `optind' once; +01161 increment it again when taking next ARGV-elt as argument. */ +01162 optarg = argv[optind++]; +01163 nextchar = NULL; +01164 } +01165 } +01166 return c; +01167 } +01168 } +01169 +01170 int +01171 getopt (argc, argv, optstring) +01172 int argc; +01173 char *const *argv; +01174 const char *optstring; +01175 { +01176 return _getopt_internal (argc, argv, optstring, +01177 (const struct option *) 0, +01178 (int *) 0, +01179 0); +01180 } +01181 +01182 #endif /* Not ELIDE_CODE. */ +01183 +01184 +01185 /* Compile with -DTEST to make an executable for use in testing +01186 the above definition of `getopt'. */ +01187 +01188 /* #define TEST */ /* Pete Wilson mod 7/28/02 */ +01189 #ifdef TEST +01190 +01191 #ifndef exit /* Pete Wilson mod 7/28/02 */ +01192 int exit(int); /* Pete Wilson mod 7/28/02 */ +01193 #endif /* Pete Wilson mod 7/28/02 */ +01194 +01195 int +01196 main (argc, argv) +01197 int argc; +01198 char **argv; +01199 { +01200 int c; +01201 int digit_optind = 0; +01202 +01203 while (1) +01204 { +01205 int this_option_optind = optind ? optind : 1; +01206 +01207 c = getopt (argc, argv, "abc:d:0123456789"); +01208 if (c == -1) +01209 break; +01210 +01211 switch (c) +01212 { +01213 case '0': +01214 case '1': +01215 case '2': +01216 case '3': +01217 case '4': +01218 case '5': +01219 case '6': +01220 case '7': +01221 case '8': +01222 case '9': +01223 if (digit_optind != 0 && digit_optind != this_option_optind) +01224 printf ("digits occur in two different argv-elements.\n"); +01225 digit_optind = this_option_optind; +01226 printf ("option %c\n", c); +01227 break; +01228 +01229 case 'a': +01230 printf ("option a\n"); +01231 break; +01232 +01233 case 'b': +01234 printf ("option b\n"); +01235 break; +01236 +01237 case 'c': +01238 printf ("option c with value `%s'\n", optarg); +01239 break; +01240 +01241 case '?': +01242 break; +01243 +01244 default: +01245 printf ("?? getopt returned character code 0%o ??\n", c); +01246 } +01247 } +01248 +01249 if (optind < argc) +01250 { +01251 printf ("non-option ARGV-elements: "); +01252 while (optind < argc) +01253 printf ("%s ", argv[optind++]); +01254 printf ("\n"); +01255 } +01256 +01257 exit (0); +01258 } +01259 +01260 #endif /* TEST */ +
#include <stdio.h>
#include "getopt.h"
#include <strings.h>
+Include dependency graph for getopt.c:
+Go to the source code of this file.
Defines | |
#define | GETOPT_INTERFACE_VERSION 2 |
#define | _(msgid) (msgid) |
#define | SWAP_FLAGS(ch1, ch2) |
#define | NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') |
Enumerations | |
enum | { REQUIRE_ORDER, +PERMUTE, +RETURN_IN_ORDER + } |
Functions | |
char * | getenv () |
int | _getopt_internal (int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only) |
int | getopt (int argc, char *const *argv, const char *optstring) |
Variables | |
char * | optarg |
int | optind = 1 |
int | __getopt_initialized |
int | opterr = 1 |
int | optopt = '?' |
#define _ | +( | +msgid | ++ | ) | +(msgid) | +
#define GETOPT_INTERFACE_VERSION 2 | +
#define SWAP_FLAGS | +( | +ch1, | |||
+ | + | ch2 | ++ | ) | ++ |
+
anonymous enum | +
+
int _getopt_internal | +( | +int | +argc, | +|
+ | + | char *const * | +argv, | +|
+ | + | const char * | +optstring, | +|
+ | + | const struct option * | +longopts, | +|
+ | + | int * | +longind, | +|
+ | + | int | +long_only | + |
+ | ) | ++ |
+ +
+Definition at line 511 of file getopt.c. +
+References __getopt_initialized, option::name, NONOPTION_P, optarg, opterr, optind, PERMUTE, and REQUIRE_ORDER. +
char* getenv | +( | ++ | ) | ++ |
+ +
int getopt | +( | +int | +argc, | +|
+ | + | char *const * | +argv, | +|
+ | + | const char * | +optstring | + |
+ | ) | ++ |
+ +
+Definition at line 1171 of file getopt.c. +
+References _getopt_internal(). +
+Here is the call graph for this function:
+
int __getopt_initialized | +
+
00001 /* from http://www.pwilson.net/getopt.html */ +00002 +00003 /* getopt.h */ +00004 /* Declarations for getopt. +00005 Copyright (C) 1989-1994, 1996-1999, 2001 Free Software +00006 Foundation, Inc. This file is part of the GNU C Library. +00007 +00008 The GNU C Library is free software; you can redistribute +00009 it and/or modify it under the terms of the GNU Lesser +00010 General Public License as published by the Free Software +00011 Foundation; either version 2.1 of the License, or +00012 (at your option) any later version. +00013 +00014 The GNU C Library is distributed in the hope that it will +00015 be useful, but WITHOUT ANY WARRANTY; without even the +00016 implied warranty of MERCHANTABILITY or FITNESS FOR A +00017 PARTICULAR PURPOSE. See the GNU Lesser General Public +00018 License for more details. +00019 +00020 You should have received a copy of the GNU Lesser General +00021 Public License along with the GNU C Library; if not, write +00022 to the Free Software Foundation, Inc., 59 Temple Place, +00023 Suite 330, Boston, MA 02111-1307 USA. */ +00024 +00025 +00026 +00027 +00028 +00029 #ifndef _GETOPT_H +00030 +00031 #ifndef __need_getopt +00032 # define _GETOPT_H 1 +00033 #endif +00034 +00035 /* If __GNU_LIBRARY__ is not already defined, either we are being used +00036 standalone, or this is the first header included in the source file. +00037 If we are being used with glibc, we need to include <features.h>, but +00038 that does not exist if we are standalone. So: if __GNU_LIBRARY__ is +00039 not defined, include <ctype.h>, which will pull in <features.h> for us +00040 if it's from glibc. (Why ctype.h? It's guaranteed to exist and it +00041 doesn't flood the namespace with stuff the way some other headers do.) */ +00042 #if !defined __GNU_LIBRARY__ +00043 # include <ctype.h> +00044 #endif +00045 +00046 #ifdef __cplusplus +00047 extern "C" { +00048 #endif +00049 +00050 /* For communication from `getopt' to the caller. +00051 When `getopt' finds an option that takes an argument, +00052 the argument value is returned here. +00053 Also, when `ordering' is RETURN_IN_ORDER, +00054 each non-option ARGV-element is returned here. */ +00055 +00056 extern char *optarg; +00057 +00058 /* Index in ARGV of the next element to be scanned. +00059 This is used for communication to and from the caller +00060 and for communication between successive calls to `getopt'. +00061 +00062 On entry to `getopt', zero means this is the first call; initialize. +00063 +00064 When `getopt' returns -1, this is the index of the first of the +00065 non-option elements that the caller should itself scan. +00066 +00067 Otherwise, `optind' communicates from one call to the next +00068 how much of ARGV has been scanned so far. */ +00069 +00070 extern int optind; +00071 +00072 /* Callers store zero here to inhibit the error message `getopt' prints +00073 for unrecognized options. */ +00074 +00075 extern int opterr; +00076 +00077 /* Set to an option character which was unrecognized. */ +00078 +00079 extern int optopt; +00080 +00081 #ifndef __need_getopt +00082 /* Describe the long-named options requested by the application. +00083 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector +00084 of `struct option' terminated by an element containing a name which is +00085 zero. +00086 +00087 The field `has_arg' is: +00088 no_argument (or 0) if the option does not take an argument, +00089 required_argument (or 1) if the option requires an argument, +00090 optional_argument (or 2) if the option takes an optional argument. +00091 +00092 If the field `flag' is not NULL, it points to a variable that is set +00093 to the value given in the field `val' when the option is found, but +00094 left unchanged if the option is not found. +00095 +00096 To have a long-named option do something other than set an `int' to +00097 a compiled-in constant, such as set a value from `optarg', set the +00098 option's `flag' field to zero and its `val' field to a nonzero +00099 value (the equivalent single-letter option character, if there is +00100 one). For long options that have a zero `flag' field, `getopt' +00101 returns the contents of the `val' field. */ +00102 +00103 struct option +00104 { +00105 # if (defined __STDC__ && __STDC__) || defined __cplusplus +00106 const char *name; +00107 # else +00108 char *name; +00109 # endif +00110 /* has_arg can't be an enum because some compilers complain about +00111 type mismatches in all the code that assumes it is an int. */ +00112 int has_arg; +00113 int *flag; +00114 int val; +00115 }; +00116 +00117 /* Names for the values of the `has_arg' field of `struct option'. */ +00118 +00119 # define no_argument 0 +00120 # define required_argument 1 +00121 # define optional_argument 2 +00122 #endif /* need getopt */ +00123 +00124 +00125 /* Get definitions and prototypes for functions to process the +00126 arguments in ARGV (ARGC of them, minus the program name) for +00127 options given in OPTS. +00128 +00129 Return the option character from OPTS just read. Return -1 when +00130 there are no more options. For unrecognized options, or options +00131 missing arguments, `optopt' is set to the option letter, and '?' is +00132 returned. +00133 +00134 The OPTS string is a list of characters which are recognized option +00135 letters, optionally followed by colons, specifying that that letter +00136 takes an argument, to be placed in `optarg'. +00137 +00138 If a letter in OPTS is followed by two colons, its argument is +00139 optional. This behavior is specific to the GNU `getopt'. +00140 +00141 The argument `--' causes premature termination of argument +00142 scanning, explicitly telling `getopt' that there are no more +00143 options. +00144 +00145 If OPTS begins with `--', then non-option arguments are treated as +00146 arguments to the option '\0'. This behavior is specific to the GNU +00147 `getopt'. */ +00148 +00149 #if (defined __STDC__ && __STDC__) || defined __cplusplus +00150 # ifdef __GNU_LIBRARY__ +00151 /* Many other libraries have conflicting prototypes for getopt, with +00152 differences in the consts, in stdlib.h. To avoid compilation +00153 errors, only prototype getopt for the GNU C library. */ +00154 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); +00155 # else /* not __GNU_LIBRARY__ */ +00156 extern int getopt (); +00157 # endif /* __GNU_LIBRARY__ */ +00158 +00159 # ifndef __need_getopt +00160 extern int getopt_long (int ___argc, char *const *___argv, +00161 const char *__shortopts, +00162 const struct option *__longopts, int *__longind); +00163 extern int getopt_long_only (int ___argc, char *const *___argv, +00164 const char *__shortopts, +00165 const struct option *__longopts, int *__longind); +00166 +00167 /* Internal only. Users should not call this directly. */ +00168 extern int _getopt_internal (int ___argc, char *const *___argv, +00169 const char *__shortopts, +00170 const struct option *__longopts, int *__longind, +00171 int __long_only); +00172 # endif +00173 #else /* not __STDC__ */ +00174 extern int getopt (); +00175 # ifndef __need_getopt +00176 extern int getopt_long (); +00177 extern int getopt_long_only (); +00178 +00179 extern int _getopt_internal (); +00180 # endif +00181 #endif /* __STDC__ */ +00182 +00183 #ifdef __cplusplus +00184 } +00185 #endif +00186 +00187 /* Make sure we later can get all the definitions and declarations. */ +00188 #undef __need_getopt +00189 +00190 #endif /* getopt.h */ +00191 +
#include <ctype.h>
+Include dependency graph for getopt.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Data Structures | |
struct | option |
Defines | |
#define | _GETOPT_H 1 |
#define | no_argument 0 |
#define | required_argument 1 |
#define | optional_argument 2 |
Functions | |
int | getopt () |
int | getopt_long () |
int | getopt_long_only () |
int | _getopt_internal () |
Variables | |
char * | optarg |
int | optind |
int | opterr |
int | optopt |
+
int _getopt_internal | +( | ++ | ) | ++ |
+ +
int getopt | +( | ++ | ) | ++ |
+ +
int getopt_long | +( | ++ | ) | ++ |
+ +
int getopt_long_only | +( | ++ | ) | ++ |
+ +
+
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #if defined(WIN32) && !defined(__CYGWIN__) +00024 #include <windows.h> +00025 #include "getopt.h" +00026 void pause(void) +00027 { +00028 system("PAUSE"); +00029 } +00030 #else +00031 #include <unistd.h> +00032 #include <stdio.h> +00033 #include <string.h> +00034 #include <stdlib.h> +00035 #include <signal.h> +00036 #endif +00037 +00038 #include "canfestival.h" +00039 #include "TestMasterMicroMod.h" +00040 #include "TestMaster.h" +00041 UNS8 slavenodeid; +00042 +00043 +00044 /*****************************************************************************/ +00045 void TestMaster_heartbeatError(UNS8 heartbeatID) +00046 { +00047 eprintf("TestMaster_heartbeatError %d\n", heartbeatID); +00048 } +00049 +00050 /******************************************************** +00051 * ConfigureSlaveNode is responsible to +00052 * - setup master RPDO 1 to receive TPDO 1 from id 0x40 +00053 * - setup master TPDO 1 to send RPDO 1 to id 0x40 +00054 ********************************************************/ +00055 void TestMaster_initialisation() +00056 { +00057 UNS32 PDO1_COBID = 0x0180 + slavenodeid; +00058 UNS32 PDO2_COBID = 0x0200 + slavenodeid; +00059 UNS8 size = sizeof(UNS32); +00060 +00061 eprintf("TestMaster_initialisation\n"); +00062 +00063 /***************************************** +00064 * Define RPDOs to match slave ID=0x40 TPDOs* +00065 *****************************************/ +00066 writeLocalDict( &TestMaster_Data, /*CO_Data* d*/ +00067 0x1400, /*UNS16 index*/ +00068 0x01, /*UNS8 subind*/ +00069 &PDO1_COBID, /*void * pSourceData,*/ +00070 &size, /* UNS8 * pExpectedSize*/ +00071 RW); /* UNS8 checkAccess */ +00072 +00073 +00074 /***************************************** +00075 * Define TPDOs to match slave ID=0x40 RPDOs* +00076 *****************************************/ +00077 writeLocalDict( &TestMaster_Data, /*CO_Data* d*/ +00078 0x1800, /*UNS16 index*/ +00079 0x01, /*UNS8 subind*/ +00080 &PDO2_COBID, /*void * pSourceData,*/ +00081 &size, /* UNS8 * pExpectedSize*/ +00082 RW); /* UNS8 checkAccess */ +00083 } +00084 +00085 static init_step = 0; +00086 +00087 /*Froward declaration*/ +00088 static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId); +00089 +00090 +00091 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId) +00092 { +00093 UNS32 abortCode; +00094 +00095 if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED) +00096 eprintf("Master : Failed in initializing slave %2.2x, step %d, AbortCode :%4.4x \n", nodeId, init_step, abortCode); +00097 +00098 /* Finalise last SDO transfer with this node */ +00099 closeSDOtransfer(&TestMaster_Data, nodeId, SDO_CLIENT); +00100 +00101 ConfigureSlaveNode(d, nodeId); +00102 } +00103 +00104 /******************************************************** +00105 * ConfigureSlaveNode is responsible to +00106 * - setup slave TPDO 1 transmit time +00107 * - setup slave TPDO 2 transmit time +00108 * - setup slave Heartbeat Producer time +00109 * - switch to operational mode +00110 * - send NMT to slave +00111 ******************************************************** +00112 * This an example of : +00113 * Network Dictionary Access (SDO) with Callback +00114 * Slave node state change request (NMT) +00115 ******************************************************** +00116 * This is called first by TestMaster_preOperational +00117 * then it called again each time a SDO exchange is +00118 * finished. +00119 ********************************************************/ +00120 static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId) +00121 { +00122 UNS8 res; +00123 eprintf("Master : ConfigureSlaveNode %2.2x\n", nodeId); +00124 switch(++init_step){ +00125 case 1: +00126 { /*disable Slave's TPDO 1 */ +00127 UNS32 TPDO_COBId = 0x80000180 + nodeId; +00128 +00129 eprintf("Master : disable slave %2.2x TPDO 1 \n", nodeId); +00130 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00132 nodeId, /*UNS8 nodeId*/ +00133 0x1800, /*UNS16 index*/ +00134 0x01, /*UNS8 subindex*/ +00135 4, /*UNS8 count*/ +00136 0, /*UNS8 dataType*/ +00137 &TPDO_COBId,/*void *data*/ +00138 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00139 } +00140 break; +00141 +00142 case 2: +00143 { /*setup Slave's TPDO 1 to be transmitted on SYNC*/ +00144 UNS8 Transmission_Type = 0x01; +00145 +00146 eprintf("Master : set slave %2.2x TPDO 1 transmit type\n", nodeId); +00147 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00149 nodeId, /*UNS8 nodeId*/ +00150 0x1800, /*UNS16 index*/ +00151 0x02, /*UNS8 subindex*/ +00152 1, /*UNS8 count*/ +00153 0, /*UNS8 dataType*/ +00154 &Transmission_Type,/*void *data*/ +00155 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00156 } +00157 break; +00158 +00159 case 3: +00160 { /*re-enable Slave's TPDO 1 */ +00161 UNS32 TPDO_COBId = 0x00000180 + nodeId; +00162 +00163 eprintf("Master : re-enable slave %2.2x TPDO 1\n", nodeId); +00164 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00166 nodeId, /*UNS8 nodeId*/ +00167 0x1800, /*UNS16 index*/ +00168 0x01, /*UNS8 subindex*/ +00169 4, /*UNS8 count*/ +00170 0, /*UNS8 dataType*/ +00171 &TPDO_COBId,/*void *data*/ +00172 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00173 } +00174 break; +00175 +00176 case 4: +00177 { /*disable Slave's TPDO 2 */ +00178 UNS32 TPDO_COBId = 0x80000200 + nodeId; +00179 +00180 eprintf("Master : disable slave %2.2x RPDO 1\n", nodeId); +00181 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00183 nodeId, /*UNS8 nodeId*/ +00184 0x1400, /*UNS16 index*/ +00185 0x01, /*UNS8 subindex*/ +00186 4, /*UNS8 count*/ +00187 0, /*UNS8 dataType*/ +00188 &TPDO_COBId,/*void *data*/ +00189 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00190 } +00191 break; +00192 +00193 +00194 case 5: +00195 { +00196 UNS8 Transmission_Type = 0x01; +00197 +00198 eprintf("Master : set slave %2.2x RPDO 1 receive type\n", nodeId); +00199 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00201 nodeId, /*UNS8 nodeId*/ +00202 0x1400, /*UNS16 index*/ +00203 0x02, /*UNS8 subindex*/ +00204 1, /*UNS8 count*/ +00205 0, /*UNS8 dataType*/ +00206 &Transmission_Type,/*void *data*/ +00207 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00208 } +00209 break; +00210 +00211 case 6: +00212 { /*re-enable Slave's TPDO 1 */ +00213 UNS32 TPDO_COBId = 0x00000200 + nodeId; +00214 +00215 eprintf("Master : re-enable %2.2x RPDO 1\n", nodeId); +00216 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00218 nodeId, /*UNS8 nodeId*/ +00219 0x1400, /*UNS16 index*/ +00220 0x01, /*UNS8 subindex*/ +00221 4, /*UNS8 count*/ +00222 0, /*UNS8 dataType*/ +00223 &TPDO_COBId,/*void *data*/ +00224 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00225 } +00226 break; +00227 +00228 case 7: +00229 { +00230 UNS16 Heartbeat_Producer_Time = 0x03E8; +00231 eprintf("Master : set slave %2.2x heartbeat producer time \n", nodeId); +00232 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00234 nodeId, /*UNS8 nodeId*/ +00235 0x1017, /*UNS16 index*/ +00236 0x00, /*UNS8 subindex*/ +00237 2, /*UNS8 count*/ +00238 0, /*UNS8 dataType*/ +00239 &Heartbeat_Producer_Time,/*void *data*/ +00240 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00241 } +00242 break; +00243 +00244 case 8: +00245 { /*disable Slave's TPDO 2 */ +00246 UNS32 TPDO_COBId = 0x80000280 + nodeId; +00247 +00248 eprintf("Master : disable slave %2.2x TPDO 2 \n", nodeId); +00249 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00251 nodeId, /*UNS8 nodeId*/ +00252 0x1801, /*UNS16 index*/ +00253 0x01, /*UNS8 subindex*/ +00254 4, /*UNS8 count*/ +00255 0, /*UNS8 dataType*/ +00256 &TPDO_COBId,/*void *data*/ +00257 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00258 } +00259 break; +00260 +00261 case 9: +00262 { /*disable Slave's TPDO 3 */ +00263 UNS32 TPDO_COBId = 0x80000380 + nodeId; +00264 +00265 eprintf("Master : disable slave %2.2x TPDO 3 \n", nodeId); +00266 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00268 nodeId, /*UNS8 nodeId*/ +00269 0x1802, /*UNS16 index*/ +00270 0x01, /*UNS8 subindex*/ +00271 4, /*UNS8 count*/ +00272 0, /*UNS8 dataType*/ +00273 &TPDO_COBId,/*void *data*/ +00274 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00275 } +00276 break; +00277 +00278 case 10: +00279 { /*disable Slave's TPDO 2 */ +00280 UNS32 TPDO_COBId = 0x80000480 + nodeId; +00281 +00282 eprintf("Master : disable slave %2.2x TPDO 4 \n", nodeId); +00283 res = writeNetworkDictCallBack (d, /*CO_Data* d*/ +00285 nodeId, /*UNS8 nodeId*/ +00286 0x1803, /*UNS16 index*/ +00287 0x01, /*UNS8 subindex*/ +00288 4, /*UNS8 count*/ +00289 0, /*UNS8 dataType*/ +00290 &TPDO_COBId,/*void *data*/ +00291 CheckSDOAndContinue); /*SDOCallback_t Callback*/ +00292 } +00293 break; +00294 +00295 case 11: +00296 /* Put the master in operational mode */ +00297 setState(d, Operational); +00298 +00299 /* Ask slave node to go in operational mode */ +00300 masterSendNMTstateChange (d, nodeId, NMT_Start_Node); +00301 } +00302 +00303 } +00304 +00305 void TestMaster_preOperational() +00306 { +00307 +00308 eprintf("TestMaster_preOperational\n"); +00309 ConfigureSlaveNode(&TestMaster_Data, slavenodeid); +00310 +00311 } +00312 +00313 void TestMaster_operational() +00314 { +00315 eprintf("TestMaster_operational\n"); +00316 } +00317 +00318 void TestMaster_stopped() +00319 { +00320 eprintf("TestMaster_stopped\n"); +00321 } +00322 +00323 void TestMaster_post_sync() +00324 { +00325 DO++; +00326 eprintf("MicroMod Digital Out: %2.2x\n",DO); +00327 eprintf("MicroMod Digital In (by bit): DI1: %2.2x DI2: %2.2x DI3: %2.2x DI4: %2.2x DI5: %2.2x DI6: %2.2x DI7: %2.2x DI8: %2.2x\n",DI1,DI2,DI3,DI4,DI5,DI6,DI7,DI8); +00328 } +00329 +00330 void TestMaster_post_TPDO() +00331 { +00332 // eprintf("TestMaster_post_TPDO\n"); +00333 } +00334 +00335 //s_BOARD SlaveBoard = {"0", "500K"}; +00336 s_BOARD MasterBoard = {"32", "125K"}; +00337 +00338 #if !defined(WIN32) || defined(__CYGWIN__) +00339 void catch_signal(int sig) +00340 { +00341 signal(SIGTERM, catch_signal); +00342 signal(SIGINT, catch_signal); +00343 +00344 eprintf("Got Signal %d\n",sig); +00345 } +00346 #endif +00347 +00348 void help() +00349 { +00350 printf("**************************************************************\n"); +00351 printf("* TestMasterMicroMod *\n"); +00352 printf("* *\n"); +00353 printf("* A simple example for PC. *\n"); +00354 printf("* A CanOpen master that control a MicroMod module: *\n"); +00355 printf("* - setup module TPDO 1 transmit type *\n"); +00356 printf("* - setup module RPDO 1 transmit type *\n"); +00357 printf("* - setup module hearbeatbeat period *\n"); +00358 printf("* - disable others TPDOs *\n"); +00359 printf("* - set state to operational *\n"); +00360 printf("* - send periodic SYNC *\n"); +00361 printf("* - send periodic RPDO 1 to Micromod (digital output) *\n"); +00362 printf("* - listen Micromod's TPDO 1 (digital input) *\n"); +00363 printf("* - Mapping RPDO 1 bit per bit (digital input) *\n"); +00364 printf("* *\n"); +00365 printf("* Usage: *\n"); +00366 printf("* ./TestMasterMicroMod [OPTIONS] *\n"); +00367 printf("* *\n"); +00368 printf("* OPTIONS: *\n"); +00369 printf("* -l : Can library [\"libcanfestival_can_virtual.so\"] *\n"); +00370 printf("* *\n"); +00371 printf("* Slave: *\n"); +00372 printf("* -i : Slave Node id format [0x01 , 0x7F] *\n"); +00373 printf("* *\n"); +00374 printf("* Master: *\n"); +00375 printf("* -m : bus name [\"1\"] *\n"); +00376 printf("* -M : 1M,500K,250K,125K,100K,50K,20K,10K *\n"); +00377 printf("* *\n"); +00378 printf("**************************************************************\n"); +00379 } +00380 +00381 /*************************** INIT *****************************************/ +00382 void InitNodes(CO_Data* d, UNS32 id) +00383 { +00384 /****************************** INITIALISATION MASTER *******************************/ +00385 if(MasterBoard.baudrate){ +00386 /* Defining the node Id */ +00387 setNodeId(&TestMaster_Data, 0x01); +00388 +00389 /* init */ +00390 setState(&TestMaster_Data, Initialisation); +00391 } +00392 } +00393 +00394 /****************************************************************************/ +00395 /*************************** MAIN *****************************************/ +00396 /****************************************************************************/ +00397 int main(int argc,char **argv) +00398 { +00399 +00400 int c; +00401 extern char *optarg; +00402 char* LibraryPath="libcanfestival_can_virtual.so"; +00403 char *snodeid; +00404 while ((c = getopt(argc, argv, "-m:s:M:S:l:i:")) != EOF) +00405 { +00406 switch(c) +00407 { +00408 case 'm' : +00409 if (optarg[0] == 0) +00410 { +00411 help(); +00412 exit(1); +00413 } +00414 MasterBoard.busname = optarg; +00415 break; +00416 case 'M' : +00417 if (optarg[0] == 0) +00418 { +00419 help(); +00420 exit(1); +00421 } +00422 MasterBoard.baudrate = optarg; +00423 break; +00424 case 'l' : +00425 if (optarg[0] == 0) +00426 { +00427 help(); +00428 exit(1); +00429 } +00430 LibraryPath = optarg; +00431 break; +00432 case 'i' : +00433 if (optarg[0] == 0) +00434 { +00435 help(); +00436 exit(1); +00437 } +00438 snodeid = optarg; +00439 sscanf(snodeid,"%x",&slavenodeid); +00440 break; +00441 default: +00442 help(); +00443 exit(1); +00444 } +00445 } +00446 +00447 #if !defined(WIN32) || defined(__CYGWIN__) +00448 /* install signal handler for manual break */ +00449 signal(SIGTERM, catch_signal); +00450 signal(SIGINT, catch_signal); +00451 #endif +00452 +00453 #ifndef NOT_USE_DYNAMIC_LOADING +00454 LoadCanDriver(LibraryPath); +00455 #endif +00456 +00457 TestMaster_Data.heartbeatError = TestMaster_heartbeatError; +00458 TestMaster_Data.initialisation = TestMaster_initialisation; +00459 TestMaster_Data.preOperational = TestMaster_preOperational; +00460 TestMaster_Data.operational = TestMaster_operational; +00461 TestMaster_Data.stopped = TestMaster_stopped; +00462 TestMaster_Data.post_sync = TestMaster_post_sync; +00463 TestMaster_Data.post_TPDO = TestMaster_post_TPDO; +00464 +00465 if(!canOpen(&MasterBoard,&TestMaster_Data)){ +00466 eprintf("Cannot open Master Board\n"); +00467 goto fail_master; +00468 } +00469 +00470 // Start timer thread +00471 StartTimerLoop(&InitNodes); +00472 +00473 // wait Ctrl-C +00474 pause(); +00475 eprintf("Finishing.\n"); +00476 +00477 // Reset the slave node for next use (will stop emitting heartbeat) +00478 masterSendNMTstateChange (&TestMaster_Data, slavenodeid, NMT_Reset_Node); +00479 +00480 // Stop master +00481 setState(&TestMaster_Data, Stopped); +00482 +00483 // Stop timer thread +00484 StopTimerLoop(); +00485 +00486 fail_master: +00487 if(MasterBoard.baudrate) canClose(&TestMaster_Data); +00488 +00489 return 0; +00490 } +00491 +00492 +
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include "canfestival.h"
#include "TestMasterMicroMod.h"
#include "TestMaster.h"
+Include dependency graph for TestMasterMicroMod.c:
+Go to the source code of this file.
Functions | |
void | TestMaster_heartbeatError (UNS8 heartbeatID) |
void | TestMaster_initialisation () |
void | TestMaster_preOperational () |
void | TestMaster_operational () |
void | TestMaster_stopped () |
void | TestMaster_post_sync () |
void | TestMaster_post_TPDO () |
void | catch_signal (int sig) |
void | help () |
void | InitNodes (CO_Data *d, UNS32 id) |
int | main (int argc, char **argv) |
Variables | |
UNS8 | slavenodeid |
s_BOARD | MasterBoard = {"32", "125K"} |
void catch_signal | +( | +int | +sig | +) | ++ |
+ +
+Definition at line 339 of file TestMasterMicroMod.c. +
+References catch_signal(), and eprintf. +
+Here is the call graph for this function:
void help | +( | ++ | ) | ++ |
+ +
+Definition at line 348 of file TestMasterMicroMod.c. +
void InitNodes | +( | +CO_Data * | +d, | +|
+ | + | UNS32 | +id | + |
+ | ) | ++ |
+ +
+Definition at line 382 of file TestMasterMicroMod.c. +
+References struct_s_BOARD::baudrate, Initialisation, MasterBoard, setNodeId(), setState(), and TestMaster_Data. +
+Here is the call graph for this function:
int main | +( | +int | +argc, | +|
+ | + | char ** | +argv | + |
+ | ) | ++ |
+ +
+Definition at line 397 of file TestMasterMicroMod.c. +
+References struct_s_BOARD::baudrate, struct_s_BOARD::busname, canClose(), canOpen(), catch_signal(), eprintf, getopt(), struct_CO_Data::heartbeatError, help(), struct_CO_Data::initialisation, InitNodes(), LoadCanDriver(), MasterBoard, masterSendNMTstateChange(), NMT_Reset_Node, struct_CO_Data::operational, optarg, struct_CO_Data::post_sync, struct_CO_Data::post_TPDO, struct_CO_Data::preOperational, setState(), slavenodeid, StartTimerLoop(), Stopped, struct_CO_Data::stopped, StopTimerLoop(), TestMaster_Data, TestMaster_heartbeatError(), TestMaster_initialisation(), TestMaster_operational(), TestMaster_post_sync(), TestMaster_post_TPDO(), TestMaster_preOperational(), and TestMaster_stopped(). +
+Here is the call graph for this function:
void TestMaster_heartbeatError | +( | +UNS8 | +heartbeatID | +) | ++ |
void TestMaster_initialisation | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 55 of file TestMasterMicroMod.c. +
+References eprintf, RW, slavenodeid, TestMaster_Data, UNS32, UNS8, and writeLocalDict(). +
+Here is the call graph for this function:
void TestMaster_operational | +( | +void | ++ | ) | ++ |
void TestMaster_post_sync | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 323 of file TestMasterMicroMod.c. +
+References DI1, DI2, DI3, DI4, DI5, DI6, DI7, DI8, DO, eprintf, MasterMap1, MasterMap10, MasterMap11, MasterMap2, MasterMap3, MasterMap4, MasterMap5, MasterMap6, MasterMap7, MasterMap8, and MasterMap9. +
void TestMaster_post_TPDO | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 330 of file TestMasterMicroMod.c. +
+References closeSDOtransfer(), eprintf, getReadResultNetworkDict(), MasterMap1, readNetworkDict(), SDO_ABORTED_INTERNAL, SDO_ABORTED_RCV, SDO_CLIENT, SDO_DOWNLOAD_IN_PROGRESS, SDO_FINISHED, SDO_RESET, SDO_UPLOAD_IN_PROGRESS, TestMaster_Data, UNS32, and UNS8. +
+Here is the call graph for this function:
void TestMaster_preOperational | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 305 of file TestMasterMicroMod.c. +
+References eprintf, slavenodeid, and TestMaster_Data. +
void TestMaster_stopped | +( | +void | ++ | ) | ++ |
+
s_BOARD MasterBoard = {"32", "125K"} | +
+ +
+Definition at line 336 of file TestMasterMicroMod.c. +
UNS8 slavenodeid | +
+ +
+Definition at line 41 of file TestMasterMicroMod.c. +
+Referenced by main(), TestMaster_initialisation(), and TestMaster_preOperational(). +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 #ifdef USE_XENO +00023 #define eprintf(...) +00024 #else +00025 #define eprintf(...) printf (__VA_ARGS__) +00026 #endif +00027 //void print_message(Message *m); +00028 +00029 /*UNS8 canSend(CAN_HANDLE fd0, Message *m);*/ +00030 +00031 #include "canfestival.h" +00032 +00033 /* +00034 #define CAN_FIFO_LENGTH 100 +00035 +00036 #define DECLARE_A_CAN_FIFO \ +00037 static Message FIFO[CAN_FIFO_LENGTH];\ +00038 static int FIFO_First = 0;\ +00039 static int FIFO_Last = 0;\ +00040 \ +00041 static void PutInFIFO(Message *m)\ +00042 {\ +00043 FIFO[FIFO_Last++] = *m;\ +00044 FIFO_Last %= CAN_FIFO_LENGTH;\ +00045 }\ +00046 \ +00047 static void GetFromFIFO(Message *m)\ +00048 {\ +00049 *m = FIFO[FIFO_First++];\ +00050 FIFO_First %= CAN_FIFO_LENGTH;\ +00051 }\ +00052 \ +00053 static void TransmitMessage(CO_Data* d, UNS32 id)\ +00054 {\ +00055 Message m;\ +00056 GetFromFIFO(&m);\ +00057 canDispatch(d, &m);\ +00058 } +00059 */ +
#include "canfestival.h"
+Include dependency graph for TestMasterMicroMod.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Defines | |
#define | eprintf(...) printf (__VA_ARGS__) |
#define eprintf | +( | +... | ++ | ) | +printf (__VA_ARGS__) | +
+ +
+Definition at line 25 of file TestMasterMicroMod.h. +
+
00001 +00002 /* File generated by gen_cfile.py. Should not be modified. */ +00003 +00004 #include "TestMaster.h" +00005 +00006 /**************************************************************************/ +00007 /* Declaration of the mapped variables */ +00008 /**************************************************************************/ +00009 UNS8 MasterMap1 = 0x0; /* Mapped at index 0x2000, subindex 0x00 */ +00010 UNS8 MasterMap2 = 0x0; /* Mapped at index 0x2001, subindex 0x00 */ +00011 UNS8 MasterMap3 = 0x0; /* Mapped at index 0x2002, subindex 0x00 */ +00012 UNS8 MasterMap4 = 0x0; /* Mapped at index 0x2003, subindex 0x00 */ +00013 UNS8 MasterMap5 = 0x0; /* Mapped at index 0x2004, subindex 0x00 */ +00014 UNS8 MasterMap6 = 0x0; /* Mapped at index 0x2005, subindex 0x00 */ +00015 UNS8 MasterMap7 = 0x0; /* Mapped at index 0x2006, subindex 0x00 */ +00016 UNS8 MasterMap8 = 0x0; /* Mapped at index 0x2007, subindex 0x00 */ +00017 UNS8 MasterMap9 = 0x0; /* Mapped at index 0x2008, subindex 0x00 */ +00018 UNS32 MasterMap10 = 0x0; /* Mapped at index 0x2009, subindex 0x00 */ +00019 UNS16 MasterMap11 = 0x0; /* Mapped at index 0x200A, subindex 0x00 */ +00020 +00021 /**************************************************************************/ +00022 /* Declaration of the value range types */ +00023 /**************************************************************************/ +00024 +00025 UNS32 TestMaster_valueRangeTest (UNS8 typeValue, void * value) +00026 { +00027 switch (typeValue) { +00028 } +00029 return 0; +00030 } +00031 +00032 /**************************************************************************/ +00033 /* The node id */ +00034 /**************************************************************************/ +00035 /* node_id default value.*/ +00036 UNS8 TestMaster_bDeviceNodeId = 0x01; +00037 +00038 /**************************************************************************/ +00039 /* Array of message processing information */ +00040 +00041 const UNS8 TestMaster_iam_a_slave = 0; +00042 +00043 TIMER_HANDLE TestMaster_heartBeatTimers[1] = {TIMER_NONE,}; +00044 +00045 /* +00046 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +00047 +00048 OBJECT DICTIONARY +00049 +00050 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +00051 */ +00052 +00053 /* index 0x1000 : Device Type. */ +00054 UNS32 TestMaster_obj1000 = 0x12D; /* 301 */ +00055 subindex TestMaster_Index1000[] = +00056 { +00057 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1000 } +00058 }; +00059 +00060 /* index 0x1001 : Error Register. */ +00061 UNS8 TestMaster_obj1001 = 0x0; /* 0 */ +00062 subindex TestMaster_Index1001[] = +00063 { +00064 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_obj1001 } +00065 }; +00066 +00067 /* index 0x1005 : SYNC COB ID. */ +00068 UNS32 TestMaster_obj1005 = 0x40000080; /* 1073741952 */ +00069 ODCallback_t TestMaster_Index1005_callbacks[] = +00070 { +00071 NULL, +00072 }; +00073 subindex TestMaster_Index1005[] = +00074 { +00075 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1005 } +00076 }; +00077 +00078 /* index 0x1006 : Communication / Cycle Period. */ +00079 UNS32 TestMaster_obj1006 = 0xC350; /* 50000 */ +00080 ODCallback_t TestMaster_Index1006_callbacks[] = +00081 { +00082 NULL, +00083 }; +00084 subindex TestMaster_Index1006[] = +00085 { +00086 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1006 } +00087 }; +00088 +00089 /* index 0x1010 : Store parameters. */ +00090 UNS8 TestMaster_highestSubIndex_obj1010 = 4; /* number of subindex - 1*/ +00091 UNS32 TestMaster_obj1010_Save_All_Parameters = 0x0; /* 0 */ +00092 UNS32 TestMaster_obj1010_Save_Communication_Parameters = 0x0; /* 0 */ +00093 UNS32 TestMaster_obj1010_Save_Application_Parameters = 0x0; /* 0 */ +00094 UNS32 TestMaster_obj1010_Save_Manufacturer_Parameters = 0x0; /* 0 */ +00095 subindex TestMaster_Index1010[] = +00096 { +00097 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1010 }, +00098 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_All_Parameters }, +00099 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Communication_Parameters }, +00100 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Application_Parameters }, +00101 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Manufacturer_Parameters } +00102 }; +00103 +00104 /* index 0x1011 : Restore Default Parameters. */ +00105 UNS8 TestMaster_highestSubIndex_obj1011 = 4; /* number of subindex - 1*/ +00106 UNS32 TestMaster_obj1011_Restore_All_Default_Parameters = 0x0; /* 0 */ +00107 UNS32 TestMaster_obj1011_Restore_Communication_Default_Parameters = 0x0; /* 0 */ +00108 UNS32 TestMaster_obj1011_Restore_Application_Default_Parameters = 0x0; /* 0 */ +00109 UNS32 TestMaster_obj1011_Restore_Manufacturer_Default_Parameters = 0x0; /* 0 */ +00110 subindex TestMaster_Index1011[] = +00111 { +00112 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1011 }, +00113 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_All_Default_Parameters }, +00114 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Communication_Default_Parameters }, +00115 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Application_Default_Parameters }, +00116 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Manufacturer_Default_Parameters } +00117 }; +00118 +00119 /* index 0x1016 : Consumer Heartbeat Time. */ +00120 UNS8 TestMaster_highestSubIndex_obj1016 = 1; /* number of subindex - 1*/ +00121 UNS32 TestMaster_obj1016[] = +00122 { +00123 0x205DC /* 132572 */ +00124 }; +00125 subindex TestMaster_Index1016[] = +00126 { +00127 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1016 }, +00128 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1016[0] } +00129 }; +00130 +00131 /* index 0x1017 : Producer Heartbeat Time */ +00132 UNS16 TestMaster_obj1017 = 0x0; /* 0 */ +00133 +00134 /* index 0x1018 : Identity. */ +00135 UNS8 TestMaster_highestSubIndex_obj1018 = 4; /* number of subindex - 1*/ +00136 UNS32 TestMaster_obj1018_Vendor_ID = 0x0; /* 0 */ +00137 UNS32 TestMaster_obj1018_Product_Code = 0x0; /* 0 */ +00138 UNS32 TestMaster_obj1018_Revision_Number = 0x0; /* 0 */ +00139 UNS32 TestMaster_obj1018_Serial_Number = 0x0; /* 0 */ +00140 subindex TestMaster_Index1018[] = +00141 { +00142 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1018 }, +00143 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Vendor_ID }, +00144 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Product_Code }, +00145 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Revision_Number }, +00146 { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Serial_Number } +00147 }; +00148 +00149 /* index 0x1280 : Client SDO 1 Parameter. */ +00150 UNS8 TestMaster_highestSubIndex_obj1280 = 3; /* number of subindex - 1*/ +00151 UNS32 TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO = 0x602; /* 1538 */ +00152 UNS32 TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO = 0x582; /* 1410 */ +00153 INTEGER32 TestMaster_obj1280_Node_ID_of_the_SDO_Server = 0x2; /* 2 */ +00154 subindex TestMaster_Index1280[] = +00155 { +00156 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1280 }, +00157 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO }, +00158 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO }, +00159 { RW, int32, sizeof (INTEGER32), (void*)&TestMaster_obj1280_Node_ID_of_the_SDO_Server } +00160 }; +00161 +00162 /* index 0x1400 : Receive PDO 1 Parameter. */ +00163 UNS8 TestMaster_highestSubIndex_obj1400 = 5; /* number of subindex - 1*/ +00164 UNS32 TestMaster_obj1400_COB_ID_used_by_PDO = 0x182; /* 386 */ +00165 UNS8 TestMaster_obj1400_Transmission_Type = 0x1; /* 1 */ +00166 UNS16 TestMaster_obj1400_Inhibit_Time = 0x0; /* 0 */ +00167 UNS8 TestMaster_obj1400_Compatibility_Entry = 0x0; /* 0 */ +00168 UNS16 TestMaster_obj1400_Event_Timer = 0x0; /* 0 */ +00169 subindex TestMaster_Index1400[] = +00170 { +00171 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1400 }, +00172 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1400_COB_ID_used_by_PDO }, +00173 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Transmission_Type }, +00174 { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Inhibit_Time }, +00175 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Compatibility_Entry }, +00176 { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Event_Timer } +00177 }; +00178 +00179 /* index 0x1401 : Receive PDO 2 Parameter. */ +00180 UNS8 TestMaster_highestSubIndex_obj1401 = 5; /* number of subindex - 1*/ +00181 UNS32 TestMaster_obj1401_COB_ID_used_by_PDO = 0x0; /* 0 */ +00182 UNS8 TestMaster_obj1401_Transmission_Type = 0x0; /* 0 */ +00183 UNS16 TestMaster_obj1401_Inhibit_Time = 0x0; /* 0 */ +00184 UNS8 TestMaster_obj1401_Compatibility_Entry = 0x0; /* 0 */ +00185 UNS16 TestMaster_obj1401_Event_Timer = 0x0; /* 0 */ +00186 subindex TestMaster_Index1401[] = +00187 { +00188 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1401 }, +00189 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1401_COB_ID_used_by_PDO }, +00190 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1401_Transmission_Type }, +00191 { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Inhibit_Time }, +00192 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1401_Compatibility_Entry }, +00193 { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Event_Timer } +00194 }; +00195 +00196 /* index 0x1600 : Receive PDO 1 Mapping. */ +00197 UNS8 TestMaster_highestSubIndex_obj1600 = 10; /* number of subindex - 1*/ +00198 UNS32 TestMaster_obj1600[] = +00199 { +00200 0x20000001, /* 536870913 */ +00201 0x20010001, /* 536936449 */ +00202 0x20020001, /* 537001985 */ +00203 0x20030001, /* 537067521 */ +00204 0x20040001, /* 537133057 */ +00205 0x20050001, /* 537198593 */ +00206 0x20060001, /* 537264129 */ +00207 0x20070001, /* 537329665 */ +00208 0x20080008, /* 537395208 */ +00209 0x20090020 /* 537460768 */ +00210 }; +00211 subindex TestMaster_Index1600[] = +00212 { +00213 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1600 }, +00214 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[0] }, +00215 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[1] }, +00216 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[2] }, +00217 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[3] }, +00218 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[4] }, +00219 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[5] }, +00220 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[6] }, +00221 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[7] }, +00222 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[8] }, +00223 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[9] } +00224 }; +00225 +00226 /* index 0x1601 : Receive PDO 2 Mapping. */ +00227 UNS8 TestMaster_highestSubIndex_obj1601 = 1; /* number of subindex - 1*/ +00228 UNS32 TestMaster_obj1601[] = +00229 { +00230 0x200A0010 /* 537526288 */ +00231 }; +00232 subindex TestMaster_Index1601[] = +00233 { +00234 { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1601 }, +00235 { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1601[0] } +00236 }; +00237 +00238 /* index 0x1F22 : Concise DCF. */ +00239 UNS8 TestMaster_highestSubIndex_obj1F22 = 2; /* number of subindex - 1*/ +00240 UNS8* TestMaster_obj1F22[] = +00241 { +00242 "", +00243 "\x01\x00\x00\x00\x17\x10\x00\x02\x00\x00\x00\xe8\x03" +00244 }; +00245 subindex TestMaster_Index1F22[] = +00246 { +00247 { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1F22 }, +00248 { RW, domain, 0, (void*)&TestMaster_obj1F22[0] }, +00249 { RW, domain, 13, (void*)&TestMaster_obj1F22[1] } +00250 }; +00251 +00252 /* index 0x2000 : Mapped variable MasterMap1 */ +00253 subindex TestMaster_Index2000[] = +00254 { +00255 { RW, boolean, sizeof (UNS8), (void*)&MasterMap1 } +00256 }; +00257 +00258 /* index 0x2001 : Mapped variable MasterMap2 */ +00259 subindex TestMaster_Index2001[] = +00260 { +00261 { RW, boolean, sizeof (UNS8), (void*)&MasterMap2 } +00262 }; +00263 +00264 /* index 0x2002 : Mapped variable MasterMap3 */ +00265 subindex TestMaster_Index2002[] = +00266 { +00267 { RW, boolean, sizeof (UNS8), (void*)&MasterMap3 } +00268 }; +00269 +00270 /* index 0x2003 : Mapped variable MasterMap4 */ +00271 subindex TestMaster_Index2003[] = +00272 { +00273 { RW, boolean, sizeof (UNS8), (void*)&MasterMap4 } +00274 }; +00275 +00276 /* index 0x2004 : Mapped variable MasterMap5 */ +00277 subindex TestMaster_Index2004[] = +00278 { +00279 { RW, boolean, sizeof (UNS8), (void*)&MasterMap5 } +00280 }; +00281 +00282 /* index 0x2005 : Mapped variable MasterMap6 */ +00283 subindex TestMaster_Index2005[] = +00284 { +00285 { RW, boolean, sizeof (UNS8), (void*)&MasterMap6 } +00286 }; +00287 +00288 /* index 0x2006 : Mapped variable MasterMap7 */ +00289 subindex TestMaster_Index2006[] = +00290 { +00291 { RW, boolean, sizeof (UNS8), (void*)&MasterMap7 } +00292 }; +00293 +00294 /* index 0x2007 : Mapped variable MasterMap8 */ +00295 subindex TestMaster_Index2007[] = +00296 { +00297 { RW, boolean, sizeof (UNS8), (void*)&MasterMap8 } +00298 }; +00299 +00300 /* index 0x2008 : Mapped variable MasterMap9 */ +00301 subindex TestMaster_Index2008[] = +00302 { +00303 { RW, uint8, sizeof (UNS8), (void*)&MasterMap9 } +00304 }; +00305 +00306 /* index 0x2009 : Mapped variable MasterMap10 */ +00307 subindex TestMaster_Index2009[] = +00308 { +00309 { RW, uint32, sizeof (UNS32), (void*)&MasterMap10 } +00310 }; +00311 +00312 /* index 0x200A : Mapped variable MasterMap11 */ +00313 subindex TestMaster_Index200A[] = +00314 { +00315 { RW, uint16, sizeof (UNS16), (void*)&MasterMap11 } +00316 }; +00317 +00318 const indextable TestMaster_objdict[] = +00319 { +00320 { (subindex*)TestMaster_Index1000,sizeof(TestMaster_Index1000)/sizeof(TestMaster_Index1000[0]), 0x1000}, +00321 { (subindex*)TestMaster_Index1001,sizeof(TestMaster_Index1001)/sizeof(TestMaster_Index1001[0]), 0x1001}, +00322 { (subindex*)TestMaster_Index1005,sizeof(TestMaster_Index1005)/sizeof(TestMaster_Index1005[0]), 0x1005}, +00323 { (subindex*)TestMaster_Index1006,sizeof(TestMaster_Index1006)/sizeof(TestMaster_Index1006[0]), 0x1006}, +00324 { (subindex*)TestMaster_Index1010,sizeof(TestMaster_Index1010)/sizeof(TestMaster_Index1010[0]), 0x1010}, +00325 { (subindex*)TestMaster_Index1011,sizeof(TestMaster_Index1011)/sizeof(TestMaster_Index1011[0]), 0x1011}, +00326 { (subindex*)TestMaster_Index1016,sizeof(TestMaster_Index1016)/sizeof(TestMaster_Index1016[0]), 0x1016}, +00327 { (subindex*)TestMaster_Index1018,sizeof(TestMaster_Index1018)/sizeof(TestMaster_Index1018[0]), 0x1018}, +00328 { (subindex*)TestMaster_Index1280,sizeof(TestMaster_Index1280)/sizeof(TestMaster_Index1280[0]), 0x1280}, +00329 { (subindex*)TestMaster_Index1400,sizeof(TestMaster_Index1400)/sizeof(TestMaster_Index1400[0]), 0x1400}, +00330 { (subindex*)TestMaster_Index1401,sizeof(TestMaster_Index1401)/sizeof(TestMaster_Index1401[0]), 0x1401}, +00331 { (subindex*)TestMaster_Index1600,sizeof(TestMaster_Index1600)/sizeof(TestMaster_Index1600[0]), 0x1600}, +00332 { (subindex*)TestMaster_Index1601,sizeof(TestMaster_Index1601)/sizeof(TestMaster_Index1601[0]), 0x1601}, +00333 { (subindex*)TestMaster_Index1F22,sizeof(TestMaster_Index1F22)/sizeof(TestMaster_Index1F22[0]), 0x1F22}, +00334 { (subindex*)TestMaster_Index2000,sizeof(TestMaster_Index2000)/sizeof(TestMaster_Index2000[0]), 0x2000}, +00335 { (subindex*)TestMaster_Index2001,sizeof(TestMaster_Index2001)/sizeof(TestMaster_Index2001[0]), 0x2001}, +00336 { (subindex*)TestMaster_Index2002,sizeof(TestMaster_Index2002)/sizeof(TestMaster_Index2002[0]), 0x2002}, +00337 { (subindex*)TestMaster_Index2003,sizeof(TestMaster_Index2003)/sizeof(TestMaster_Index2003[0]), 0x2003}, +00338 { (subindex*)TestMaster_Index2004,sizeof(TestMaster_Index2004)/sizeof(TestMaster_Index2004[0]), 0x2004}, +00339 { (subindex*)TestMaster_Index2005,sizeof(TestMaster_Index2005)/sizeof(TestMaster_Index2005[0]), 0x2005}, +00340 { (subindex*)TestMaster_Index2006,sizeof(TestMaster_Index2006)/sizeof(TestMaster_Index2006[0]), 0x2006}, +00341 { (subindex*)TestMaster_Index2007,sizeof(TestMaster_Index2007)/sizeof(TestMaster_Index2007[0]), 0x2007}, +00342 { (subindex*)TestMaster_Index2008,sizeof(TestMaster_Index2008)/sizeof(TestMaster_Index2008[0]), 0x2008}, +00343 { (subindex*)TestMaster_Index2009,sizeof(TestMaster_Index2009)/sizeof(TestMaster_Index2009[0]), 0x2009}, +00344 { (subindex*)TestMaster_Index200A,sizeof(TestMaster_Index200A)/sizeof(TestMaster_Index200A[0]), 0x200A}, +00345 }; +00346 +00347 const indextable * TestMaster_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks) +00348 { +00349 int i; +00350 *callbacks = NULL; +00351 switch(wIndex){ +00352 case 0x1000: i = 0;break; +00353 case 0x1001: i = 1;break; +00354 case 0x1005: i = 2;*callbacks = TestMaster_Index1005_callbacks; break; +00355 case 0x1006: i = 3;*callbacks = TestMaster_Index1006_callbacks; break; +00356 case 0x1010: i = 4;break; +00357 case 0x1011: i = 5;break; +00358 case 0x1016: i = 6;break; +00359 case 0x1018: i = 7;break; +00360 case 0x1280: i = 8;break; +00361 case 0x1400: i = 9;break; +00362 case 0x1401: i = 10;break; +00363 case 0x1600: i = 11;break; +00364 case 0x1601: i = 12;break; +00365 case 0x1F22: i = 13;break; +00366 case 0x2000: i = 14;break; +00367 case 0x2001: i = 15;break; +00368 case 0x2002: i = 16;break; +00369 case 0x2003: i = 17;break; +00370 case 0x2004: i = 18;break; +00371 case 0x2005: i = 19;break; +00372 case 0x2006: i = 20;break; +00373 case 0x2007: i = 21;break; +00374 case 0x2008: i = 22;break; +00375 case 0x2009: i = 23;break; +00376 case 0x200A: i = 24;break; +00377 default: +00378 *errorCode = OD_NO_SUCH_OBJECT; +00379 return NULL; +00380 } +00381 *errorCode = OD_SUCCESSFUL; +00382 return &TestMaster_objdict[i]; +00383 } +00384 +00385 /* To count at which received SYNC a PDO must be sent. +00386 * Even if no pdoTransmit are defined, at least one entry is computed +00387 * for compilations issues. +00388 */ +00389 UNS8 TestMaster_count_sync[1] = {0,}; +00390 +00391 quick_index TestMaster_firstIndex = { +00392 0, /* SDO_SVR */ +00393 8, /* SDO_CLT */ +00394 9, /* PDO_RCV */ +00395 11, /* PDO_RCV_MAP */ +00396 0, /* PDO_TRS */ +00397 0 /* PDO_TRS_MAP */ +00398 }; +00399 +00400 quick_index TestMaster_lastIndex = { +00401 0, /* SDO_SVR */ +00402 8, /* SDO_CLT */ +00403 10, /* PDO_RCV */ +00404 12, /* PDO_RCV_MAP */ +00405 0, /* PDO_TRS */ +00406 0 /* PDO_TRS_MAP */ +00407 }; +00408 +00409 UNS16 TestMaster_ObjdictSize = sizeof(TestMaster_objdict)/sizeof(TestMaster_objdict[0]); +00410 +00411 CO_Data TestMaster_Data = CANOPEN_NODE_DATA_INITIALIZER(TestMaster); +00412 +
#include "TestMaster.h"
+Include dependency graph for TestMaster.c:
+Go to the source code of this file.
const indextable* TestMaster_scanIndexOD | +( | +UNS16 | +wIndex, | +|
+ | + | UNS32 * | +errorCode, | +|
+ | + | ODCallback_t ** | +callbacks | + |
+ | ) | ++ |
+ +
+Definition at line 347 of file TestMaster.c. +
UNS32 TestMaster_valueRangeTest | +( | +UNS8 | +typeValue, | +|
+ | + | void * | +value | + |
+ | ) | ++ |
+ +
+Definition at line 25 of file TestMaster.c. +
+
UNS8 MasterMap1 = 0x0 | +
+ +
+Definition at line 9 of file TestMaster.c. +
+Referenced by TestMaster_post_sync(), and TestMaster_post_TPDO(). +
UNS32 MasterMap10 = 0x0 | +
UNS16 MasterMap11 = 0x0 | +
UNS8 MasterMap2 = 0x0 | +
UNS8 MasterMap3 = 0x0 | +
UNS8 MasterMap4 = 0x0 | +
UNS8 MasterMap5 = 0x0 | +
UNS8 MasterMap6 = 0x0 | +
UNS8 MasterMap7 = 0x0 | +
UNS8 MasterMap8 = 0x0 | +
UNS8 MasterMap9 = 0x0 | +
UNS8 TestMaster_bDeviceNodeId = 0x01 | +
+ +
+Definition at line 36 of file TestMaster.c. +
UNS8 TestMaster_count_sync[1] = {0,} | +
+ +
+Definition at line 389 of file TestMaster.c. +
CO_Data TestMaster_Data = CANOPEN_NODE_DATA_INITIALIZER(TestMaster) | +
+ +
+Definition at line 411 of file TestMaster.c. +
+Referenced by InitNodes(), main(), TestMaster_initialisation(), TestMaster_post_TPDO(), and TestMaster_preOperational(). +
quick_index TestMaster_firstIndex | +
+Initial value:
{ + 0, + 8, + 9, + 11, + 0, + 0 +} +
+Definition at line 391 of file TestMaster.c. +
TIMER_HANDLE TestMaster_heartBeatTimers[1] = {TIMER_NONE,} | +
+ +
+Definition at line 43 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1010 = 4 | +
+ +
+Definition at line 90 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1011 = 4 | +
+ +
+Definition at line 105 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1016 = 1 | +
+ +
+Definition at line 120 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1018 = 4 | +
+ +
+Definition at line 135 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1280 = 3 | +
+ +
+Definition at line 150 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1400 = 5 | +
+ +
+Definition at line 163 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1401 = 5 | +
+ +
+Definition at line 180 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1600 = 10 | +
+ +
+Definition at line 197 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1601 = 1 | +
+ +
+Definition at line 227 of file TestMaster.c. +
UNS8 TestMaster_highestSubIndex_obj1F22 = 2 | +
+ +
+Definition at line 239 of file TestMaster.c. +
const UNS8 TestMaster_iam_a_slave = 0 | +
+ +
+Definition at line 41 of file TestMaster.c. +
subindex TestMaster_Index1000[] | +
+Initial value:
+ { + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1000 } + } +
+Definition at line 55 of file TestMaster.c. +
subindex TestMaster_Index1001[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_obj1001 } + } +
+Definition at line 62 of file TestMaster.c. +
subindex TestMaster_Index1005[] | +
+Initial value:
+ { + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1005 } + } +
+Definition at line 73 of file TestMaster.c. +
ODCallback_t TestMaster_Index1005_callbacks[] | +
+Initial value:
+ { + NULL, + } +
+Definition at line 69 of file TestMaster.c. +
+Referenced by TestMaster_scanIndexOD(). +
subindex TestMaster_Index1006[] | +
+Initial value:
+ { + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1006 } + } +
+Definition at line 84 of file TestMaster.c. +
ODCallback_t TestMaster_Index1006_callbacks[] | +
+Initial value:
+ { + NULL, + } +
+Definition at line 80 of file TestMaster.c. +
+Referenced by TestMaster_scanIndexOD(). +
subindex TestMaster_Index1010[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1010 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_All_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Communication_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Application_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Manufacturer_Parameters } + } +
+Definition at line 95 of file TestMaster.c. +
subindex TestMaster_Index1011[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1011 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_All_Default_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Communication_Default_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Application_Default_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Manufacturer_Default_Parameters } + } +
+Definition at line 110 of file TestMaster.c. +
subindex TestMaster_Index1016[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1016 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1016[0] } + } +
+Definition at line 125 of file TestMaster.c. +
subindex TestMaster_Index1018[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1018 }, + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Vendor_ID }, + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Product_Code }, + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Revision_Number }, + { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1018_Serial_Number } + } +
+Definition at line 140 of file TestMaster.c. +
subindex TestMaster_Index1280[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1280 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO }, + { RW, int32, sizeof (INTEGER32), (void*)&TestMaster_obj1280_Node_ID_of_the_SDO_Server } + } +
+Definition at line 154 of file TestMaster.c. +
subindex TestMaster_Index1400[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1400 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1400_COB_ID_used_by_PDO }, + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Transmission_Type }, + { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Inhibit_Time }, + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1400_Compatibility_Entry }, + { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1400_Event_Timer } + } +
+Definition at line 169 of file TestMaster.c. +
subindex TestMaster_Index1401[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1401 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1401_COB_ID_used_by_PDO }, + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1401_Transmission_Type }, + { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Inhibit_Time }, + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_obj1401_Compatibility_Entry }, + { RW, uint16, sizeof (UNS16), (void*)&TestMaster_obj1401_Event_Timer } + } +
+Definition at line 186 of file TestMaster.c. +
subindex TestMaster_Index1600[] | +
+Initial value:
+ { + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1600 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[0] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[1] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[2] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[3] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[4] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[5] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[6] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[7] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[8] }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1600[9] } + } +
+Definition at line 211 of file TestMaster.c. +
subindex TestMaster_Index1601[] | +
+Initial value:
+ { + { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1601 }, + { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1601[0] } + } +
+Definition at line 232 of file TestMaster.c. +
subindex TestMaster_Index1F22[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1F22 }, + { RW, domain, 0, (void*)&TestMaster_obj1F22[0] }, + { RW, domain, 13, (void*)&TestMaster_obj1F22[1] } + } +
+Definition at line 245 of file TestMaster.c. +
subindex TestMaster_Index2000[] | +
+Initial value:
+ { + { RW, boolean, sizeof (UNS8), (void*)&MasterMap1 } + } +
+Definition at line 253 of file TestMaster.c. +
subindex TestMaster_Index2001[] | +
+Initial value:
+ { + { RW, boolean, sizeof (UNS8), (void*)&MasterMap2 } + } +
+Definition at line 259 of file TestMaster.c. +
subindex TestMaster_Index2002[] | +
+Initial value:
+ { + { RW, boolean, sizeof (UNS8), (void*)&MasterMap3 } + } +
+Definition at line 265 of file TestMaster.c. +
subindex TestMaster_Index2003[] | +
+Initial value:
+ { + { RW, boolean, sizeof (UNS8), (void*)&MasterMap4 } + } +
+Definition at line 271 of file TestMaster.c. +
subindex TestMaster_Index2004[] | +
+Initial value:
+ { + { RW, boolean, sizeof (UNS8), (void*)&MasterMap5 } + } +
+Definition at line 277 of file TestMaster.c. +
subindex TestMaster_Index2005[] | +
+Initial value:
+ { + { RW, boolean, sizeof (UNS8), (void*)&MasterMap6 } + } +
+Definition at line 283 of file TestMaster.c. +
subindex TestMaster_Index2006[] | +
+Initial value:
+ { + { RW, boolean, sizeof (UNS8), (void*)&MasterMap7 } + } +
+Definition at line 289 of file TestMaster.c. +
subindex TestMaster_Index2007[] | +
+Initial value:
+ { + { RW, boolean, sizeof (UNS8), (void*)&MasterMap8 } + } +
+Definition at line 295 of file TestMaster.c. +
subindex TestMaster_Index2008[] | +
+Initial value:
+ { + { RW, uint8, sizeof (UNS8), (void*)&MasterMap9 } + } +
+Definition at line 301 of file TestMaster.c. +
subindex TestMaster_Index2009[] | +
+Initial value:
+ { + { RW, uint32, sizeof (UNS32), (void*)&MasterMap10 } + } +
+Definition at line 307 of file TestMaster.c. +
subindex TestMaster_Index200A[] | +
+Initial value:
+ { + { RW, uint16, sizeof (UNS16), (void*)&MasterMap11 } + } +
+Definition at line 313 of file TestMaster.c. +
quick_index TestMaster_lastIndex | +
+Initial value:
{ + 0, + 8, + 10, + 12, + 0, + 0 +} +
+Definition at line 400 of file TestMaster.c. +
UNS32 TestMaster_obj1000 = 0x12D | +
+ +
+Definition at line 54 of file TestMaster.c. +
UNS8 TestMaster_obj1001 = 0x0 | +
+ +
+Definition at line 61 of file TestMaster.c. +
UNS32 TestMaster_obj1005 = 0x40000080 | +
+ +
+Definition at line 68 of file TestMaster.c. +
UNS32 TestMaster_obj1006 = 0xC350 | +
+ +
+Definition at line 79 of file TestMaster.c. +
UNS32 TestMaster_obj1010_Save_All_Parameters = 0x0 | +
+ +
+Definition at line 91 of file TestMaster.c. +
UNS32 TestMaster_obj1010_Save_Application_Parameters = 0x0 | +
+ +
+Definition at line 93 of file TestMaster.c. +
UNS32 TestMaster_obj1010_Save_Communication_Parameters = 0x0 | +
+ +
+Definition at line 92 of file TestMaster.c. +
UNS32 TestMaster_obj1010_Save_Manufacturer_Parameters = 0x0 | +
+ +
+Definition at line 94 of file TestMaster.c. +
UNS32 TestMaster_obj1011_Restore_All_Default_Parameters = 0x0 | +
+ +
+Definition at line 106 of file TestMaster.c. +
UNS32 TestMaster_obj1011_Restore_Application_Default_Parameters = 0x0 | +
+ +
+Definition at line 108 of file TestMaster.c. +
UNS32 TestMaster_obj1011_Restore_Communication_Default_Parameters = 0x0 | +
+ +
+Definition at line 107 of file TestMaster.c. +
UNS32 TestMaster_obj1011_Restore_Manufacturer_Default_Parameters = 0x0 | +
+ +
+Definition at line 109 of file TestMaster.c. +
UNS32 TestMaster_obj1016[] | +
UNS16 TestMaster_obj1017 = 0x0 | +
+ +
+Definition at line 132 of file TestMaster.c. +
UNS32 TestMaster_obj1018_Product_Code = 0x0 | +
+ +
+Definition at line 137 of file TestMaster.c. +
UNS32 TestMaster_obj1018_Revision_Number = 0x0 | +
+ +
+Definition at line 138 of file TestMaster.c. +
UNS32 TestMaster_obj1018_Serial_Number = 0x0 | +
+ +
+Definition at line 139 of file TestMaster.c. +
UNS32 TestMaster_obj1018_Vendor_ID = 0x0 | +
+ +
+Definition at line 136 of file TestMaster.c. +
UNS32 TestMaster_obj1280_COB_ID_Client_to_Server_Transmit_SDO = 0x602 | +
+ +
+Definition at line 151 of file TestMaster.c. +
UNS32 TestMaster_obj1280_COB_ID_Server_to_Client_Receive_SDO = 0x582 | +
+ +
+Definition at line 152 of file TestMaster.c. +
INTEGER32 TestMaster_obj1280_Node_ID_of_the_SDO_Server = 0x2 | +
+ +
+Definition at line 153 of file TestMaster.c. +
UNS32 TestMaster_obj1400_COB_ID_used_by_PDO = 0x182 | +
+ +
+Definition at line 164 of file TestMaster.c. +
UNS8 TestMaster_obj1400_Compatibility_Entry = 0x0 | +
+ +
+Definition at line 167 of file TestMaster.c. +
UNS16 TestMaster_obj1400_Event_Timer = 0x0 | +
+ +
+Definition at line 168 of file TestMaster.c. +
UNS16 TestMaster_obj1400_Inhibit_Time = 0x0 | +
+ +
+Definition at line 166 of file TestMaster.c. +
UNS8 TestMaster_obj1400_Transmission_Type = 0x1 | +
+ +
+Definition at line 165 of file TestMaster.c. +
UNS32 TestMaster_obj1401_COB_ID_used_by_PDO = 0x0 | +
+ +
+Definition at line 181 of file TestMaster.c. +
UNS8 TestMaster_obj1401_Compatibility_Entry = 0x0 | +
+ +
+Definition at line 184 of file TestMaster.c. +
UNS16 TestMaster_obj1401_Event_Timer = 0x0 | +
+ +
+Definition at line 185 of file TestMaster.c. +
UNS16 TestMaster_obj1401_Inhibit_Time = 0x0 | +
+ +
+Definition at line 183 of file TestMaster.c. +
UNS8 TestMaster_obj1401_Transmission_Type = 0x0 | +
+ +
+Definition at line 182 of file TestMaster.c. +
UNS32 TestMaster_obj1600[] | +
+Initial value:
+ { + 0x20000001, + 0x20010001, + 0x20020001, + 0x20030001, + 0x20040001, + 0x20050001, + 0x20060001, + 0x20070001, + 0x20080008, + 0x20090020 + } +
+Definition at line 198 of file TestMaster.c. +
UNS32 TestMaster_obj1601[] | +
UNS8* TestMaster_obj1F22[] | +
+Initial value:
+ { + "", + "\x01\x00\x00\x00\x17\x10\x00\x02\x00\x00\x00\xe8\x03" + } +
+Definition at line 240 of file TestMaster.c. +
const indextable TestMaster_objdict[] | +
+Initial value:
+{ + { (subindex*)TestMaster_Index1000,sizeof(TestMaster_Index1000)/sizeof(TestMaster_Index1000[0]), 0x1000}, + { (subindex*)TestMaster_Index1001,sizeof(TestMaster_Index1001)/sizeof(TestMaster_Index1001[0]), 0x1001}, + { (subindex*)TestMaster_Index1005,sizeof(TestMaster_Index1005)/sizeof(TestMaster_Index1005[0]), 0x1005}, + { (subindex*)TestMaster_Index1006,sizeof(TestMaster_Index1006)/sizeof(TestMaster_Index1006[0]), 0x1006}, + { (subindex*)TestMaster_Index1010,sizeof(TestMaster_Index1010)/sizeof(TestMaster_Index1010[0]), 0x1010}, + { (subindex*)TestMaster_Index1011,sizeof(TestMaster_Index1011)/sizeof(TestMaster_Index1011[0]), 0x1011}, + { (subindex*)TestMaster_Index1016,sizeof(TestMaster_Index1016)/sizeof(TestMaster_Index1016[0]), 0x1016}, + { (subindex*)TestMaster_Index1018,sizeof(TestMaster_Index1018)/sizeof(TestMaster_Index1018[0]), 0x1018}, + { (subindex*)TestMaster_Index1280,sizeof(TestMaster_Index1280)/sizeof(TestMaster_Index1280[0]), 0x1280}, + { (subindex*)TestMaster_Index1400,sizeof(TestMaster_Index1400)/sizeof(TestMaster_Index1400[0]), 0x1400}, + { (subindex*)TestMaster_Index1401,sizeof(TestMaster_Index1401)/sizeof(TestMaster_Index1401[0]), 0x1401}, + { (subindex*)TestMaster_Index1600,sizeof(TestMaster_Index1600)/sizeof(TestMaster_Index1600[0]), 0x1600}, + { (subindex*)TestMaster_Index1601,sizeof(TestMaster_Index1601)/sizeof(TestMaster_Index1601[0]), 0x1601}, + { (subindex*)TestMaster_Index1F22,sizeof(TestMaster_Index1F22)/sizeof(TestMaster_Index1F22[0]), 0x1F22}, + { (subindex*)TestMaster_Index2000,sizeof(TestMaster_Index2000)/sizeof(TestMaster_Index2000[0]), 0x2000}, + { (subindex*)TestMaster_Index2001,sizeof(TestMaster_Index2001)/sizeof(TestMaster_Index2001[0]), 0x2001}, + { (subindex*)TestMaster_Index2002,sizeof(TestMaster_Index2002)/sizeof(TestMaster_Index2002[0]), 0x2002}, + { (subindex*)TestMaster_Index2003,sizeof(TestMaster_Index2003)/sizeof(TestMaster_Index2003[0]), 0x2003}, + { (subindex*)TestMaster_Index2004,sizeof(TestMaster_Index2004)/sizeof(TestMaster_Index2004[0]), 0x2004}, + { (subindex*)TestMaster_Index2005,sizeof(TestMaster_Index2005)/sizeof(TestMaster_Index2005[0]), 0x2005}, + { (subindex*)TestMaster_Index2006,sizeof(TestMaster_Index2006)/sizeof(TestMaster_Index2006[0]), 0x2006}, + { (subindex*)TestMaster_Index2007,sizeof(TestMaster_Index2007)/sizeof(TestMaster_Index2007[0]), 0x2007}, + { (subindex*)TestMaster_Index2008,sizeof(TestMaster_Index2008)/sizeof(TestMaster_Index2008[0]), 0x2008}, + { (subindex*)TestMaster_Index2009,sizeof(TestMaster_Index2009)/sizeof(TestMaster_Index2009[0]), 0x2009}, + { (subindex*)TestMaster_Index200A,sizeof(TestMaster_Index200A)/sizeof(TestMaster_Index200A[0]), 0x200A}, +} +
+Definition at line 318 of file TestMaster.c. +
+Referenced by TestMaster_scanIndexOD(). +
UNS16 TestMaster_ObjdictSize = sizeof(TestMaster_objdict)/sizeof(TestMaster_objdict[0]) | +
+ +
+Definition at line 409 of file TestMaster.c. +
+
00001 +00002 /* File generated by gen_cfile.py. Should not be modified. */ +00003 +00004 #include "data.h" +00005 +00006 /* Prototypes of function provided by object dictionnary */ +00007 UNS32 TestMaster_valueRangeTest (UNS8 typeValue, void * value); +00008 const indextable * TestMaster_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks); +00009 +00010 /* Master node data struct */ +00011 extern CO_Data TestMaster_Data; +00012 +00013 extern UNS8 MasterMap1; /* Mapped at index 0x2000, subindex 0x00*/ +00014 extern UNS8 MasterMap2; /* Mapped at index 0x2001, subindex 0x00*/ +00015 extern UNS8 MasterMap3; /* Mapped at index 0x2002, subindex 0x00*/ +00016 extern UNS8 MasterMap4; /* Mapped at index 0x2003, subindex 0x00*/ +00017 extern UNS8 MasterMap5; /* Mapped at index 0x2004, subindex 0x00*/ +00018 extern UNS8 MasterMap6; /* Mapped at index 0x2005, subindex 0x00*/ +00019 extern UNS8 MasterMap7; /* Mapped at index 0x2006, subindex 0x00*/ +00020 extern UNS8 MasterMap8; /* Mapped at index 0x2007, subindex 0x00*/ +00021 extern UNS8 MasterMap9; /* Mapped at index 0x2008, subindex 0x00*/ +00022 extern UNS32 MasterMap10; /* Mapped at index 0x2009, subindex 0x00*/ +00023 extern UNS16 MasterMap11; /* Mapped at index 0x200A, subindex 0x00*/ +
#include "data.h"
+Include dependency graph for TestMaster.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Functions | |
UNS32 | TestMaster_valueRangeTest (UNS8 typeValue, void *value) |
const indextable * | TestMaster_scanIndexOD (UNS16 wIndex, UNS32 *errorCode, ODCallback_t **callbacks) |
Variables | |
CO_Data | TestMaster_Data |
UNS8 | MasterMap1 |
UNS8 | MasterMap2 |
UNS8 | MasterMap3 |
UNS8 | MasterMap4 |
UNS8 | MasterMap5 |
UNS8 | MasterMap6 |
UNS8 | MasterMap7 |
UNS8 | MasterMap8 |
UNS8 | MasterMap9 |
UNS32 | MasterMap10 |
UNS16 | MasterMap11 |
const indextable* TestMaster_scanIndexOD | +( | +UNS16 | +wIndex, | +|
+ | + | UNS32 * | +errorCode, | +|
+ | + | ODCallback_t ** | +callbacks | + |
+ | ) | ++ |
+ +
+Definition at line 347 of file TestMaster.c. +
UNS32 TestMaster_valueRangeTest | +( | +UNS8 | +typeValue, | +|
+ | + | void * | +value | + |
+ | ) | ++ |
+ +
+Definition at line 25 of file TestMaster.c. +
+
UNS8 MasterMap1 | +
+ +
+Definition at line 9 of file TestMaster.c. +
+Referenced by TestMaster_post_sync(), and TestMaster_post_TPDO(). +
UNS32 MasterMap10 | +
UNS16 MasterMap11 | +
UNS8 MasterMap2 | +
UNS8 MasterMap3 | +
UNS8 MasterMap4 | +
UNS8 MasterMap5 | +
UNS8 MasterMap6 | +
UNS8 MasterMap7 | +
UNS8 MasterMap8 | +
UNS8 MasterMap9 | +
CO_Data TestMaster_Data | +
+ +
+Definition at line 411 of file TestMaster.c. +
+
00001 /* from http://www.pwilson.net/getopt.html */ +00002 +00003 /* Getopt for GNU. +00004 NOTE: getopt is now part of the C library, so if you don't know what +00005 "Keep this file name-space clean" means, talk to drepper@gnu.org +00006 before changing it! +00007 Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001 +00008 Free Software Foundation, Inc. +00009 This file is part of the GNU C Library. +00010 +00011 The GNU C Library is free software; you can redistribute it and/or +00012 modify it under the terms of the GNU Lesser General Public +00013 License as published by the Free Software Foundation; either +00014 version 2.1 of the License, or (at your option) any later version. +00015 +00016 The GNU C Library is distributed in the hope that it will be useful, +00017 but WITHOUT ANY WARRANTY; without even the implied warranty of +00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00019 Lesser General Public License for more details. +00020 +00021 You should have received a copy of the GNU Lesser General Public +00022 License along with the GNU C Library; if not, write to the Free +00023 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +00024 02111-1307 USA. */ +00025 +00026 /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. +00027 Ditto for AIX 3.2 and <stdlib.h>. */ +00028 #ifndef _NO_PROTO +00029 # define _NO_PROTO +00030 #endif +00031 +00032 #ifdef HAVE_CONFIG_H +00033 # include <config.h> +00034 #endif +00035 +00036 #if !defined __STDC__ || !__STDC__ +00037 /* This is a separate conditional since some stdc systems +00038 reject `defined (const)'. */ +00039 # ifndef const +00040 # define const +00041 # endif +00042 #endif +00043 +00044 #include <stdio.h> +00045 +00046 /* Comment out all this code if we are using the GNU C Library, and are not +00047 actually compiling the library itself. This code is part of the GNU C +00048 Library, but also included in many other GNU distributions. Compiling +00049 and linking in this code is a waste when using the GNU C library +00050 (especially if it is a shared library). Rather than having every GNU +00051 program understand `configure --with-gnu-libc' and omit the object files, +00052 it is simpler to just do this in the source for each such file. */ +00053 +00054 #define GETOPT_INTERFACE_VERSION 2 +00055 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +00056 # include <gnu-versions.h> +00057 # if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +00058 # define ELIDE_CODE +00059 # endif +00060 #endif +00061 +00062 #ifndef ELIDE_CODE +00063 +00064 +00065 /* This needs to come after some library #include +00066 to get __GNU_LIBRARY__ defined. */ +00067 #ifdef __GNU_LIBRARY__ +00068 /* Don't include stdlib.h for non-GNU C libraries because some of them +00069 contain conflicting prototypes for getopt. */ +00070 # include <stdlib.h> +00071 # include <unistd.h> +00072 #endif /* GNU C library. */ +00073 +00074 #ifdef VMS +00075 # include <unixlib.h> +00076 # if HAVE_STRING_H - 0 +00077 # include <string.h> +00078 # endif +00079 #endif +00080 +00081 #ifndef _ +00082 /* This is for other GNU distributions with internationalized messages. */ +00083 # if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC +00084 # include <libintl.h> +00085 # ifndef _ +00086 # define _(msgid) gettext (msgid) +00087 # endif +00088 # else +00089 # define _(msgid) (msgid) +00090 # endif +00091 # if defined _LIBC && defined USE_IN_LIBIO +00092 # include <wchar.h> +00093 # endif +00094 #endif +00095 +00096 /* This version of `getopt' appears to the caller like standard Unix `getopt' +00097 but it behaves differently for the user, since it allows the user +00098 to intersperse the options with the other arguments. +00099 +00100 As `getopt' works, it permutes the elements of ARGV so that, +00101 when it is done, all the options precede everything else. Thus +00102 all application programs are extended to handle flexible argument order. +00103 +00104 Setting the environment variable POSIXLY_CORRECT disables permutation. +00105 Then the behavior is completely standard. +00106 +00107 GNU application programs can use a third alternative mode in which +00108 they can distinguish the relative order of options and other arguments. */ +00109 +00110 #include "getopt.h" +00111 +00112 /* For communication from `getopt' to the caller. +00113 When `getopt' finds an option that takes an argument, +00114 the argument value is returned here. +00115 Also, when `ordering' is RETURN_IN_ORDER, +00116 each non-option ARGV-element is returned here. */ +00117 +00118 char *optarg; +00119 +00120 /* Index in ARGV of the next element to be scanned. +00121 This is used for communication to and from the caller +00122 and for communication between successive calls to `getopt'. +00123 +00124 On entry to `getopt', zero means this is the first call; initialize. +00125 +00126 When `getopt' returns -1, this is the index of the first of the +00127 non-option elements that the caller should itself scan. +00128 +00129 Otherwise, `optind' communicates from one call to the next +00130 how much of ARGV has been scanned so far. */ +00131 +00132 /* 1003.2 says this must be 1 before any call. */ +00133 int optind = 1; +00134 +00135 /* Formerly, initialization of getopt depended on optind==0, which +00136 causes problems with re-calling getopt as programs generally don't +00137 know that. */ +00138 +00139 int __getopt_initialized; +00140 +00141 /* The next char to be scanned in the option-element +00142 in which the last option character we returned was found. +00143 This allows us to pick up the scan where we left off. +00144 +00145 If this is zero, or a null string, it means resume the scan +00146 by advancing to the next ARGV-element. */ +00147 +00148 static char *nextchar; +00149 +00150 /* Callers store zero here to inhibit the error message +00151 for unrecognized options. */ +00152 +00153 int opterr = 1; +00154 +00155 /* Set to an option character which was unrecognized. +00156 This must be initialized on some systems to avoid linking in the +00157 system's own getopt implementation. */ +00158 +00159 int optopt = '?'; +00160 +00161 /* Describe how to deal with options that follow non-option ARGV-elements. +00162 +00163 If the caller did not specify anything, +00164 the default is REQUIRE_ORDER if the environment variable +00165 POSIXLY_CORRECT is defined, PERMUTE otherwise. +00166 +00167 REQUIRE_ORDER means don't recognize them as options; +00168 stop option processing when the first non-option is seen. +00169 This is what Unix does. +00170 This mode of operation is selected by either setting the environment +00171 variable POSIXLY_CORRECT, or using `+' as the first character +00172 of the list of option characters. +00173 +00174 PERMUTE is the default. We permute the contents of ARGV as we scan, +00175 so that eventually all the non-options are at the end. This allows options +00176 to be given in any order, even with programs that were not written to +00177 expect this. +00178 +00179 RETURN_IN_ORDER is an option available to programs that were written +00180 to expect options and other ARGV-elements in any order and that care about +00181 the ordering of the two. We describe each non-option ARGV-element +00182 as if it were the argument of an option with character code 1. +00183 Using `-' as the first character of the list of option characters +00184 selects this mode of operation. +00185 +00186 The special argument `--' forces an end of option-scanning regardless +00187 of the value of `ordering'. In the case of RETURN_IN_ORDER, only +00188 `--' can cause `getopt' to return -1 with `optind' != ARGC. */ +00189 +00190 static enum +00191 { +00192 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +00193 } ordering; +00194 +00195 /* Value of POSIXLY_CORRECT environment variable. */ +00196 static char *posixly_correct; +00197 +00198 #ifdef __GNU_LIBRARY__ +00199 /* We want to avoid inclusion of string.h with non-GNU libraries +00200 because there are many ways it can cause trouble. +00201 On some systems, it contains special magic macros that don't work +00202 in GCC. */ +00203 # include <string.h> +00204 # define my_index strchr +00205 #else +00206 +00207 # if HAVE_STRING_H || WIN32 /* Pete Wilson mod 7/28/02 */ +00208 # include <string.h> +00209 # else +00210 # include <strings.h> +00211 # endif +00212 +00213 /* Avoid depending on library functions or files +00214 whose names are inconsistent. */ +00215 +00216 #ifndef getenv +00217 extern char *getenv (); +00218 #endif +00219 +00220 static char * +00221 my_index (str, chr) +00222 const char *str; +00223 int chr; +00224 { +00225 while (*str) +00226 { +00227 if (*str == chr) +00228 return (char *) str; +00229 str++; +00230 } +00231 return 0; +00232 } +00233 +00234 /* If using GCC, we can safely declare strlen this way. +00235 If not using GCC, it is ok not to declare it. */ +00236 #ifdef __GNUC__ +00237 /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. +00238 That was relevant to code that was here before. */ +00239 # if (!defined __STDC__ || !__STDC__) && !defined strlen +00240 /* gcc with -traditional declares the built-in strlen to return int, +00241 and has done so at least since version 2.4.5. -- rms. */ +00242 extern int strlen (const char *); +00243 # endif /* not __STDC__ */ +00244 #endif /* __GNUC__ */ +00245 +00246 #endif /* not __GNU_LIBRARY__ */ +00247 +00248 /* Handle permutation of arguments. */ +00249 +00250 /* Describe the part of ARGV that contains non-options that have +00251 been skipped. `first_nonopt' is the index in ARGV of the first of them; +00252 `last_nonopt' is the index after the last of them. */ +00253 +00254 static int first_nonopt; +00255 static int last_nonopt; +00256 +00257 #ifdef _LIBC +00258 /* Stored original parameters. +00259 XXX This is no good solution. We should rather copy the args so +00260 that we can compare them later. But we must not use malloc(3). */ +00261 extern int __libc_argc; +00262 extern char **__libc_argv; +00263 +00264 /* Bash 2.0 gives us an environment variable containing flags +00265 indicating ARGV elements that should not be considered arguments. */ +00266 +00267 # ifdef USE_NONOPTION_FLAGS +00268 /* Defined in getopt_init.c */ +00269 extern char *__getopt_nonoption_flags; +00270 +00271 static int nonoption_flags_max_len; +00272 static int nonoption_flags_len; +00273 # endif +00274 +00275 # ifdef USE_NONOPTION_FLAGS +00276 # define SWAP_FLAGS(ch1, ch2) \ +00277 if (nonoption_flags_len > 0) \ +00278 { \ +00279 char __tmp = __getopt_nonoption_flags[ch1]; \ +00280 __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ +00281 __getopt_nonoption_flags[ch2] = __tmp; \ +00282 } +00283 # else +00284 # define SWAP_FLAGS(ch1, ch2) +00285 # endif +00286 #else /* !_LIBC */ +00287 # define SWAP_FLAGS(ch1, ch2) +00288 #endif /* _LIBC */ +00289 +00290 /* Exchange two adjacent subsequences of ARGV. +00291 One subsequence is elements [first_nonopt,last_nonopt) +00292 which contains all the non-options that have been skipped so far. +00293 The other is elements [last_nonopt,optind), which contains all +00294 the options processed since those non-options were skipped. +00295 +00296 `first_nonopt' and `last_nonopt' are relocated so that they describe +00297 the new indices of the non-options in ARGV after they are moved. */ +00298 +00299 #if defined __STDC__ && __STDC__ +00300 static void exchange (char **); +00301 #endif +00302 +00303 static void +00304 exchange (argv) +00305 char **argv; +00306 { +00307 int bottom = first_nonopt; +00308 int middle = last_nonopt; +00309 int top = optind; +00310 char *tem; +00311 +00312 /* Exchange the shorter segment with the far end of the longer segment. +00313 That puts the shorter segment into the right place. +00314 It leaves the longer segment in the right place overall, +00315 but it consists of two parts that need to be swapped next. */ +00316 +00317 #if defined _LIBC && defined USE_NONOPTION_FLAGS +00318 /* First make sure the handling of the `__getopt_nonoption_flags' +00319 string can work normally. Our top argument must be in the range +00320 of the string. */ +00321 if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) +00322 { +00323 /* We must extend the array. The user plays games with us and +00324 presents new arguments. */ +00325 char *new_str = malloc (top + 1); +00326 if (new_str == NULL) +00327 nonoption_flags_len = nonoption_flags_max_len = 0; +00328 else +00329 { +00330 memset (__mempcpy (new_str, __getopt_nonoption_flags, +00331 nonoption_flags_max_len), +00332 '\0', top + 1 - nonoption_flags_max_len); +00333 nonoption_flags_max_len = top + 1; +00334 __getopt_nonoption_flags = new_str; +00335 } +00336 } +00337 #endif +00338 +00339 while (top > middle && middle > bottom) +00340 { +00341 if (top - middle > middle - bottom) +00342 { +00343 /* Bottom segment is the short one. */ +00344 int len = middle - bottom; +00345 register int i; +00346 +00347 /* Swap it with the top part of the top segment. */ +00348 for (i = 0; i < len; i++) +00349 { +00350 tem = argv[bottom + i]; +00351 argv[bottom + i] = argv[top - (middle - bottom) + i]; +00352 argv[top - (middle - bottom) + i] = tem; +00353 SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); +00354 } +00355 /* Exclude the moved bottom segment from further swapping. */ +00356 top -= len; +00357 } +00358 else +00359 { +00360 /* Top segment is the short one. */ +00361 int len = top - middle; +00362 register int i; +00363 +00364 /* Swap it with the bottom part of the bottom segment. */ +00365 for (i = 0; i < len; i++) +00366 { +00367 tem = argv[bottom + i]; +00368 argv[bottom + i] = argv[middle + i]; +00369 argv[middle + i] = tem; +00370 SWAP_FLAGS (bottom + i, middle + i); +00371 } +00372 /* Exclude the moved top segment from further swapping. */ +00373 bottom += len; +00374 } +00375 } +00376 +00377 /* Update records for the slots the non-options now occupy. */ +00378 +00379 first_nonopt += (optind - last_nonopt); +00380 last_nonopt = optind; +00381 } +00382 +00383 /* Initialize the internal data when the first call is made. */ +00384 +00385 #if defined __STDC__ && __STDC__ +00386 static const char *_getopt_initialize (int, char *const *, const char *); +00387 #endif +00388 static const char * +00389 _getopt_initialize (argc, argv, optstring) +00390 int argc; +00391 char *const *argv; +00392 const char *optstring; +00393 { +00394 /* Start processing options with ARGV-element 1 (since ARGV-element 0 +00395 is the program name); the sequence of previously skipped +00396 non-option ARGV-elements is empty. */ +00397 +00398 first_nonopt = last_nonopt = optind; +00399 +00400 nextchar = NULL; +00401 +00402 posixly_correct = getenv ("POSIXLY_CORRECT"); +00403 +00404 /* Determine how to handle the ordering of options and nonoptions. */ +00405 +00406 if (optstring[0] == '-') +00407 { +00408 ordering = RETURN_IN_ORDER; +00409 ++optstring; +00410 } +00411 else if (optstring[0] == '+') +00412 { +00413 ordering = REQUIRE_ORDER; +00414 ++optstring; +00415 } +00416 else if (posixly_correct != NULL) +00417 ordering = REQUIRE_ORDER; +00418 else +00419 ordering = PERMUTE; +00420 +00421 #if defined _LIBC && defined USE_NONOPTION_FLAGS +00422 if (posixly_correct == NULL +00423 && argc == __libc_argc && argv == __libc_argv) +00424 { +00425 if (nonoption_flags_max_len == 0) +00426 { +00427 if (__getopt_nonoption_flags == NULL +00428 || __getopt_nonoption_flags[0] == '\0') +00429 nonoption_flags_max_len = -1; +00430 else +00431 { +00432 const char *orig_str = __getopt_nonoption_flags; +00433 int len = nonoption_flags_max_len = strlen (orig_str); +00434 if (nonoption_flags_max_len < argc) +00435 nonoption_flags_max_len = argc; +00436 __getopt_nonoption_flags = +00437 (char *) malloc (nonoption_flags_max_len); +00438 if (__getopt_nonoption_flags == NULL) +00439 nonoption_flags_max_len = -1; +00440 else +00441 memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), +00442 '\0', nonoption_flags_max_len - len); +00443 } +00444 } +00445 nonoption_flags_len = nonoption_flags_max_len; +00446 } +00447 else +00448 nonoption_flags_len = 0; +00449 #endif +00450 +00451 return optstring; +00452 } +00453 +00454 /* Scan elements of ARGV (whose length is ARGC) for option characters +00455 given in OPTSTRING. +00456 +00457 If an element of ARGV starts with '-', and is not exactly "-" or "--", +00458 then it is an option element. The characters of this element +00459 (aside from the initial '-') are option characters. If `getopt' +00460 is called repeatedly, it returns successively each of the option characters +00461 from each of the option elements. +00462 +00463 If `getopt' finds another option character, it returns that character, +00464 updating `optind' and `nextchar' so that the next call to `getopt' can +00465 resume the scan with the following option character or ARGV-element. +00466 +00467 If there are no more option characters, `getopt' returns -1. +00468 Then `optind' is the index in ARGV of the first ARGV-element +00469 that is not an option. (The ARGV-elements have been permuted +00470 so that those that are not options now come last.) +00471 +00472 OPTSTRING is a string containing the legitimate option characters. +00473 If an option character is seen that is not listed in OPTSTRING, +00474 return '?' after printing an error message. If you set `opterr' to +00475 zero, the error message is suppressed but we still return '?'. +00476 +00477 If a char in OPTSTRING is followed by a colon, that means it wants an arg, +00478 so the following text in the same ARGV-element, or the text of the following +00479 ARGV-element, is returned in `optarg'. Two colons mean an option that +00480 wants an optional arg; if there is text in the current ARGV-element, +00481 it is returned in `optarg', otherwise `optarg' is set to zero. +00482 +00483 If OPTSTRING starts with `-' or `+', it requests different methods of +00484 handling the non-option ARGV-elements. +00485 See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. +00486 +00487 Long-named options begin with `--' instead of `-'. +00488 Their names may be abbreviated as long as the abbreviation is unique +00489 or is an exact match for some defined option. If they have an +00490 argument, it follows the option name in the same ARGV-element, separated +00491 from the option name by a `=', or else the in next ARGV-element. +00492 When `getopt' finds a long-named option, it returns 0 if that option's +00493 `flag' field is nonzero, the value of the option's `val' field +00494 if the `flag' field is zero. +00495 +00496 The elements of ARGV aren't really const, because we permute them. +00497 But we pretend they're const in the prototype to be compatible +00498 with other systems. +00499 +00500 LONGOPTS is a vector of `struct option' terminated by an +00501 element containing a name which is zero. +00502 +00503 LONGIND returns the index in LONGOPT of the long-named option found. +00504 It is only valid when a long-named option has been found by the most +00505 recent call. +00506 +00507 If LONG_ONLY is nonzero, '-' as well as '--' can introduce +00508 long-named options. */ +00509 +00510 int +00511 _getopt_internal (argc, argv, optstring, longopts, longind, long_only) +00512 int argc; +00513 char *const *argv; +00514 const char *optstring; +00515 const struct option *longopts; +00516 int *longind; +00517 int long_only; +00518 { +00519 int print_errors = opterr; +00520 if (optstring[0] == ':') +00521 print_errors = 0; +00522 +00523 if (argc < 1) +00524 return -1; +00525 +00526 optarg = NULL; +00527 +00528 if (optind == 0 || !__getopt_initialized) +00529 { +00530 if (optind == 0) +00531 optind = 1; /* Don't scan ARGV[0], the program name. */ +00532 optstring = _getopt_initialize (argc, argv, optstring); +00533 __getopt_initialized = 1; +00534 } +00535 +00536 /* Test whether ARGV[optind] points to a non-option argument. +00537 Either it does not have option syntax, or there is an environment flag +00538 from the shell indicating it is not an option. The later information +00539 is only used when the used in the GNU libc. */ +00540 #if defined _LIBC && defined USE_NONOPTION_FLAGS +00541 # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ +00542 || (optind < nonoption_flags_len \ +00543 && __getopt_nonoption_flags[optind] == '1')) +00544 #else +00545 # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +00546 #endif +00547 +00548 if (nextchar == NULL || *nextchar == '\0') +00549 { +00550 /* Advance to the next ARGV-element. */ +00551 +00552 /* Give FIRST_NONOPT and LAST_NONOPT rational values if OPTIND has been +00553 moved back by the user (who may also have changed the arguments). */ +00554 if (last_nonopt > optind) +00555 last_nonopt = optind; +00556 if (first_nonopt > optind) +00557 first_nonopt = optind; +00558 +00559 if (ordering == PERMUTE) +00560 { +00561 /* If we have just processed some options following some non-options, +00562 exchange them so that the options come first. */ +00563 +00564 if (first_nonopt != last_nonopt && last_nonopt != optind) +00565 exchange ((char **) argv); +00566 else if (last_nonopt != optind) +00567 first_nonopt = optind; +00568 +00569 /* Skip any additional non-options +00570 and extend the range of non-options previously skipped. */ +00571 +00572 while (optind < argc && NONOPTION_P) +00573 optind++; +00574 last_nonopt = optind; +00575 } +00576 +00577 /* The special ARGV-element `--' means premature end of options. +00578 Skip it like a null option, +00579 then exchange with previous non-options as if it were an option, +00580 then skip everything else like a non-option. */ +00581 +00582 if (optind != argc && !strcmp (argv[optind], "--")) +00583 { +00584 optind++; +00585 +00586 if (first_nonopt != last_nonopt && last_nonopt != optind) +00587 exchange ((char **) argv); +00588 else if (first_nonopt == last_nonopt) +00589 first_nonopt = optind; +00590 last_nonopt = argc; +00591 +00592 optind = argc; +00593 } +00594 +00595 /* If we have done all the ARGV-elements, stop the scan +00596 and back over any non-options that we skipped and permuted. */ +00597 +00598 if (optind == argc) +00599 { +00600 /* Set the next-arg-index to point at the non-options +00601 that we previously skipped, so the caller will digest them. */ +00602 if (first_nonopt != last_nonopt) +00603 optind = first_nonopt; +00604 return -1; +00605 } +00606 +00607 /* If we have come to a non-option and did not permute it, +00608 either stop the scan or describe it to the caller and pass it by. */ +00609 +00610 if (NONOPTION_P) +00611 { +00612 if (ordering == REQUIRE_ORDER) +00613 return -1; +00614 optarg = argv[optind++]; +00615 return 1; +00616 } +00617 +00618 /* We have found another option-ARGV-element. +00619 Skip the initial punctuation. */ +00620 +00621 nextchar = (argv[optind] + 1 +00622 + (longopts != NULL && argv[optind][1] == '-')); +00623 } +00624 +00625 /* Decode the current option-ARGV-element. */ +00626 +00627 /* Check whether the ARGV-element is a long option. +00628 +00629 If long_only and the ARGV-element has the form "-f", where f is +00630 a valid short option, don't consider it an abbreviated form of +00631 a long option that starts with f. Otherwise there would be no +00632 way to give the -f short option. +00633 +00634 On the other hand, if there's a long option "fubar" and +00635 the ARGV-element is "-fu", do consider that an abbreviation of +00636 the long option, just like "--fu", and not "-f" with arg "u". +00637 +00638 This distinction seems to be the most useful approach. */ +00639 +00640 if (longopts != NULL +00641 && (argv[optind][1] == '-' +00642 || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) +00643 { +00644 char *nameend; +00645 const struct option *p; +00646 const struct option *pfound = NULL; +00647 int exact = 0; +00648 int ambig = 0; +00649 int indfound = -1; +00650 int option_index; +00651 +00652 for (nameend = nextchar; *nameend && *nameend != '='; nameend++) +00653 /* Do nothing. */ ; +00654 +00655 /* Test all long options for either exact match +00656 or abbreviated matches. */ +00657 for (p = longopts, option_index = 0; p->name; p++, option_index++) +00658 if (!strncmp (p->name, nextchar, nameend - nextchar)) +00659 { +00660 if ((unsigned int) (nameend - nextchar) +00661 == (unsigned int) strlen (p->name)) +00662 { +00663 /* Exact match found. */ +00664 pfound = p; +00665 indfound = option_index; +00666 exact = 1; +00667 break; +00668 } +00669 else if (pfound == NULL) +00670 { +00671 /* First nonexact match found. */ +00672 pfound = p; +00673 indfound = option_index; +00674 } +00675 else if (long_only +00676 || pfound->has_arg != p->has_arg +00677 || pfound->flag != p->flag +00678 || pfound->val != p->val) +00679 /* Second or later nonexact match found. */ +00680 ambig = 1; +00681 } +00682 +00683 if (ambig && !exact) +00684 { +00685 if (print_errors) +00686 { +00687 #if defined _LIBC && defined USE_IN_LIBIO +00688 char *buf; +00689 +00690 __asprintf (&buf, _("%s: option `%s' is ambiguous\n"), +00691 argv[0], argv[optind]); +00692 +00693 if (_IO_fwide (stderr, 0) > 0) +00694 __fwprintf (stderr, L"%s", buf); +00695 else +00696 fputs (buf, stderr); +00697 +00698 free (buf); +00699 #else +00700 fprintf (stderr, _("%s: option `%s' is ambiguous\n"), +00701 argv[0], argv[optind]); +00702 #endif +00703 } +00704 nextchar += strlen (nextchar); +00705 optind++; +00706 optopt = 0; +00707 return '?'; +00708 } +00709 +00710 if (pfound != NULL) +00711 { +00712 option_index = indfound; +00713 optind++; +00714 if (*nameend) +00715 { +00716 /* Don't test has_arg with >, because some C compilers don't +00717 allow it to be used on enums. */ +00718 if (pfound->has_arg) +00719 optarg = nameend + 1; +00720 else +00721 { +00722 if (print_errors) +00723 { +00724 #if defined _LIBC && defined USE_IN_LIBIO +00725 char *buf; +00726 #endif +00727 +00728 if (argv[optind - 1][1] == '-') +00729 { +00730 /* --option */ +00731 #if defined _LIBC && defined USE_IN_LIBIO +00732 __asprintf (&buf, _("\ +00733 %s: option `--%s' doesn't allow an argument\n"), +00734 argv[0], pfound->name); +00735 #else +00736 fprintf (stderr, _("\ +00737 %s: option `--%s' doesn't allow an argument\n"), +00738 argv[0], pfound->name); +00739 #endif +00740 } +00741 else +00742 { +00743 /* +option or -option */ +00744 #if defined _LIBC && defined USE_IN_LIBIO +00745 __asprintf (&buf, _("\ +00746 %s: option `%c%s' doesn't allow an argument\n"), +00747 argv[0], argv[optind - 1][0], +00748 pfound->name); +00749 #else +00750 fprintf (stderr, _("\ +00751 %s: option `%c%s' doesn't allow an argument\n"), +00752 argv[0], argv[optind - 1][0], pfound->name); +00753 #endif +00754 } +00755 +00756 #if defined _LIBC && defined USE_IN_LIBIO +00757 if (_IO_fwide (stderr, 0) > 0) +00758 __fwprintf (stderr, L"%s", buf); +00759 else +00760 fputs (buf, stderr); +00761 +00762 free (buf); +00763 #endif +00764 } +00765 +00766 nextchar += strlen (nextchar); +00767 +00768 optopt = pfound->val; +00769 return '?'; +00770 } +00771 } +00772 else if (pfound->has_arg == 1) +00773 { +00774 if (optind < argc) +00775 optarg = argv[optind++]; +00776 else +00777 { +00778 if (print_errors) +00779 { +00780 #if defined _LIBC && defined USE_IN_LIBIO +00781 char *buf; +00782 +00783 __asprintf (&buf, +00784 _("%s: option `%s' requires an argument\n"), +00785 argv[0], argv[optind - 1]); +00786 +00787 if (_IO_fwide (stderr, 0) > 0) +00788 __fwprintf (stderr, L"%s", buf); +00789 else +00790 fputs (buf, stderr); +00791 +00792 free (buf); +00793 #else +00794 fprintf (stderr, +00795 _("%s: option `%s' requires an argument\n"), +00796 argv[0], argv[optind - 1]); +00797 #endif +00798 } +00799 nextchar += strlen (nextchar); +00800 optopt = pfound->val; +00801 return optstring[0] == ':' ? ':' : '?'; +00802 } +00803 } +00804 nextchar += strlen (nextchar); +00805 if (longind != NULL) +00806 *longind = option_index; +00807 if (pfound->flag) +00808 { +00809 *(pfound->flag) = pfound->val; +00810 return 0; +00811 } +00812 return pfound->val; +00813 } +00814 +00815 /* Can't find it as a long option. If this is not getopt_long_only, +00816 or the option starts with '--' or is not a valid short +00817 option, then it's an error. +00818 Otherwise interpret it as a short option. */ +00819 if (!long_only || argv[optind][1] == '-' +00820 || my_index (optstring, *nextchar) == NULL) +00821 { +00822 if (print_errors) +00823 { +00824 #if defined _LIBC && defined USE_IN_LIBIO +00825 char *buf; +00826 #endif +00827 +00828 if (argv[optind][1] == '-') +00829 { +00830 /* --option */ +00831 #if defined _LIBC && defined USE_IN_LIBIO +00832 __asprintf (&buf, _("%s: unrecognized option `--%s'\n"), +00833 argv[0], nextchar); +00834 #else +00835 fprintf (stderr, _("%s: unrecognized option `--%s'\n"), +00836 argv[0], nextchar); +00837 #endif +00838 } +00839 else +00840 { +00841 /* +option or -option */ +00842 #if defined _LIBC && defined USE_IN_LIBIO +00843 __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"), +00844 argv[0], argv[optind][0], nextchar); +00845 #else +00846 fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), +00847 argv[0], argv[optind][0], nextchar); +00848 #endif +00849 } +00850 +00851 #if defined _LIBC && defined USE_IN_LIBIO +00852 if (_IO_fwide (stderr, 0) > 0) +00853 __fwprintf (stderr, L"%s", buf); +00854 else +00855 fputs (buf, stderr); +00856 +00857 free (buf); +00858 #endif +00859 } +00860 nextchar = (char *) ""; +00861 optind++; +00862 optopt = 0; +00863 return '?'; +00864 } +00865 } +00866 +00867 /* Look at and handle the next short option-character. */ +00868 +00869 { +00870 char c = *nextchar++; +00871 char *temp = my_index (optstring, c); +00872 +00873 /* Increment `optind' when we start to process its last character. */ +00874 if (*nextchar == '\0') +00875 ++optind; +00876 +00877 if (temp == NULL || c == ':') +00878 { +00879 if (print_errors) +00880 { +00881 #if defined _LIBC && defined USE_IN_LIBIO +00882 char *buf; +00883 #endif +00884 +00885 if (posixly_correct) +00886 { +00887 /* 1003.2 specifies the format of this message. */ +00888 #if defined _LIBC && defined USE_IN_LIBIO +00889 __asprintf (&buf, _("%s: illegal option -- %c\n"), +00890 argv[0], c); +00891 #else +00892 fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); +00893 #endif +00894 } +00895 else +00896 { +00897 #if defined _LIBC && defined USE_IN_LIBIO +00898 __asprintf (&buf, _("%s: invalid option -- %c\n"), +00899 argv[0], c); +00900 #else +00901 fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); +00902 #endif +00903 } +00904 +00905 #if defined _LIBC && defined USE_IN_LIBIO +00906 if (_IO_fwide (stderr, 0) > 0) +00907 __fwprintf (stderr, L"%s", buf); +00908 else +00909 fputs (buf, stderr); +00910 +00911 free (buf); +00912 #endif +00913 } +00914 optopt = c; +00915 return '?'; +00916 } +00917 /* Convenience. Treat POSIX -W foo same as long option --foo */ +00918 if (temp[0] == 'W' && temp[1] == ';') +00919 { +00920 char *nameend; +00921 const struct option *p; +00922 const struct option *pfound = NULL; +00923 int exact = 0; +00924 int ambig = 0; +00925 int indfound = 0; +00926 int option_index; +00927 +00928 /* This is an option that requires an argument. */ +00929 if (*nextchar != '\0') +00930 { +00931 optarg = nextchar; +00932 /* If we end this ARGV-element by taking the rest as an arg, +00933 we must advance to the next element now. */ +00934 optind++; +00935 } +00936 else if (optind == argc) +00937 { +00938 if (print_errors) +00939 { +00940 /* 1003.2 specifies the format of this message. */ +00941 #if defined _LIBC && defined USE_IN_LIBIO +00942 char *buf; +00943 +00944 __asprintf (&buf, _("%s: option requires an argument -- %c\n"), +00945 argv[0], c); +00946 +00947 if (_IO_fwide (stderr, 0) > 0) +00948 __fwprintf (stderr, L"%s", buf); +00949 else +00950 fputs (buf, stderr); +00951 +00952 free (buf); +00953 #else +00954 fprintf (stderr, _("%s: option requires an argument -- %c\n"), +00955 argv[0], c); +00956 #endif +00957 } +00958 optopt = c; +00959 if (optstring[0] == ':') +00960 c = ':'; +00961 else +00962 c = '?'; +00963 return c; +00964 } +00965 else +00966 /* We already incremented `optind' once; +00967 increment it again when taking next ARGV-elt as argument. */ +00968 optarg = argv[optind++]; +00969 +00970 /* optarg is now the argument, see if it's in the +00971 table of longopts. */ +00972 +00973 for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) +00974 /* Do nothing. */ ; +00975 +00976 /* Test all long options for either exact match +00977 or abbreviated matches. */ +00978 for (p = longopts, option_index = 0; p->name; p++, option_index++) +00979 if (!strncmp (p->name, nextchar, nameend - nextchar)) +00980 { +00981 if ((unsigned int) (nameend - nextchar) == strlen (p->name)) +00982 { +00983 /* Exact match found. */ +00984 pfound = p; +00985 indfound = option_index; +00986 exact = 1; +00987 break; +00988 } +00989 else if (pfound == NULL) +00990 { +00991 /* First nonexact match found. */ +00992 pfound = p; +00993 indfound = option_index; +00994 } +00995 else +00996 /* Second or later nonexact match found. */ +00997 ambig = 1; +00998 } +00999 if (ambig && !exact) +01000 { +01001 if (print_errors) +01002 { +01003 #if defined _LIBC && defined USE_IN_LIBIO +01004 char *buf; +01005 +01006 __asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), +01007 argv[0], argv[optind]); +01008 +01009 if (_IO_fwide (stderr, 0) > 0) +01010 __fwprintf (stderr, L"%s", buf); +01011 else +01012 fputs (buf, stderr); +01013 +01014 free (buf); +01015 #else +01016 fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), +01017 argv[0], argv[optind]); +01018 #endif +01019 } +01020 nextchar += strlen (nextchar); +01021 optind++; +01022 return '?'; +01023 } +01024 if (pfound != NULL) +01025 { +01026 option_index = indfound; +01027 if (*nameend) +01028 { +01029 /* Don't test has_arg with >, because some C compilers don't +01030 allow it to be used on enums. */ +01031 if (pfound->has_arg) +01032 optarg = nameend + 1; +01033 else +01034 { +01035 if (print_errors) +01036 { +01037 #if defined _LIBC && defined USE_IN_LIBIO +01038 char *buf; +01039 +01040 __asprintf (&buf, _("\ +01041 %s: option `-W %s' doesn't allow an argument\n"), +01042 argv[0], pfound->name); +01043 +01044 if (_IO_fwide (stderr, 0) > 0) +01045 __fwprintf (stderr, L"%s", buf); +01046 else +01047 fputs (buf, stderr); +01048 +01049 free (buf); +01050 #else +01051 fprintf (stderr, _("\ +01052 %s: option `-W %s' doesn't allow an argument\n"), +01053 argv[0], pfound->name); +01054 #endif +01055 } +01056 +01057 nextchar += strlen (nextchar); +01058 return '?'; +01059 } +01060 } +01061 else if (pfound->has_arg == 1) +01062 { +01063 if (optind < argc) +01064 optarg = argv[optind++]; +01065 else +01066 { +01067 if (print_errors) +01068 { +01069 #if defined _LIBC && defined USE_IN_LIBIO +01070 char *buf; +01071 +01072 __asprintf (&buf, _("\ +01073 %s: option `%s' requires an argument\n"), +01074 argv[0], argv[optind - 1]); +01075 +01076 if (_IO_fwide (stderr, 0) > 0) +01077 __fwprintf (stderr, L"%s", buf); +01078 else +01079 fputs (buf, stderr); +01080 +01081 free (buf); +01082 #else +01083 fprintf (stderr, +01084 _("%s: option `%s' requires an argument\n"), +01085 argv[0], argv[optind - 1]); +01086 #endif +01087 } +01088 nextchar += strlen (nextchar); +01089 return optstring[0] == ':' ? ':' : '?'; +01090 } +01091 } +01092 nextchar += strlen (nextchar); +01093 if (longind != NULL) +01094 *longind = option_index; +01095 if (pfound->flag) +01096 { +01097 *(pfound->flag) = pfound->val; +01098 return 0; +01099 } +01100 return pfound->val; +01101 } +01102 nextchar = NULL; +01103 return 'W'; /* Let the application handle it. */ +01104 } +01105 if (temp[1] == ':') +01106 { +01107 if (temp[2] == ':') +01108 { +01109 /* This is an option that accepts an argument optionally. */ +01110 if (*nextchar != '\0') +01111 { +01112 optarg = nextchar; +01113 optind++; +01114 } +01115 else +01116 optarg = NULL; +01117 nextchar = NULL; +01118 } +01119 else +01120 { +01121 /* This is an option that requires an argument. */ +01122 if (*nextchar != '\0') +01123 { +01124 optarg = nextchar; +01125 /* If we end this ARGV-element by taking the rest as an arg, +01126 we must advance to the next element now. */ +01127 optind++; +01128 } +01129 else if (optind == argc) +01130 { +01131 if (print_errors) +01132 { +01133 /* 1003.2 specifies the format of this message. */ +01134 #if defined _LIBC && defined USE_IN_LIBIO +01135 char *buf; +01136 +01137 __asprintf (&buf, +01138 _("%s: option requires an argument -- %c\n"), +01139 argv[0], c); +01140 +01141 if (_IO_fwide (stderr, 0) > 0) +01142 __fwprintf (stderr, L"%s", buf); +01143 else +01144 fputs (buf, stderr); +01145 +01146 free (buf); +01147 #else +01148 fprintf (stderr, +01149 _("%s: option requires an argument -- %c\n"), +01150 argv[0], c); +01151 #endif +01152 } +01153 optopt = c; +01154 if (optstring[0] == ':') +01155 c = ':'; +01156 else +01157 c = '?'; +01158 } +01159 else +01160 /* We already incremented `optind' once; +01161 increment it again when taking next ARGV-elt as argument. */ +01162 optarg = argv[optind++]; +01163 nextchar = NULL; +01164 } +01165 } +01166 return c; +01167 } +01168 } +01169 +01170 int +01171 getopt (argc, argv, optstring) +01172 int argc; +01173 char *const *argv; +01174 const char *optstring; +01175 { +01176 return _getopt_internal (argc, argv, optstring, +01177 (const struct option *) 0, +01178 (int *) 0, +01179 0); +01180 } +01181 +01182 #endif /* Not ELIDE_CODE. */ +01183 +01184 +01185 /* Compile with -DTEST to make an executable for use in testing +01186 the above definition of `getopt'. */ +01187 +01188 /* #define TEST */ /* Pete Wilson mod 7/28/02 */ +01189 #ifdef TEST +01190 +01191 #ifndef exit /* Pete Wilson mod 7/28/02 */ +01192 int exit(int); /* Pete Wilson mod 7/28/02 */ +01193 #endif /* Pete Wilson mod 7/28/02 */ +01194 +01195 int +01196 main (argc, argv) +01197 int argc; +01198 char **argv; +01199 { +01200 int c; +01201 int digit_optind = 0; +01202 +01203 while (1) +01204 { +01205 int this_option_optind = optind ? optind : 1; +01206 +01207 c = getopt (argc, argv, "abc:d:0123456789"); +01208 if (c == -1) +01209 break; +01210 +01211 switch (c) +01212 { +01213 case '0': +01214 case '1': +01215 case '2': +01216 case '3': +01217 case '4': +01218 case '5': +01219 case '6': +01220 case '7': +01221 case '8': +01222 case '9': +01223 if (digit_optind != 0 && digit_optind != this_option_optind) +01224 printf ("digits occur in two different argv-elements.\n"); +01225 digit_optind = this_option_optind; +01226 printf ("option %c\n", c); +01227 break; +01228 +01229 case 'a': +01230 printf ("option a\n"); +01231 break; +01232 +01233 case 'b': +01234 printf ("option b\n"); +01235 break; +01236 +01237 case 'c': +01238 printf ("option c with value `%s'\n", optarg); +01239 break; +01240 +01241 case '?': +01242 break; +01243 +01244 default: +01245 printf ("?? getopt returned character code 0%o ??\n", c); +01246 } +01247 } +01248 +01249 if (optind < argc) +01250 { +01251 printf ("non-option ARGV-elements: "); +01252 while (optind < argc) +01253 printf ("%s ", argv[optind++]); +01254 printf ("\n"); +01255 } +01256 +01257 exit (0); +01258 } +01259 +01260 #endif /* TEST */ +
#include <stdio.h>
#include "getopt.h"
#include <strings.h>
+Include dependency graph for getopt.c:
+Go to the source code of this file.
Defines | |
#define | GETOPT_INTERFACE_VERSION 2 |
#define | _(msgid) (msgid) |
#define | SWAP_FLAGS(ch1, ch2) |
#define | NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') |
Enumerations | |
enum | { REQUIRE_ORDER, +PERMUTE, +RETURN_IN_ORDER + } |
Functions | |
char * | getenv () |
int | _getopt_internal (int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only) |
int | getopt (int argc, char *const *argv, const char *optstring) |
Variables | |
char * | optarg |
int | optind = 1 |
int | __getopt_initialized |
int | opterr = 1 |
int | optopt = '?' |
#define _ | +( | +msgid | ++ | ) | +(msgid) | +
#define GETOPT_INTERFACE_VERSION 2 | +
+ +
+Referenced by _getopt_internal(). +
#define SWAP_FLAGS | +( | +ch1, | |||
+ | + | ch2 | ++ | ) | ++ |
+
anonymous enum | +
+
int _getopt_internal | +( | +int | +argc, | +|
+ | + | char *const * | +argv, | +|
+ | + | const char * | +optstring, | +|
+ | + | const struct option * | +longopts, | +|
+ | + | int * | +longind, | +|
+ | + | int | +long_only | + |
+ | ) | ++ |
+ +
+Definition at line 511 of file getopt.c. +
+References __getopt_initialized, option::name, NONOPTION_P, optarg, opterr, optind, PERMUTE, and REQUIRE_ORDER. +
+Referenced by getopt(). +
char* getenv | +( | ++ | ) | ++ |
+ +
int getopt | +( | +int | +argc, | +|
+ | + | char *const * | +argv, | +|
+ | + | const char * | +optstring | + |
+ | ) | ++ |
+ +
+Definition at line 1171 of file getopt.c. +
+References _getopt_internal(). +
+Referenced by main(). +
+Here is the call graph for this function:
+
int __getopt_initialized | +
char* optarg | +
+ +
+Definition at line 118 of file getopt.c. +
+Referenced by _getopt_internal(), and main(). +
int opterr = 1 | +
int optind = 1 | +
+
00001 /* from http://www.pwilson.net/getopt.html */ +00002 +00003 /* getopt.h */ +00004 /* Declarations for getopt. +00005 Copyright (C) 1989-1994, 1996-1999, 2001 Free Software +00006 Foundation, Inc. This file is part of the GNU C Library. +00007 +00008 The GNU C Library is free software; you can redistribute +00009 it and/or modify it under the terms of the GNU Lesser +00010 General Public License as published by the Free Software +00011 Foundation; either version 2.1 of the License, or +00012 (at your option) any later version. +00013 +00014 The GNU C Library is distributed in the hope that it will +00015 be useful, but WITHOUT ANY WARRANTY; without even the +00016 implied warranty of MERCHANTABILITY or FITNESS FOR A +00017 PARTICULAR PURPOSE. See the GNU Lesser General Public +00018 License for more details. +00019 +00020 You should have received a copy of the GNU Lesser General +00021 Public License along with the GNU C Library; if not, write +00022 to the Free Software Foundation, Inc., 59 Temple Place, +00023 Suite 330, Boston, MA 02111-1307 USA. */ +00024 +00025 +00026 +00027 +00028 +00029 #ifndef _GETOPT_H +00030 +00031 #ifndef __need_getopt +00032 # define _GETOPT_H 1 +00033 #endif +00034 +00035 /* If __GNU_LIBRARY__ is not already defined, either we are being used +00036 standalone, or this is the first header included in the source file. +00037 If we are being used with glibc, we need to include <features.h>, but +00038 that does not exist if we are standalone. So: if __GNU_LIBRARY__ is +00039 not defined, include <ctype.h>, which will pull in <features.h> for us +00040 if it's from glibc. (Why ctype.h? It's guaranteed to exist and it +00041 doesn't flood the namespace with stuff the way some other headers do.) */ +00042 #if !defined __GNU_LIBRARY__ +00043 # include <ctype.h> +00044 #endif +00045 +00046 #ifdef __cplusplus +00047 extern "C" { +00048 #endif +00049 +00050 /* For communication from `getopt' to the caller. +00051 When `getopt' finds an option that takes an argument, +00052 the argument value is returned here. +00053 Also, when `ordering' is RETURN_IN_ORDER, +00054 each non-option ARGV-element is returned here. */ +00055 +00056 extern char *optarg; +00057 +00058 /* Index in ARGV of the next element to be scanned. +00059 This is used for communication to and from the caller +00060 and for communication between successive calls to `getopt'. +00061 +00062 On entry to `getopt', zero means this is the first call; initialize. +00063 +00064 When `getopt' returns -1, this is the index of the first of the +00065 non-option elements that the caller should itself scan. +00066 +00067 Otherwise, `optind' communicates from one call to the next +00068 how much of ARGV has been scanned so far. */ +00069 +00070 extern int optind; +00071 +00072 /* Callers store zero here to inhibit the error message `getopt' prints +00073 for unrecognized options. */ +00074 +00075 extern int opterr; +00076 +00077 /* Set to an option character which was unrecognized. */ +00078 +00079 extern int optopt; +00080 +00081 #ifndef __need_getopt +00082 /* Describe the long-named options requested by the application. +00083 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector +00084 of `struct option' terminated by an element containing a name which is +00085 zero. +00086 +00087 The field `has_arg' is: +00088 no_argument (or 0) if the option does not take an argument, +00089 required_argument (or 1) if the option requires an argument, +00090 optional_argument (or 2) if the option takes an optional argument. +00091 +00092 If the field `flag' is not NULL, it points to a variable that is set +00093 to the value given in the field `val' when the option is found, but +00094 left unchanged if the option is not found. +00095 +00096 To have a long-named option do something other than set an `int' to +00097 a compiled-in constant, such as set a value from `optarg', set the +00098 option's `flag' field to zero and its `val' field to a nonzero +00099 value (the equivalent single-letter option character, if there is +00100 one). For long options that have a zero `flag' field, `getopt' +00101 returns the contents of the `val' field. */ +00102 +00103 struct option +00104 { +00105 # if (defined __STDC__ && __STDC__) || defined __cplusplus +00106 const char *name; +00107 # else +00108 char *name; +00109 # endif +00110 /* has_arg can't be an enum because some compilers complain about +00111 type mismatches in all the code that assumes it is an int. */ +00112 int has_arg; +00113 int *flag; +00114 int val; +00115 }; +00116 +00117 /* Names for the values of the `has_arg' field of `struct option'. */ +00118 +00119 # define no_argument 0 +00120 # define required_argument 1 +00121 # define optional_argument 2 +00122 #endif /* need getopt */ +00123 +00124 +00125 /* Get definitions and prototypes for functions to process the +00126 arguments in ARGV (ARGC of them, minus the program name) for +00127 options given in OPTS. +00128 +00129 Return the option character from OPTS just read. Return -1 when +00130 there are no more options. For unrecognized options, or options +00131 missing arguments, `optopt' is set to the option letter, and '?' is +00132 returned. +00133 +00134 The OPTS string is a list of characters which are recognized option +00135 letters, optionally followed by colons, specifying that that letter +00136 takes an argument, to be placed in `optarg'. +00137 +00138 If a letter in OPTS is followed by two colons, its argument is +00139 optional. This behavior is specific to the GNU `getopt'. +00140 +00141 The argument `--' causes premature termination of argument +00142 scanning, explicitly telling `getopt' that there are no more +00143 options. +00144 +00145 If OPTS begins with `--', then non-option arguments are treated as +00146 arguments to the option '\0'. This behavior is specific to the GNU +00147 `getopt'. */ +00148 +00149 #if (defined __STDC__ && __STDC__) || defined __cplusplus +00150 # ifdef __GNU_LIBRARY__ +00151 /* Many other libraries have conflicting prototypes for getopt, with +00152 differences in the consts, in stdlib.h. To avoid compilation +00153 errors, only prototype getopt for the GNU C library. */ +00154 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); +00155 # else /* not __GNU_LIBRARY__ */ +00156 extern int getopt (); +00157 # endif /* __GNU_LIBRARY__ */ +00158 +00159 # ifndef __need_getopt +00160 extern int getopt_long (int ___argc, char *const *___argv, +00161 const char *__shortopts, +00162 const struct option *__longopts, int *__longind); +00163 extern int getopt_long_only (int ___argc, char *const *___argv, +00164 const char *__shortopts, +00165 const struct option *__longopts, int *__longind); +00166 +00167 /* Internal only. Users should not call this directly. */ +00168 extern int _getopt_internal (int ___argc, char *const *___argv, +00169 const char *__shortopts, +00170 const struct option *__longopts, int *__longind, +00171 int __long_only); +00172 # endif +00173 #else /* not __STDC__ */ +00174 extern int getopt (); +00175 # ifndef __need_getopt +00176 extern int getopt_long (); +00177 extern int getopt_long_only (); +00178 +00179 extern int _getopt_internal (); +00180 # endif +00181 #endif /* __STDC__ */ +00182 +00183 #ifdef __cplusplus +00184 } +00185 #endif +00186 +00187 /* Make sure we later can get all the definitions and declarations. */ +00188 #undef __need_getopt +00189 +00190 #endif /* getopt.h */ +00191 +
#include <ctype.h>
+Include dependency graph for getopt.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Data Structures | |
struct | option |
Defines | |
#define | _GETOPT_H 1 |
#define | no_argument 0 |
#define | required_argument 1 |
#define | optional_argument 2 |
Functions | |
int | getopt () |
int | getopt_long () |
int | getopt_long_only () |
int | _getopt_internal () |
Variables | |
char * | optarg |
int | optind |
int | opterr |
int | optopt |
+
int _getopt_internal | +( | ++ | ) | ++ |
+ +
int getopt | +( | ++ | ) | ++ |
+ +
int getopt_long | +( | ++ | ) | ++ |
+ +
int getopt_long_only | +( | ++ | ) | ++ |
+ +
+
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #if defined(WIN32) && !defined(__CYGWIN__) +00024 #include <windows.h> +00025 #include "getopt.h" +00026 void pause(void) +00027 { +00028 system("PAUSE"); +00029 } +00030 #else +00031 #include <stdio.h> +00032 #include <string.h> +00033 #include <unistd.h> +00034 #include <stdlib.h> +00035 #include <signal.h> +00036 #endif +00037 +00038 #include "canfestival.h" +00039 //#include <can_driver.h> +00040 //#include <timers_driver.h> +00041 +00042 #include "Master.h" +00043 #include "Slave.h" +00044 #include "TestMasterSlave.h" +00045 +00046 UNS32 OnMasterMap1Update(CO_Data* d, const indextable * unsused_indextable, UNS8 unsused_bSubindex) +00047 { +00048 eprintf("OnSlaveMap1Update:%d\n", SlaveMap1); +00049 return 0; +00050 } +00051 +00052 s_BOARD SlaveBoard = {"0", "125K"}; +00053 s_BOARD MasterBoard = {"1", "125K"}; +00054 +00055 #if !defined(WIN32) || defined(__CYGWIN__) +00056 void catch_signal(int sig) +00057 { +00058 signal(SIGTERM, catch_signal); +00059 signal(SIGINT, catch_signal); +00060 eprintf("Got Signal %d\n",sig); +00061 } +00062 #endif +00063 +00064 void help() +00065 { +00066 printf("**************************************************************\n"); +00067 printf("* TestMasterSlave *\n"); +00068 printf("* *\n"); +00069 printf("* A simple example for PC. It does implement 2 CanOpen *\n"); +00070 printf("* nodes in the same process. A master and a slave. Both *\n"); +00071 printf("* communicate together, exchanging periodically NMT, SYNC, *\n"); +00072 printf("* SDO and PDO. Master configure heartbeat producer time *\n"); +00073 printf("* at 1000 ms for slave node-id 0x02 by concise DCF. *\n"); +00074 printf("* *\n"); +00075 printf("* Usage: *\n"); +00076 printf("* ./TestMasterSlave [OPTIONS] *\n"); +00077 printf("* *\n"); +00078 printf("* OPTIONS: *\n"); +00079 printf("* -l : Can library [\"libcanfestival_can_virtual.so\"] *\n"); +00080 printf("* *\n"); +00081 printf("* Slave: *\n"); +00082 printf("* -s : bus name [\"0\"] *\n"); +00083 printf("* -S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *\n"); +00084 printf("* *\n"); +00085 printf("* Master: *\n"); +00086 printf("* -m : bus name [\"1\"] *\n"); +00087 printf("* -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) *\n"); +00088 printf("* *\n"); +00089 printf("**************************************************************\n"); +00090 } +00091 +00092 /*************************** INIT *****************************************/ +00093 void InitNodes(CO_Data* d, UNS32 id) +00094 { +00095 /****************************** INITIALISATION SLAVE *******************************/ +00096 if(strcmp(SlaveBoard.baudrate, "none")) { +00097 /* Defining the node Id */ +00098 setNodeId(&TestSlave_Data, 0x02); +00099 /* init */ +00100 setState(&TestSlave_Data, Initialisation); +00101 } +00102 +00103 /****************************** INITIALISATION MASTER *******************************/ +00104 if(strcmp(MasterBoard.baudrate, "none")){ +00105 RegisterSetODentryCallBack(&TestMaster_Data, 0x2000, 0, &OnMasterMap1Update); +00106 +00107 /* Defining the node Id */ +00108 setNodeId(&TestMaster_Data, 0x01); +00109 +00110 /* init */ +00111 setState(&TestMaster_Data, Initialisation); +00112 +00113 } +00114 } +00115 +00116 /****************************************************************************/ +00117 /*************************** MAIN *****************************************/ +00118 /****************************************************************************/ +00119 int main(int argc,char **argv) +00120 { +00121 +00122 int c; +00123 extern char *optarg; +00124 char* LibraryPath="libcanfestival_can_virtual.so"; +00125 +00126 while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF) +00127 { +00128 switch(c) +00129 { +00130 case 's' : +00131 if (optarg[0] == 0) +00132 { +00133 help(); +00134 exit(1); +00135 } +00136 SlaveBoard.busname = optarg; +00137 break; +00138 case 'm' : +00139 if (optarg[0] == 0) +00140 { +00141 help(); +00142 exit(1); +00143 } +00144 MasterBoard.busname = optarg; +00145 break; +00146 case 'S' : +00147 if (optarg[0] == 0) +00148 { +00149 help(); +00150 exit(1); +00151 } +00152 SlaveBoard.baudrate = optarg; +00153 break; +00154 case 'M' : +00155 if (optarg[0] == 0) +00156 { +00157 help(); +00158 exit(1); +00159 } +00160 MasterBoard.baudrate = optarg; +00161 break; +00162 case 'l' : +00163 if (optarg[0] == 0) +00164 { +00165 help(); +00166 exit(1); +00167 } +00168 LibraryPath = optarg; +00169 break; +00170 default: +00171 help(); +00172 exit(1); +00173 } +00174 } +00175 +00176 #if !defined(WIN32) || defined(__CYGWIN__) +00177 /* install signal handler for manual break */ +00178 signal(SIGTERM, catch_signal); +00179 signal(SIGINT, catch_signal); +00180 #endif +00181 +00182 #ifndef NOT_USE_DYNAMIC_LOADING +00183 LoadCanDriver(LibraryPath); +00184 #endif +00185 // Open CAN devices +00186 +00187 if(strcmp(SlaveBoard.baudrate, "none")){ +00188 +00189 TestSlave_Data.heartbeatError = TestSlave_heartbeatError; +00190 TestSlave_Data.initialisation = TestSlave_initialisation; +00191 TestSlave_Data.preOperational = TestSlave_preOperational; +00192 TestSlave_Data.operational = TestSlave_operational; +00193 TestSlave_Data.stopped = TestSlave_stopped; +00194 TestSlave_Data.post_sync = TestSlave_post_sync; +00195 TestSlave_Data.post_TPDO = TestSlave_post_TPDO; +00196 TestSlave_Data.storeODSubIndex = TestSlave_storeODSubIndex; +00197 +00198 if(!canOpen(&SlaveBoard,&TestSlave_Data)){ +00199 eprintf("Cannot open Slave Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate); +00200 goto fail_slave; +00201 } +00202 } +00203 if(strcmp(MasterBoard.baudrate, "none")){ +00204 +00205 TestMaster_Data.heartbeatError = TestMaster_heartbeatError; +00206 TestMaster_Data.initialisation = TestMaster_initialisation; +00207 TestMaster_Data.preOperational = TestMaster_preOperational; +00208 TestMaster_Data.operational = TestMaster_operational; +00209 TestMaster_Data.stopped = TestMaster_stopped; +00210 TestMaster_Data.post_sync = TestMaster_post_sync; +00211 TestMaster_Data.post_TPDO = TestMaster_post_TPDO; +00212 +00213 if(!canOpen(&MasterBoard,&TestMaster_Data)){ +00214 eprintf("Cannot open Master Board (%s,%s)\n",MasterBoard.busname, MasterBoard.baudrate); +00215 goto fail_master; +00216 } +00217 } +00218 +00219 // Start timer thread +00220 StartTimerLoop(&InitNodes); +00221 +00222 // wait Ctrl-C +00223 +00224 pause(); +00225 eprintf("Finishing.\n"); +00226 +00227 masterSendNMTstateChange (&TestMaster_Data, 0x02, NMT_Reset_Node); +00228 eprintf("reset\n"); +00229 // Stop master +00230 setState(&TestMaster_Data, Stopped); +00231 +00232 // Stop timer thread +00233 StopTimerLoop(); +00234 +00235 // Close CAN devices (and can threads) +00236 if(strcmp(SlaveBoard.baudrate, "none")) canClose(&TestSlave_Data); +00237 fail_master: +00238 if(strcmp(MasterBoard.baudrate, "none")) canClose(&TestMaster_Data); +00239 fail_slave: +00240 return 0; +00241 } +
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include "canfestival.h"
#include "Master.h"
#include "Slave.h"
#include "TestMasterSlave.h"
+Include dependency graph for TestMasterSlave.c:
+Go to the source code of this file.
Functions | |
UNS32 | OnMasterMap1Update (CO_Data *d, const indextable *unsused_indextable, UNS8 unsused_bSubindex) |
void | catch_signal (int sig) |
void | help () |
void | InitNodes (CO_Data *d, UNS32 id) |
int | main (int argc, char **argv) |
Variables | |
s_BOARD | SlaveBoard = {"0", "125K"} |
s_BOARD | MasterBoard = {"1", "125K"} |
void catch_signal | +( | +int | +sig | +) | ++ |
+ +
+Definition at line 56 of file TestMasterSlave.c. +
+References eprintf. +
+Referenced by catch_signal(), and main(). +
void help | +( | ++ | ) | ++ |
void InitNodes | +( | +CO_Data * | +d, | +|
+ | + | UNS32 | +id | + |
+ | ) | ++ |
+ +
+Definition at line 93 of file TestMasterSlave.c. +
+References struct_s_BOARD::baudrate, Initialisation, MasterBoard, OnMasterMap1Update(), RegisterSetODentryCallBack(), setNodeId(), setState(), SlaveBoard, TestMaster_Data, and TestSlave_Data. +
+Referenced by main(). +
+Here is the call graph for this function:
int main | +( | +int | +argc, | +|
+ | + | char ** | +argv | + |
+ | ) | ++ |
+ +
+Definition at line 119 of file TestMasterSlave.c. +
+References struct_s_BOARD::baudrate, struct_s_BOARD::busname, canClose(), canOpen(), catch_signal(), eprintf, getopt(), struct_CO_Data::heartbeatError, help(), struct_CO_Data::initialisation, InitNodes(), LoadCanDriver(), MasterBoard, masterSendNMTstateChange(), NMT_Reset_Node, struct_CO_Data::operational, optarg, struct_CO_Data::post_sync, struct_CO_Data::post_TPDO, struct_CO_Data::preOperational, setState(), SlaveBoard, StartTimerLoop(), Stopped, struct_CO_Data::stopped, StopTimerLoop(), struct_CO_Data::storeODSubIndex, TestMaster_Data, TestMaster_heartbeatError(), TestMaster_initialisation(), TestMaster_operational(), TestMaster_post_sync(), TestMaster_post_TPDO(), TestMaster_preOperational(), TestMaster_stopped(), TestSlave_Data, TestSlave_heartbeatError(), TestSlave_initialisation(), TestSlave_operational(), TestSlave_post_sync(), TestSlave_post_TPDO(), TestSlave_preOperational(), TestSlave_stopped(), and TestSlave_storeODSubIndex(). +
+Here is the call graph for this function:
UNS32 OnMasterMap1Update | +( | +CO_Data * | +d, | +|
+ | + | const indextable * | +unsused_indextable, | +|
+ | + | UNS8 | +unsused_bSubindex | + |
+ | ) | ++ |
+ +
+Definition at line 46 of file TestMasterSlave.c. +
+References eprintf, and SlaveMap1. +
+Referenced by InitNodes(). +
+
s_BOARD MasterBoard = {"1", "125K"} | +
+ +
+Definition at line 53 of file TestMasterSlave.c. +
+Referenced by InitNodes(), and main(). +
s_BOARD SlaveBoard = {"0", "125K"} | +
+ +
+Definition at line 52 of file TestMasterSlave.c. +
+Referenced by InitNodes(), and main(). +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 #ifdef USE_XENO +00023 //#define eprintf(...) if(0){} +00024 #define eprintf(...) +00025 #else +00026 #define eprintf(...) printf (__VA_ARGS__) +00027 #endif +00028 void print_message(Message *m); +00029 +00030 /*UNS8 canSend(CAN_HANDLE fd0, Message *m);*/ +00031 +00032 #include "canfestival.h" +00033 +00034 /* +00035 #define CAN_FIFO_LENGTH 100 +00036 +00037 #define DECLARE_A_CAN_FIFO \ +00038 static Message FIFO[CAN_FIFO_LENGTH];\ +00039 static int FIFO_First = 0;\ +00040 static int FIFO_Last = 0;\ +00041 \ +00042 static void PutInFIFO(Message *m)\ +00043 {\ +00044 FIFO[FIFO_Last++] = *m;\ +00045 FIFO_Last %= CAN_FIFO_LENGTH;\ +00046 }\ +00047 \ +00048 static void GetFromFIFO(Message *m)\ +00049 {\ +00050 *m = FIFO[FIFO_First++];\ +00051 FIFO_First %= CAN_FIFO_LENGTH;\ +00052 }\ +00053 \ +00054 static void TransmitMessage(CO_Data* d, UNS32 id)\ +00055 {\ +00056 Message m;\ +00057 GetFromFIFO(&m);\ +00058 canDispatch(d, &m);\ +00059 } +00060 */ +
#include "canfestival.h"
+Include dependency graph for TestMasterSlave.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Defines | |
#define | eprintf(...) printf (__VA_ARGS__) |
Functions | |
void | print_message (Message *m) |
#define eprintf | +( | +... | ++ | ) | +printf (__VA_ARGS__) | +
+ +
+Definition at line 26 of file TestMasterSlave.h. +
+Referenced by catch_signal(), main(), OnMasterMap1Update(), TestMaster_heartbeatError(), TestMaster_initialisation(), TestMaster_operational(), TestMaster_post_sync(), TestMaster_post_TPDO(), TestMaster_preOperational(), TestMaster_stopped(), TestSlave_heartbeatError(), TestSlave_initialisation(), TestSlave_operational(), TestSlave_post_sync(), TestSlave_post_TPDO(), TestSlave_preOperational(), TestSlave_stopped(), and TestSlave_storeODSubIndex(). +
+
void print_message | +( | +Message * | +m | +) | ++ |
+ +
+Definition at line 53 of file can_virtual.c. +
+References Message::cob_id, Message::data, Message::len, MyCase, NMT, NODE_GUARD, PDO1rx, PDO1tx, PDO2rx, PDO2tx, PDO3rx, PDO3tx, PDO4rx, PDO4tx, Message::rtr, SDOrx, SDOtx, SYNC, TIME_STAMP, and SHORT_CAN::w. +
+Referenced by canSend_driver(). +
+
00001 +00002 /* File generated by gen_cfile.py. Should not be modified. */ +00003 +00004 #include "TestSlave.h" +00005 +00006 /**************************************************************************/ +00007 /* Declaration of the mapped variables */ +00008 /**************************************************************************/ +00009 UNS8 SlaveMap1 = 0x0; /* Mapped at index 0x2000, subindex 0x00 */ +00010 UNS8 SlaveMap2 = 0x0; /* Mapped at index 0x2001, subindex 0x00 */ +00011 UNS8 SlaveMap3 = 0x0; /* Mapped at index 0x2002, subindex 0x00 */ +00012 UNS8 SlaveMap4 = 0x0; /* Mapped at index 0x2003, subindex 0x00 */ +00013 UNS8 SlaveMap5 = 0x0; /* Mapped at index 0x2004, subindex 0x00 */ +00014 UNS8 SlaveMap6 = 0x0; /* Mapped at index 0x2005, subindex 0x00 */ +00015 UNS8 SlaveMap7 = 0x0; /* Mapped at index 0x2006, subindex 0x00 */ +00016 UNS8 SlaveMap8 = 0x0; /* Mapped at index 0x2007, subindex 0x00 */ +00017 UNS8 SlaveMap9 = 0x0; /* Mapped at index 0x2008, subindex 0x00 */ +00018 UNS32 SlaveMap10 = 0x0; /* Mapped at index 0x2009, subindex 0x00 */ +00019 UNS16 SlaveMap11 = 0x0; /* Mapped at index 0x200A, subindex 0x00 */ +00020 +00021 /**************************************************************************/ +00022 /* Declaration of the value range types */ +00023 /**************************************************************************/ +00024 +00025 UNS32 TestSlave_valueRangeTest (UNS8 typeValue, void * value) +00026 { +00027 switch (typeValue) { +00028 } +00029 return 0; +00030 } +00031 +00032 /**************************************************************************/ +00033 /* The node id */ +00034 /**************************************************************************/ +00035 /* node_id default value.*/ +00036 UNS8 TestSlave_bDeviceNodeId = 0x00; +00037 +00038 /**************************************************************************/ +00039 /* Array of message processing information */ +00040 +00041 const UNS8 TestSlave_iam_a_slave = 1; +00042 +00043 TIMER_HANDLE TestSlave_heartBeatTimers[1]; +00044 +00045 /* +00046 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +00047 +00048 OBJECT DICTIONARY +00049 +00050 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +00051 */ +00052 +00053 /* index 0x1000 : Device Type. */ +00054 UNS32 TestSlave_obj1000 = 0x12D; /* 301 */ +00055 subindex TestSlave_Index1000[] = +00056 { +00057 { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1000 } +00058 }; +00059 +00060 /* index 0x1001 : Error Register. */ +00061 UNS8 TestSlave_obj1001 = 0x0; /* 0 */ +00062 subindex TestSlave_Index1001[] = +00063 { +00064 { RO, uint8, sizeof (UNS8), (void*)&TestSlave_obj1001 } +00065 }; +00066 +00067 /* index 0x1005 : SYNC COB ID. */ +00068 UNS32 TestSlave_obj1005 = 0x80; /* 128 */ +00069 ODCallback_t TestSlave_Index1005_callbacks[] = +00070 { +00071 NULL, +00072 }; +00073 subindex TestSlave_Index1005[] = +00074 { +00075 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1005 } +00076 }; +00077 +00078 /* index 0x1006 : Communication / Cycle Period. */ +00079 UNS32 TestSlave_obj1006 = 0x0; /* 0 */ +00080 ODCallback_t TestSlave_Index1006_callbacks[] = +00081 { +00082 NULL, +00083 }; +00084 subindex TestSlave_Index1006[] = +00085 { +00086 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1006 } +00087 }; +00088 +00089 /* index 0x1010 : Store parameters. */ +00090 UNS8 TestSlave_highestSubIndex_obj1010 = 4; /* number of subindex - 1*/ +00091 UNS32 TestSlave_obj1010_Save_All_Parameters = 0x0; /* 0 */ +00092 UNS32 TestSlave_obj1010_Save_Communication_Parameters = 0x0; /* 0 */ +00093 UNS32 TestSlave_obj1010_Save_Application_Parameters = 0x0; /* 0 */ +00094 UNS32 TestSlave_obj1010_Save_Manufacturer_Parameters = 0x0; /* 0 */ +00095 ODCallback_t TestSlave_Index1010_callbacks[] = +00096 { +00097 NULL, +00098 NULL, +00099 NULL, +00100 NULL, +00101 NULL, +00102 }; +00103 subindex TestSlave_Index1010[] = +00104 { +00105 { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1010 }, +00106 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_All_Parameters }, +00107 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Communication_Parameters }, +00108 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Application_Parameters }, +00109 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Manufacturer_Parameters } +00110 }; +00111 +00112 /* index 0x1011 : Restore Default Parameters. */ +00113 UNS8 TestSlave_highestSubIndex_obj1011 = 4; /* number of subindex - 1*/ +00114 UNS32 TestSlave_obj1011_Restore_All_Default_Parameters = 0x0; /* 0 */ +00115 UNS32 TestSlave_obj1011_Restore_Communication_Default_Parameters = 0x0; /* 0 */ +00116 UNS32 TestSlave_obj1011_Restore_Application_Default_Parameters = 0x0; /* 0 */ +00117 UNS32 TestSlave_obj1011_Restore_Manufacturer_Default_Parameters = 0x0; /* 0 */ +00118 ODCallback_t TestSlave_Index1011_callbacks[] = +00119 { +00120 NULL, +00121 NULL, +00122 NULL, +00123 NULL, +00124 NULL, +00125 }; +00126 subindex TestSlave_Index1011[] = +00127 { +00128 { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1011 }, +00129 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_All_Default_Parameters }, +00130 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Communication_Default_Parameters }, +00131 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Application_Default_Parameters }, +00132 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Manufacturer_Default_Parameters } +00133 }; +00134 +00135 /* index 0x1016 : Consumer Heartbeat Time */ +00136 UNS8 TestSlave_highestSubIndex_obj1016 = 0; +00137 UNS32 TestSlave_obj1016[]={0}; +00138 +00139 /* index 0x1017 : Producer Heartbeat Time. */ +00140 UNS16 TestSlave_obj1017 = 0x0; /* 0 */ +00141 ODCallback_t TestSlave_Index1017_callbacks[] = +00142 { +00143 NULL, +00144 }; +00145 subindex TestSlave_Index1017[] = +00146 { +00147 { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1017 } +00148 }; +00149 +00150 /* index 0x1018 : Identity. */ +00151 UNS8 TestSlave_highestSubIndex_obj1018 = 4; /* number of subindex - 1*/ +00152 UNS32 TestSlave_obj1018_Vendor_ID = 0x0; /* 0 */ +00153 UNS32 TestSlave_obj1018_Product_Code = 0x0; /* 0 */ +00154 UNS32 TestSlave_obj1018_Revision_Number = 0x0; /* 0 */ +00155 UNS32 TestSlave_obj1018_Serial_Number = 0x0; /* 0 */ +00156 subindex TestSlave_Index1018[] = +00157 { +00158 { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1018 }, +00159 { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Vendor_ID }, +00160 { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Product_Code }, +00161 { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Revision_Number }, +00162 { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Serial_Number } +00163 }; +00164 +00165 /* index 0x1200 : Server SDO Parameter. */ +00166 UNS8 TestSlave_highestSubIndex_obj1200 = 2; /* number of subindex - 1*/ +00167 UNS32 TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO = 0x601; /* 1537 */ +00168 UNS32 TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO = 0x581; /* 1409 */ +00169 subindex TestSlave_Index1200[] = +00170 { +00171 { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1200 }, +00172 { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO }, +00173 { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO } +00174 }; +00175 +00176 /* index 0x1800 : Transmit PDO 1 Parameter. */ +00177 UNS8 TestSlave_highestSubIndex_obj1800 = 5; /* number of subindex - 1*/ +00178 UNS32 TestSlave_obj1800_COB_ID_used_by_PDO = 0x182; /* 386 */ +00179 UNS8 TestSlave_obj1800_Transmission_Type = 0x0; /* 0 */ +00180 UNS16 TestSlave_obj1800_Inhibit_Time = 0x0; /* 0 */ +00181 UNS8 TestSlave_obj1800_Compatibility_Entry = 0x0; /* 0 */ +00182 UNS16 TestSlave_obj1800_Event_Timer = 0x0; /* 0 */ +00183 subindex TestSlave_Index1800[] = +00184 { +00185 { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1800 }, +00186 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1800_COB_ID_used_by_PDO }, +00187 { RW|TO_BE_SAVE, uint8, sizeof (UNS8), (void*)&TestSlave_obj1800_Transmission_Type }, +00188 { RW|TO_BE_SAVE, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Inhibit_Time }, +00189 { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1800_Compatibility_Entry }, +00190 { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Event_Timer } +00191 }; +00192 +00193 /* index 0x1801 : Transmit PDO 2 Parameter. */ +00194 UNS8 TestSlave_highestSubIndex_obj1801 = 5; /* number of subindex - 1*/ +00195 UNS32 TestSlave_obj1801_COB_ID_used_by_PDO = 0x0; /* 0 */ +00196 UNS8 TestSlave_obj1801_Transmission_Type = 0x0; /* 0 */ +00197 UNS16 TestSlave_obj1801_Inhibit_Time = 0x0; /* 0 */ +00198 UNS8 TestSlave_obj1801_Compatibility_Entry = 0x0; /* 0 */ +00199 UNS16 TestSlave_obj1801_Event_Timer = 0x0; /* 0 */ +00200 subindex TestSlave_Index1801[] = +00201 { +00202 { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1801 }, +00203 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1801_COB_ID_used_by_PDO }, +00204 { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1801_Transmission_Type }, +00205 { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Inhibit_Time }, +00206 { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1801_Compatibility_Entry }, +00207 { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Event_Timer } +00208 }; +00209 +00210 /* index 0x1A00 : Transmit PDO 1 Mapping. */ +00211 UNS8 TestSlave_highestSubIndex_obj1A00 = 10; /* number of subindex - 1*/ +00212 UNS32 TestSlave_obj1A00[] = +00213 { +00214 0x20000001, /* 536870913 */ +00215 0x20010001, /* 536936449 */ +00216 0x20020001, /* 537001985 */ +00217 0x20030001, /* 537067521 */ +00218 0x20040001, /* 537133057 */ +00219 0x20050001, /* 537198593 */ +00220 0x20060001, /* 537264129 */ +00221 0x20070001, /* 537329665 */ +00222 0x20080008, /* 537395208 */ +00223 0x20090020 /* 537460768 */ +00224 }; +00225 subindex TestSlave_Index1A00[] = +00226 { +00227 { RW, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1A00 }, +00228 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[0] }, +00229 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[1] }, +00230 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[2] }, +00231 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[3] }, +00232 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[4] }, +00233 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[5] }, +00234 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[6] }, +00235 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[7] }, +00236 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[8] }, +00237 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[9] } +00238 }; +00239 +00240 /* index 0x1A01 : Transmit PDO 2 Mapping. */ +00241 UNS8 TestSlave_highestSubIndex_obj1A01 = 1; /* number of subindex - 1*/ +00242 UNS32 TestSlave_obj1A01[] = +00243 { +00244 0x200A0010 /* 537526288 */ +00245 }; +00246 subindex TestSlave_Index1A01[] = +00247 { +00248 { RW, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1A01 }, +00249 { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A01[0] } +00250 }; +00251 +00252 /* index 0x2000 : Mapped variable SlaveMap1 */ +00253 subindex TestSlave_Index2000[] = +00254 { +00255 { RW, boolean, sizeof (UNS8), (void*)&SlaveMap1 } +00256 }; +00257 +00258 /* index 0x2001 : Mapped variable SlaveMap2 */ +00259 subindex TestSlave_Index2001[] = +00260 { +00261 { RW, boolean, sizeof (UNS8), (void*)&SlaveMap2 } +00262 }; +00263 +00264 /* index 0x2002 : Mapped variable SlaveMap3 */ +00265 subindex TestSlave_Index2002[] = +00266 { +00267 { RW, boolean, sizeof (UNS8), (void*)&SlaveMap3 } +00268 }; +00269 +00270 /* index 0x2003 : Mapped variable SlaveMap4 */ +00271 subindex TestSlave_Index2003[] = +00272 { +00273 { RW, boolean, sizeof (UNS8), (void*)&SlaveMap4 } +00274 }; +00275 +00276 /* index 0x2004 : Mapped variable SlaveMap5 */ +00277 subindex TestSlave_Index2004[] = +00278 { +00279 { RW, boolean, sizeof (UNS8), (void*)&SlaveMap5 } +00280 }; +00281 +00282 /* index 0x2005 : Mapped variable SlaveMap6 */ +00283 subindex TestSlave_Index2005[] = +00284 { +00285 { RW, boolean, sizeof (UNS8), (void*)&SlaveMap6 } +00286 }; +00287 +00288 /* index 0x2006 : Mapped variable SlaveMap7 */ +00289 subindex TestSlave_Index2006[] = +00290 { +00291 { RW, boolean, sizeof (UNS8), (void*)&SlaveMap7 } +00292 }; +00293 +00294 /* index 0x2007 : Mapped variable SlaveMap8 */ +00295 subindex TestSlave_Index2007[] = +00296 { +00297 { RW, boolean, sizeof (UNS8), (void*)&SlaveMap8 } +00298 }; +00299 +00300 /* index 0x2008 : Mapped variable SlaveMap9 */ +00301 subindex TestSlave_Index2008[] = +00302 { +00303 { RW, uint8, sizeof (UNS8), (void*)&SlaveMap9 } +00304 }; +00305 +00306 /* index 0x2009 : Mapped variable SlaveMap10 */ +00307 subindex TestSlave_Index2009[] = +00308 { +00309 { RW, uint32, sizeof (UNS32), (void*)&SlaveMap10 } +00310 }; +00311 +00312 /* index 0x200A : Mapped variable SlaveMap11 */ +00313 subindex TestSlave_Index200A[] = +00314 { +00315 { RW, uint16, sizeof (UNS16), (void*)&SlaveMap11 } +00316 }; +00317 +00318 const indextable TestSlave_objdict[] = +00319 { +00320 { (subindex*)TestSlave_Index1000,sizeof(TestSlave_Index1000)/sizeof(TestSlave_Index1000[0]), 0x1000}, +00321 { (subindex*)TestSlave_Index1001,sizeof(TestSlave_Index1001)/sizeof(TestSlave_Index1001[0]), 0x1001}, +00322 { (subindex*)TestSlave_Index1005,sizeof(TestSlave_Index1005)/sizeof(TestSlave_Index1005[0]), 0x1005}, +00323 { (subindex*)TestSlave_Index1006,sizeof(TestSlave_Index1006)/sizeof(TestSlave_Index1006[0]), 0x1006}, +00324 { (subindex*)TestSlave_Index1010,sizeof(TestSlave_Index1010)/sizeof(TestSlave_Index1010[0]), 0x1010}, +00325 { (subindex*)TestSlave_Index1011,sizeof(TestSlave_Index1011)/sizeof(TestSlave_Index1011[0]), 0x1011}, +00326 { (subindex*)TestSlave_Index1017,sizeof(TestSlave_Index1017)/sizeof(TestSlave_Index1017[0]), 0x1017}, +00327 { (subindex*)TestSlave_Index1018,sizeof(TestSlave_Index1018)/sizeof(TestSlave_Index1018[0]), 0x1018}, +00328 { (subindex*)TestSlave_Index1200,sizeof(TestSlave_Index1200)/sizeof(TestSlave_Index1200[0]), 0x1200}, +00329 { (subindex*)TestSlave_Index1800,sizeof(TestSlave_Index1800)/sizeof(TestSlave_Index1800[0]), 0x1800}, +00330 { (subindex*)TestSlave_Index1801,sizeof(TestSlave_Index1801)/sizeof(TestSlave_Index1801[0]), 0x1801}, +00331 { (subindex*)TestSlave_Index1A00,sizeof(TestSlave_Index1A00)/sizeof(TestSlave_Index1A00[0]), 0x1A00}, +00332 { (subindex*)TestSlave_Index1A01,sizeof(TestSlave_Index1A01)/sizeof(TestSlave_Index1A01[0]), 0x1A01}, +00333 { (subindex*)TestSlave_Index2000,sizeof(TestSlave_Index2000)/sizeof(TestSlave_Index2000[0]), 0x2000}, +00334 { (subindex*)TestSlave_Index2001,sizeof(TestSlave_Index2001)/sizeof(TestSlave_Index2001[0]), 0x2001}, +00335 { (subindex*)TestSlave_Index2002,sizeof(TestSlave_Index2002)/sizeof(TestSlave_Index2002[0]), 0x2002}, +00336 { (subindex*)TestSlave_Index2003,sizeof(TestSlave_Index2003)/sizeof(TestSlave_Index2003[0]), 0x2003}, +00337 { (subindex*)TestSlave_Index2004,sizeof(TestSlave_Index2004)/sizeof(TestSlave_Index2004[0]), 0x2004}, +00338 { (subindex*)TestSlave_Index2005,sizeof(TestSlave_Index2005)/sizeof(TestSlave_Index2005[0]), 0x2005}, +00339 { (subindex*)TestSlave_Index2006,sizeof(TestSlave_Index2006)/sizeof(TestSlave_Index2006[0]), 0x2006}, +00340 { (subindex*)TestSlave_Index2007,sizeof(TestSlave_Index2007)/sizeof(TestSlave_Index2007[0]), 0x2007}, +00341 { (subindex*)TestSlave_Index2008,sizeof(TestSlave_Index2008)/sizeof(TestSlave_Index2008[0]), 0x2008}, +00342 { (subindex*)TestSlave_Index2009,sizeof(TestSlave_Index2009)/sizeof(TestSlave_Index2009[0]), 0x2009}, +00343 { (subindex*)TestSlave_Index200A,sizeof(TestSlave_Index200A)/sizeof(TestSlave_Index200A[0]), 0x200A}, +00344 }; +00345 +00346 const indextable * TestSlave_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks) +00347 { +00348 int i; +00349 *callbacks = NULL; +00350 switch(wIndex){ +00351 case 0x1000: i = 0;break; +00352 case 0x1001: i = 1;break; +00353 case 0x1005: i = 2;*callbacks = TestSlave_Index1005_callbacks; break; +00354 case 0x1006: i = 3;*callbacks = TestSlave_Index1006_callbacks; break; +00355 case 0x1010: i = 4;*callbacks = TestSlave_Index1010_callbacks; break; +00356 case 0x1011: i = 5;*callbacks = TestSlave_Index1011_callbacks; break; +00357 case 0x1017: i = 6;*callbacks = TestSlave_Index1017_callbacks; break; +00358 case 0x1018: i = 7;break; +00359 case 0x1200: i = 8;break; +00360 case 0x1800: i = 9;break; +00361 case 0x1801: i = 10;break; +00362 case 0x1A00: i = 11;break; +00363 case 0x1A01: i = 12;break; +00364 case 0x2000: i = 13;break; +00365 case 0x2001: i = 14;break; +00366 case 0x2002: i = 15;break; +00367 case 0x2003: i = 16;break; +00368 case 0x2004: i = 17;break; +00369 case 0x2005: i = 18;break; +00370 case 0x2006: i = 19;break; +00371 case 0x2007: i = 20;break; +00372 case 0x2008: i = 21;break; +00373 case 0x2009: i = 22;break; +00374 case 0x200A: i = 23;break; +00375 default: +00376 *errorCode = OD_NO_SUCH_OBJECT; +00377 return NULL; +00378 } +00379 *errorCode = OD_SUCCESSFUL; +00380 return &TestSlave_objdict[i]; +00381 } +00382 +00383 /* To count at which received SYNC a PDO must be sent. +00384 * Even if no pdoTransmit are defined, at least one entry is computed +00385 * for compilations issues. +00386 */ +00387 UNS8 TestSlave_count_sync[2] = {0,}; +00388 +00389 quick_index TestSlave_firstIndex = { +00390 8, /* SDO_SVR */ +00391 0, /* SDO_CLT */ +00392 0, /* PDO_RCV */ +00393 0, /* PDO_RCV_MAP */ +00394 9, /* PDO_TRS */ +00395 11 /* PDO_TRS_MAP */ +00396 }; +00397 +00398 quick_index TestSlave_lastIndex = { +00399 8, /* SDO_SVR */ +00400 0, /* SDO_CLT */ +00401 0, /* PDO_RCV */ +00402 0, /* PDO_RCV_MAP */ +00403 10, /* PDO_TRS */ +00404 12 /* PDO_TRS_MAP */ +00405 }; +00406 +00407 UNS16 TestSlave_ObjdictSize = sizeof(TestSlave_objdict)/sizeof(TestSlave_objdict[0]); +00408 +00409 CO_Data TestSlave_Data = CANOPEN_NODE_DATA_INITIALIZER(TestSlave); +00410 +
#include "TestSlave.h"
+Include dependency graph for TestSlave.c:
+Go to the source code of this file.
const indextable* TestSlave_scanIndexOD | +( | +UNS16 | +wIndex, | +|
+ | + | UNS32 * | +errorCode, | +|
+ | + | ODCallback_t ** | +callbacks | + |
+ | ) | ++ |
+ +
+Definition at line 346 of file TestSlave.c. +
+References OD_NO_SUCH_OBJECT, OD_SUCCESSFUL, TestSlave_Index1005_callbacks, TestSlave_Index1006_callbacks, TestSlave_Index1010_callbacks, TestSlave_Index1011_callbacks, TestSlave_Index1017_callbacks, and TestSlave_objdict. +
UNS32 TestSlave_valueRangeTest | +( | +UNS8 | +typeValue, | +|
+ | + | void * | +value | + |
+ | ) | ++ |
+ +
+Definition at line 25 of file TestSlave.c. +
+
UNS8 SlaveMap1 = 0x0 | +
+ +
+Definition at line 9 of file TestSlave.c. +
+Referenced by OnMasterMap1Update(), and TestSlave_post_sync(). +
UNS32 SlaveMap10 = 0x0 | +
UNS16 SlaveMap11 = 0x0 | +
UNS8 SlaveMap2 = 0x0 | +
UNS8 SlaveMap3 = 0x0 | +
UNS8 SlaveMap4 = 0x0 | +
UNS8 SlaveMap5 = 0x0 | +
UNS8 SlaveMap6 = 0x0 | +
UNS8 SlaveMap7 = 0x0 | +
UNS8 SlaveMap8 = 0x0 | +
UNS8 SlaveMap9 = 0x0 | +
UNS8 TestSlave_bDeviceNodeId = 0x00 | +
+ +
+Definition at line 36 of file TestSlave.c. +
UNS8 TestSlave_count_sync[2] = {0,} | +
+ +
+Definition at line 387 of file TestSlave.c. +
CO_Data TestSlave_Data = CANOPEN_NODE_DATA_INITIALIZER(TestSlave) | +
quick_index TestSlave_firstIndex | +
+Initial value:
{ + 8, + 0, + 0, + 0, + 9, + 11 +} +
+Definition at line 389 of file TestSlave.c. +
TIMER_HANDLE TestSlave_heartBeatTimers[1] | +
+ +
+Definition at line 43 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1010 = 4 | +
+ +
+Definition at line 90 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1011 = 4 | +
+ +
+Definition at line 113 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1016 = 0 | +
+ +
+Definition at line 136 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1018 = 4 | +
+ +
+Definition at line 151 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1200 = 2 | +
+ +
+Definition at line 166 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1800 = 5 | +
+ +
+Definition at line 177 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1801 = 5 | +
+ +
+Definition at line 194 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1A00 = 10 | +
+ +
+Definition at line 211 of file TestSlave.c. +
UNS8 TestSlave_highestSubIndex_obj1A01 = 1 | +
+ +
+Definition at line 241 of file TestSlave.c. +
const UNS8 TestSlave_iam_a_slave = 1 | +
+ +
+Definition at line 41 of file TestSlave.c. +
subindex TestSlave_Index1000[] | +
+Initial value:
+ { + { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1000 } + } +
+Definition at line 55 of file TestSlave.c. +
subindex TestSlave_Index1001[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestSlave_obj1001 } + } +
+Definition at line 62 of file TestSlave.c. +
subindex TestSlave_Index1005[] | +
+Initial value:
+ { + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1005 } + } +
+Definition at line 73 of file TestSlave.c. +
ODCallback_t TestSlave_Index1005_callbacks[] | +
+Initial value:
+ { + NULL, + } +
+Definition at line 69 of file TestSlave.c. +
+Referenced by TestSlave_scanIndexOD(). +
subindex TestSlave_Index1006[] | +
+Initial value:
+ { + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1006 } + } +
+Definition at line 84 of file TestSlave.c. +
ODCallback_t TestSlave_Index1006_callbacks[] | +
+Initial value:
+ { + NULL, + } +
+Definition at line 80 of file TestSlave.c. +
+Referenced by TestSlave_scanIndexOD(). +
subindex TestSlave_Index1010[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1010 }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_All_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Communication_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Application_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1010_Save_Manufacturer_Parameters } + } +
+Definition at line 103 of file TestSlave.c. +
ODCallback_t TestSlave_Index1010_callbacks[] | +
+Initial value:
+ { + NULL, + NULL, + NULL, + NULL, + NULL, + } +
+Definition at line 95 of file TestSlave.c. +
+Referenced by TestSlave_scanIndexOD(). +
subindex TestSlave_Index1011[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1011 }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_All_Default_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Communication_Default_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Application_Default_Parameters }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1011_Restore_Manufacturer_Default_Parameters } + } +
+Definition at line 126 of file TestSlave.c. +
ODCallback_t TestSlave_Index1011_callbacks[] | +
+Initial value:
+ { + NULL, + NULL, + NULL, + NULL, + NULL, + } +
+Definition at line 118 of file TestSlave.c. +
+Referenced by TestSlave_scanIndexOD(). +
subindex TestSlave_Index1017[] | +
+Initial value:
+ { + { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1017 } + } +
+Definition at line 145 of file TestSlave.c. +
ODCallback_t TestSlave_Index1017_callbacks[] | +
+Initial value:
+ { + NULL, + } +
+Definition at line 141 of file TestSlave.c. +
+Referenced by TestSlave_scanIndexOD(). +
subindex TestSlave_Index1018[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1018 }, + { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Vendor_ID }, + { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Product_Code }, + { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Revision_Number }, + { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Serial_Number } + } +
+Definition at line 156 of file TestSlave.c. +
subindex TestSlave_Index1200[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1200 }, + { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO }, + { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO } + } +
+Definition at line 169 of file TestSlave.c. +
subindex TestSlave_Index1800[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1800 }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1800_COB_ID_used_by_PDO }, + { RW|TO_BE_SAVE, uint8, sizeof (UNS8), (void*)&TestSlave_obj1800_Transmission_Type }, + { RW|TO_BE_SAVE, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Inhibit_Time }, + { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1800_Compatibility_Entry }, + { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Event_Timer } + } +
+Definition at line 183 of file TestSlave.c. +
subindex TestSlave_Index1801[] | +
+Initial value:
+ { + { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1801 }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1801_COB_ID_used_by_PDO }, + { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1801_Transmission_Type }, + { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Inhibit_Time }, + { RW, uint8, sizeof (UNS8), (void*)&TestSlave_obj1801_Compatibility_Entry }, + { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Event_Timer } + } +
+Definition at line 200 of file TestSlave.c. +
subindex TestSlave_Index1A00[] | +
+Initial value:
+ { + { RW, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1A00 }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[0] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[1] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[2] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[3] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[4] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[5] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[6] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[7] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[8] }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A00[9] } + } +
+Definition at line 225 of file TestSlave.c. +
subindex TestSlave_Index1A01[] | +
+Initial value:
+ { + { RW, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1A01 }, + { RW, uint32, sizeof (UNS32), (void*)&TestSlave_obj1A01[0] } + } +
+Definition at line 246 of file TestSlave.c. +
subindex TestSlave_Index2000[] | +
subindex TestSlave_Index2001[] | +
subindex TestSlave_Index2002[] | +
subindex TestSlave_Index2003[] | +
subindex TestSlave_Index2004[] | +
subindex TestSlave_Index2005[] | +
subindex TestSlave_Index2006[] | +
subindex TestSlave_Index2007[] | +
subindex TestSlave_Index2008[] | +
subindex TestSlave_Index2009[] | +
+Initial value:
+ { + { RW, uint32, sizeof (UNS32), (void*)&SlaveMap10 } + } +
+Definition at line 307 of file TestSlave.c. +
subindex TestSlave_Index200A[] | +
+Initial value:
+ { + { RW, uint16, sizeof (UNS16), (void*)&SlaveMap11 } + } +
+Definition at line 313 of file TestSlave.c. +
quick_index TestSlave_lastIndex | +
+Initial value:
{ + 8, + 0, + 0, + 0, + 10, + 12 +} +
+Definition at line 398 of file TestSlave.c. +
UNS32 TestSlave_obj1000 = 0x12D | +
+ +
+Definition at line 54 of file TestSlave.c. +
UNS8 TestSlave_obj1001 = 0x0 | +
+ +
+Definition at line 61 of file TestSlave.c. +
UNS32 TestSlave_obj1005 = 0x80 | +
+ +
+Definition at line 68 of file TestSlave.c. +
UNS32 TestSlave_obj1006 = 0x0 | +
+ +
+Definition at line 79 of file TestSlave.c. +
UNS32 TestSlave_obj1010_Save_All_Parameters = 0x0 | +
+ +
+Definition at line 91 of file TestSlave.c. +
UNS32 TestSlave_obj1010_Save_Application_Parameters = 0x0 | +
+ +
+Definition at line 93 of file TestSlave.c. +
UNS32 TestSlave_obj1010_Save_Communication_Parameters = 0x0 | +
+ +
+Definition at line 92 of file TestSlave.c. +
UNS32 TestSlave_obj1010_Save_Manufacturer_Parameters = 0x0 | +
+ +
+Definition at line 94 of file TestSlave.c. +
UNS32 TestSlave_obj1011_Restore_All_Default_Parameters = 0x0 | +
+ +
+Definition at line 114 of file TestSlave.c. +
UNS32 TestSlave_obj1011_Restore_Application_Default_Parameters = 0x0 | +
+ +
+Definition at line 116 of file TestSlave.c. +
UNS32 TestSlave_obj1011_Restore_Communication_Default_Parameters = 0x0 | +
+ +
+Definition at line 115 of file TestSlave.c. +
UNS32 TestSlave_obj1011_Restore_Manufacturer_Default_Parameters = 0x0 | +
+ +
+Definition at line 117 of file TestSlave.c. +
UNS32 TestSlave_obj1016[] = {0} | +
+ +
+Definition at line 137 of file TestSlave.c. +
UNS16 TestSlave_obj1017 = 0x0 | +
+ +
+Definition at line 140 of file TestSlave.c. +
UNS32 TestSlave_obj1018_Product_Code = 0x0 | +
+ +
+Definition at line 153 of file TestSlave.c. +
UNS32 TestSlave_obj1018_Revision_Number = 0x0 | +
+ +
+Definition at line 154 of file TestSlave.c. +
UNS32 TestSlave_obj1018_Serial_Number = 0x0 | +
+ +
+Definition at line 155 of file TestSlave.c. +
UNS32 TestSlave_obj1018_Vendor_ID = 0x0 | +
+ +
+Definition at line 152 of file TestSlave.c. +
UNS32 TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO = 0x601 | +
+ +
+Definition at line 167 of file TestSlave.c. +
UNS32 TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO = 0x581 | +
+ +
+Definition at line 168 of file TestSlave.c. +
UNS32 TestSlave_obj1800_COB_ID_used_by_PDO = 0x182 | +
+ +
+Definition at line 178 of file TestSlave.c. +
UNS8 TestSlave_obj1800_Compatibility_Entry = 0x0 | +
+ +
+Definition at line 181 of file TestSlave.c. +
UNS16 TestSlave_obj1800_Event_Timer = 0x0 | +
+ +
+Definition at line 182 of file TestSlave.c. +
UNS16 TestSlave_obj1800_Inhibit_Time = 0x0 | +
+ +
+Definition at line 180 of file TestSlave.c. +
UNS8 TestSlave_obj1800_Transmission_Type = 0x0 | +
+ +
+Definition at line 179 of file TestSlave.c. +
UNS32 TestSlave_obj1801_COB_ID_used_by_PDO = 0x0 | +
+ +
+Definition at line 195 of file TestSlave.c. +
UNS8 TestSlave_obj1801_Compatibility_Entry = 0x0 | +
+ +
+Definition at line 198 of file TestSlave.c. +
UNS16 TestSlave_obj1801_Event_Timer = 0x0 | +
+ +
+Definition at line 199 of file TestSlave.c. +
UNS16 TestSlave_obj1801_Inhibit_Time = 0x0 | +
+ +
+Definition at line 197 of file TestSlave.c. +
UNS8 TestSlave_obj1801_Transmission_Type = 0x0 | +
+ +
+Definition at line 196 of file TestSlave.c. +
UNS32 TestSlave_obj1A00[] | +
+Initial value:
+ { + 0x20000001, + 0x20010001, + 0x20020001, + 0x20030001, + 0x20040001, + 0x20050001, + 0x20060001, + 0x20070001, + 0x20080008, + 0x20090020 + } +
+Definition at line 212 of file TestSlave.c. +
UNS32 TestSlave_obj1A01[] | +
const indextable TestSlave_objdict[] | +
+Initial value:
+{ + { (subindex*)TestSlave_Index1000,sizeof(TestSlave_Index1000)/sizeof(TestSlave_Index1000[0]), 0x1000}, + { (subindex*)TestSlave_Index1001,sizeof(TestSlave_Index1001)/sizeof(TestSlave_Index1001[0]), 0x1001}, + { (subindex*)TestSlave_Index1005,sizeof(TestSlave_Index1005)/sizeof(TestSlave_Index1005[0]), 0x1005}, + { (subindex*)TestSlave_Index1006,sizeof(TestSlave_Index1006)/sizeof(TestSlave_Index1006[0]), 0x1006}, + { (subindex*)TestSlave_Index1010,sizeof(TestSlave_Index1010)/sizeof(TestSlave_Index1010[0]), 0x1010}, + { (subindex*)TestSlave_Index1011,sizeof(TestSlave_Index1011)/sizeof(TestSlave_Index1011[0]), 0x1011}, + { (subindex*)TestSlave_Index1017,sizeof(TestSlave_Index1017)/sizeof(TestSlave_Index1017[0]), 0x1017}, + { (subindex*)TestSlave_Index1018,sizeof(TestSlave_Index1018)/sizeof(TestSlave_Index1018[0]), 0x1018}, + { (subindex*)TestSlave_Index1200,sizeof(TestSlave_Index1200)/sizeof(TestSlave_Index1200[0]), 0x1200}, + { (subindex*)TestSlave_Index1800,sizeof(TestSlave_Index1800)/sizeof(TestSlave_Index1800[0]), 0x1800}, + { (subindex*)TestSlave_Index1801,sizeof(TestSlave_Index1801)/sizeof(TestSlave_Index1801[0]), 0x1801}, + { (subindex*)TestSlave_Index1A00,sizeof(TestSlave_Index1A00)/sizeof(TestSlave_Index1A00[0]), 0x1A00}, + { (subindex*)TestSlave_Index1A01,sizeof(TestSlave_Index1A01)/sizeof(TestSlave_Index1A01[0]), 0x1A01}, + { (subindex*)TestSlave_Index2000,sizeof(TestSlave_Index2000)/sizeof(TestSlave_Index2000[0]), 0x2000}, + { (subindex*)TestSlave_Index2001,sizeof(TestSlave_Index2001)/sizeof(TestSlave_Index2001[0]), 0x2001}, + { (subindex*)TestSlave_Index2002,sizeof(TestSlave_Index2002)/sizeof(TestSlave_Index2002[0]), 0x2002}, + { (subindex*)TestSlave_Index2003,sizeof(TestSlave_Index2003)/sizeof(TestSlave_Index2003[0]), 0x2003}, + { (subindex*)TestSlave_Index2004,sizeof(TestSlave_Index2004)/sizeof(TestSlave_Index2004[0]), 0x2004}, + { (subindex*)TestSlave_Index2005,sizeof(TestSlave_Index2005)/sizeof(TestSlave_Index2005[0]), 0x2005}, + { (subindex*)TestSlave_Index2006,sizeof(TestSlave_Index2006)/sizeof(TestSlave_Index2006[0]), 0x2006}, + { (subindex*)TestSlave_Index2007,sizeof(TestSlave_Index2007)/sizeof(TestSlave_Index2007[0]), 0x2007}, + { (subindex*)TestSlave_Index2008,sizeof(TestSlave_Index2008)/sizeof(TestSlave_Index2008[0]), 0x2008}, + { (subindex*)TestSlave_Index2009,sizeof(TestSlave_Index2009)/sizeof(TestSlave_Index2009[0]), 0x2009}, + { (subindex*)TestSlave_Index200A,sizeof(TestSlave_Index200A)/sizeof(TestSlave_Index200A[0]), 0x200A}, +} +
+Definition at line 318 of file TestSlave.c. +
+Referenced by TestSlave_scanIndexOD(). +
UNS16 TestSlave_ObjdictSize = sizeof(TestSlave_objdict)/sizeof(TestSlave_objdict[0]) | +
+ +
+Definition at line 407 of file TestSlave.c. +
+
00001 +00002 /* File generated by gen_cfile.py. Should not be modified. */ +00003 +00004 #include "data.h" +00005 +00006 /* Prototypes of function provided by object dictionnary */ +00007 UNS32 TestSlave_valueRangeTest (UNS8 typeValue, void * value); +00008 const indextable * TestSlave_scanIndexOD (UNS16 wIndex, UNS32 * errorCode, ODCallback_t **callbacks); +00009 +00010 /* Master node data struct */ +00011 extern CO_Data TestSlave_Data; +00012 +00013 extern ODCallback_t Store_parameters_callbacks[]; /* Callbacks of index0x1010 */ +00014 extern ODCallback_t Restore_Default_Parameters_callbacks[]; /* Callbacks of index0x1011 */ +00015 extern UNS8 SlaveMap1; /* Mapped at index 0x2000, subindex 0x00*/ +00016 extern UNS8 SlaveMap2; /* Mapped at index 0x2001, subindex 0x00*/ +00017 extern UNS8 SlaveMap3; /* Mapped at index 0x2002, subindex 0x00*/ +00018 extern UNS8 SlaveMap4; /* Mapped at index 0x2003, subindex 0x00*/ +00019 extern UNS8 SlaveMap5; /* Mapped at index 0x2004, subindex 0x00*/ +00020 extern UNS8 SlaveMap6; /* Mapped at index 0x2005, subindex 0x00*/ +00021 extern UNS8 SlaveMap7; /* Mapped at index 0x2006, subindex 0x00*/ +00022 extern UNS8 SlaveMap8; /* Mapped at index 0x2007, subindex 0x00*/ +00023 extern UNS8 SlaveMap9; /* Mapped at index 0x2008, subindex 0x00*/ +00024 extern UNS32 SlaveMap10; /* Mapped at index 0x2009, subindex 0x00*/ +00025 extern UNS16 SlaveMap11; /* Mapped at index 0x200A, subindex 0x00*/ +
#include "data.h"
+Include dependency graph for TestSlave.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Functions | |
UNS32 | TestSlave_valueRangeTest (UNS8 typeValue, void *value) |
const indextable * | TestSlave_scanIndexOD (UNS16 wIndex, UNS32 *errorCode, ODCallback_t **callbacks) |
Variables | |
CO_Data | TestSlave_Data |
ODCallback_t | Store_parameters_callbacks [] |
ODCallback_t | Restore_Default_Parameters_callbacks [] |
UNS8 | SlaveMap1 |
UNS8 | SlaveMap2 |
UNS8 | SlaveMap3 |
UNS8 | SlaveMap4 |
UNS8 | SlaveMap5 |
UNS8 | SlaveMap6 |
UNS8 | SlaveMap7 |
UNS8 | SlaveMap8 |
UNS8 | SlaveMap9 |
UNS32 | SlaveMap10 |
UNS16 | SlaveMap11 |
const indextable* TestSlave_scanIndexOD | +( | +UNS16 | +wIndex, | +|
+ | + | UNS32 * | +errorCode, | +|
+ | + | ODCallback_t ** | +callbacks | + |
+ | ) | ++ |
+ +
+Definition at line 346 of file TestSlave.c. +
+References OD_NO_SUCH_OBJECT, OD_SUCCESSFUL, TestSlave_Index1005_callbacks, TestSlave_Index1006_callbacks, TestSlave_Index1010_callbacks, TestSlave_Index1011_callbacks, TestSlave_Index1017_callbacks, and TestSlave_objdict. +
UNS32 TestSlave_valueRangeTest | +( | +UNS8 | +typeValue, | +|
+ | + | void * | +value | + |
+ | ) | ++ |
+ +
+Definition at line 25 of file TestSlave.c. +
+
ODCallback_t Restore_Default_Parameters_callbacks[] | +
+ +
UNS8 SlaveMap1 | +
+ +
+Definition at line 9 of file TestSlave.c. +
+Referenced by OnMasterMap1Update(), and TestSlave_post_sync(). +
UNS32 SlaveMap10 | +
UNS16 SlaveMap11 | +
UNS8 SlaveMap2 | +
UNS8 SlaveMap3 | +
UNS8 SlaveMap4 | +
UNS8 SlaveMap5 | +
UNS8 SlaveMap6 | +
UNS8 SlaveMap7 | +
UNS8 SlaveMap8 | +
UNS8 SlaveMap9 | +
ODCallback_t Store_parameters_callbacks[] | +
+ +
CO_Data TestSlave_Data | +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 // Uncomment if you don't need console informations. +00024 #define DEBUG_WAR_CONSOLE_ON +00025 #define DEBUG_ERR_CONSOLE_ON +00026 +00027 #include <stddef.h> /* for NULL */ +00028 +00029 #include <asm-m68hc12/portsaccess.h> +00030 #include <asm-m68hc12/ports_def.h> +00031 #include <asm-m68hc12/ports.h> +00032 #include <interrupt.h> +00033 +00034 #include "../include/data.h" +00035 #include <applicfg.h> +00036 +00037 +00038 +00039 #include "../include/hcs12/candriver.h" +00040 #include "../include/hcs12/canOpenDriver.h" +00041 #include "../include/def.h" +00042 #include "../include/can.h" +00043 #include "../include/objdictdef.h" +00044 #include "../include/objacces.h" +00045 #include "../include/sdo.h" +00046 #include "../include/pdo.h" +00047 #include "../include/timer.h" +00048 #include "../include/lifegrd.h" +00049 #include "../include/sync.h" +00050 +00051 #include "../include/nmtSlave.h" +00052 +00053 // File created by the GUI +00054 #include "objdict.h" +00055 +00056 +00057 +00058 +00059 +00060 // HCS12 configuration +00061 // ----------------------------------------------------- +00062 +00063 enum E_CanBaudrate +00064 { +00065 CAN_BAUDRATE_250K, +00066 CAN_BAUDRATE_500K, +00067 CAN_BAUDRATE_1M, +00068 }; +00069 +00070 +00071 const canBusTime CAN_Baudrates[] = +00072 { +00073 { +00074 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ +00075 3, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ +00076 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ +00077 0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ +00078 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ +00079 12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ +00080 +00081 /* +00082 With these values, +00083 - The width of the bit time is 16 time quantum : +00084 - 1 tq for the SYNC segment (could not be modified) +00085 - 13 tq for the TIME 1 segment (tseg1 = 12) +00086 - 2 tq for the TIME 2 segment (tseg2 = 1) +00087 - Because the bus clock of the MSCAN is 16 MHZ, and the +00088 freq of the time quantum is 4 MHZ (brp = 3+1), and there are 16 tq in the bit time, +00089 so the freq of the bit time is 250 kHz. +00090 */ +00091 }, +00092 +00093 { +00094 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ +00095 1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ +00096 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ +00097 0, /* samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit */ +00098 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ +00099 12, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ +00100 +00101 /* +00102 With these values, +00103 - The width of the bit time is 16 time quantum : +00104 - 1 tq for the SYNC segment (could not be modified) +00105 - 13 tq for the TIME 1 segment (tseg1 = 12) +00106 - 2 tq for the TIME 2 segment (tseg2 = 1) +00107 - Because the bus clock of the MSCAN is 16 MHZ, and the +00108 freq of the time quantum is 8 MHZ (brp = 1+1), and there are 16 tq in the bit time, +00109 so the freq of the bit time is 500 kHz. +00110 */ +00111 }, +00112 +00113 { +00114 1, /* clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board */ +00115 1, /* brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) */ +00116 0, /* sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum */ +00117 0, /* samp : chose btw 0 and 3 (2 bits) (samp +MSG_WAR(0x3F33, "Je suis le noeud ", getNodeId()); 1 ) samples per bit */ +00118 1, /* tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq */ +00119 4, /* tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq */ +00120 +00121 /* +00122 With these values, +00123 - The width of the bit time is 16 time quantum : +00124 - 1 tq for the SYNC segment (could not be modified) +00125 - 5 tq for the TIME 1 segment (tseg1 = 4) +00126 - 2 tq for the TIME 2 segment (tseg2 = 1) +00127 - Because the bus clock of the MSCAN is 16 MHZ, and the +00128 freq of the time quantum is 8 MHZ (brp = 1+1), and there are 8 tq in the bit time, +00129 so the freq of the bit time is 1 MHz. +00130 */ +00131 } +00132 }; +00133 +00134 +00135 +00136 +00137 /**************************prototypes*****************************************/ +00138 +00139 //Init can bus and Canopen +00140 void initCanopencapteur (void); +00141 // Init the sensor +00142 void initSensor(void); +00143 void initPortB(void); +00144 void initPortH(void); +00145 +00146 +00147 //------------------------------------------------------------------------------ +00148 //Initialisation of the port B for the leds. +00149 void initPortB(void) +00150 { +00151 // Port B is output +00152 IO_PORTS_8(DDRB)= 0XFF; +00153 // RAZ +00154 IO_PORTS_8(PORTB) = 0xFF; +00155 } +00156 +00157 //------------------------------------------------------------------------------ +00158 // Init of port H to choose the CAN rate by switch, and the nodeId +00159 void initPortH(void) +00160 { +00161 // Port H is input +00162 IO_PORTS_8(DDRH)= 0X00; +00163 // Enable pull device +00164 IO_PORTS_8(PERH) = 0XFF; +00165 // Choose the pull-up device +00166 IO_PORTS_8(PPSH) = 0X00; +00167 } +00168 +00169 //------------------------------------------------------------------------------ +00170 void initSensor(void) +00171 { +00172 UNS8 baudrate = 0; +00173 UNS8 nodeId = 0; +00174 // Init led control +00175 initPortB(); +00176 IO_PORTS_8(PORTB) &= ~ 0x01; //One led ON +00177 initPortH(); +00178 +00179 /* Defining the node Id */ +00180 // Uncomment to have a fixed nodeId +00181 //setNodeId(&gene_SYNC_Data, 0x03); +00182 +00183 // Comment below to have a fixed nodeId +00184 nodeId = ~(IO_PORTS_8(PTH)) & 0x3F; +00185 if (nodeId == 0) { +00186 MSG_WAR(0x3F33, "Using default nodeId : ", getNodeId(&gene_SYNC_Data)); +00187 } +00188 else +00189 setNodeId(&gene_SYNC_Data, nodeId); +00190 +00191 MSG_WAR(0x3F33, "My nodeId is : ", getNodeId(&gene_SYNC_Data)); +00192 +00193 canBusInit bi0 = { +00194 0, /* no low power */ +00195 0, /* no time stamp */ +00196 1, /* enable MSCAN */ +00197 0, /* clock source : oscillator (In fact, it is not used) */ +00198 0, /* no loop back */ +00199 0, /* no listen only */ +00200 0, /* no low pass filter for wk up */ +00201 CAN_Baudrates[CAN_BAUDRATE_250K], +00202 { +00203 0x00, /* Filter on 16 bits. See Motorola Block Guide V02.14 fig 4-3 */ +00204 0x00, 0xFF, /* filter 0 hight accept all msg */ +00205 0x00, 0xFF, /* filter 0 low accept all msg */ +00206 0x00, 0xFF, /* filter 1 hight filter all of msg */ +00207 0x00, 0xFF, /* filter 1 low filter all of msg */ +00208 0x00, 0xFF, /* filter 2 hight filter most of msg */ +00209 0x00, 0xFF, /* filter 2 low filter most of msg */ +00210 0x00, 0xFF, /* filter 3 hight filter most of msg */ +00211 0x00, 0xFF, /* filter 3 low filter most of msg */ +00212 } +00213 }; +00214 +00215 //Init the HCS12 microcontroler for CanOpen +00216 initHCS12(); +00217 +00218 // Chose the CAN rate (On our board, whe have switch for all purpose) +00219 // 7 8 +00220 // ON ON => 1000 kpbs +00221 // OFF ON => 500 kpbs +00222 // ON OFF => 250 kpbs +00223 +00224 baudrate = ~(IO_PORTS_8(PTH)) & 0xC0; +00225 +00226 // Uncomment to have a fixed baudrate of 250 kbps +00227 //baudrate = 1; +00228 +00229 switch (baudrate) { +00230 case 0x40: +00231 bi0.clk = CAN_Baudrates[CAN_BAUDRATE_250K]; +00232 MSG_WAR(0x3F30, "CAN 250 kbps ", 0); +00233 break; +00234 case 0x80: +00235 bi0.clk = CAN_Baudrates[CAN_BAUDRATE_500K]; +00236 MSG_WAR(0x3F31, "CAN 500 kbps ", 0); +00237 break; +00238 case 0xC0: +00239 bi0.clk = CAN_Baudrates[CAN_BAUDRATE_1M]; +00240 MSG_WAR(0x3F31, "CAN 1000 kbps ", 0); +00241 break; +00242 default: +00243 bi0.clk = CAN_Baudrates[CAN_BAUDRATE_250K]; +00244 MSG_WAR(0x2F32, "CAN BAUD RATE NOT DEFINED => 250 kbps ", 0); +00245 } +00246 +00247 +00248 +00249 MSG_WAR(0x3F33, "SYNC signal generator ", 0); +00250 +00251 canInit(CANOPEN_LINE_NUMBER_USED, bi0); //initialize filters... +00252 initTimer(); // Init hcs12 timer used by CanFestival. (see timerhw.c) +00253 unlock(); // Allow interruptions +00254 } +00255 +00256 +00257 +00258 +00259 +00260 +00261 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +00262 // FUNCTIONS WHICH ARE PART OF CANFESTIVAL and *must* be implemented here. +00263 +00264 //------------------------------------------------------------------------------ +00265 void gene_SYNC_heartbeatError( UNS8 heartbeatID ) +00266 { +00267 +00268 MSG_ERR(0x1F00, "HeartBeat not received from node : ", heartbeatID); +00269 } +00270 +00271 //------------------------------------------------------------------------------ +00272 void gene_SYNC_initialisation() +00273 { +00274 MSG_WAR (0x3F00, "Entering in INIT ", 0); +00275 initSensor(); +00276 +00277 IO_PORTS_8(PORTB) &= ~ 0x01; // led 0 : ON +00278 IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3 : OFF +00279 +00280 } +00281 +00282 +00283 //------------------------------------------------------------------------------ +00284 void gene_SYNC_preOperational() +00285 { +00286 MSG_WAR (0x3F01, "Entering in PRE-OPERATIONAL ", 0); +00287 IO_PORTS_8(PORTB) &= ~ 0x03; // leds 0, 1 : ON +00288 IO_PORTS_8(PORTB) |= 0x0C; // leds 2, 3 : OFF +00289 /* default values for the msg CAN filters */ +00290 /* Accept all */ +00291 { +00292 canBusFilterInit filterConfiguration = +00293 { +00294 0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */ +00295 /*canidarx, canidmrx */ +00296 0x00, 0xFF, /* filter 0 */ +00297 0x00, 0xFF, /* filter 0 */ +00298 0x00, 0xFF, /* filter 1 */ +00299 0x00, 0xFF, /* filter 1 */ +00300 0x00, 0xFF, /* filter 2 */ +00301 0x00, 0xFF, /* filter 2 */ +00302 0x00, 0xFF, /* filter 3 */ +00303 0x00, 0xFF, /* filter 3 */ +00304 }; +00305 canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration); +00306 } +00307 // Reset the automatic change by SDO +00308 applyDownloadedFilters = 0; +00309 +00310 } +00311 +00312 +00313 //------------------------------------------------------------------------------ +00314 void gene_SYNC_operational() +00315 { +00316 MSG_WAR (0x3F02, "Entering in OPERATIONAL ", 0); +00317 IO_PORTS_8(PORTB) &= ~ 0x07; // leds 0, 1, 2 : ON +00318 IO_PORTS_8(PORTB) |= 0x08; // leds 3 : OFF +00319 +00320 // Filtering the CAN received msgs. +00321 // 2 ways +00322 // First :applying an automatic filter +00323 // Second : The values of the filtering registers are mapped in the object dictionary, +00324 // So that a filtering configuration can be downloaded by SDO in pre-operational mode +00325 +00326 if (applyDownloadedFilters == 0) {// No downloaded configuration to apply +00327 UNS16 accept1 = 0x0000; // Accept NMT +00328 UNS16 mask1 = 0x0FFF; // Mask NMT +00329 UNS16 accept2 = 0xE000; // Accept NMT error control (heartbeat, nodeguard) +00330 UNS16 mask2 = 0x0FFF; // Mask NMT error control (heartbeat, nodeguard) +00331 +00332 canBusFilterInit filterConfiguration = +00333 {// filters 3 and 4 not used, so configured like filter 1. +00334 0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */ +00335 /*canidarx, canidmrx */ +00336 (UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 1 id10...3*/ +00337 (UNS8)accept1 , (UNS8)mask1, /* filter 1 id2 ... */ +00338 (UNS8)(accept2 >> 8), (UNS8)(mask2 >> 8), /* filter 2 id10...3*/ +00339 (UNS8)accept2 , (UNS8)mask2, /* filter 2 id2 ... */ +00340 (UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 3 id10...3*/ +00341 (UNS8)accept1 , (UNS8)mask1, /* filter 3 id2 ... */ +00342 (UNS8)(accept1 >> 8), (UNS8)(mask1 >> 8), /* filter 4 id10...3*/ +00343 (UNS8)accept1 , (UNS8)mask1 /* filter 4 id2 ... */ +00344 }; +00345 canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration); +00346 MSG_WAR (0x3F03, "Internal CAN Rcv filter applied ", 0); +00347 } +00348 else { // Apply filters downnloaded +00349 canBusFilterInit filterConfiguration = +00350 {// filters 3 and 4 not used, so configured like filter 1. +00351 0x01, /* Filter on 16 bits. See Motorola Block Guide V02.14 */ +00352 /*canidarx, canidmrx */ +00353 (UNS8)( acceptanceFilter1>> 8), (UNS8)(mask1 >> 8), /* filter 1 id10...3*/ +00354 (UNS8)acceptanceFilter1 , (UNS8)mask1, /* filter 1 id2 ... */ +00355 (UNS8)(acceptanceFilter2 >> 8), (UNS8)(mask2 >> 8), /* filter 2 id10...3*/ +00356 (UNS8)acceptanceFilter2 , (UNS8)mask2, /* filter 2 id2 ... */ +00357 (UNS8)(acceptanceFilter3 >> 8), (UNS8)(mask3 >> 8), /* filter 3 id10...3*/ +00358 (UNS8)acceptanceFilter3 , (UNS8)mask3, /* filter 3 id2 ... */ +00359 (UNS8)(acceptanceFilter4 >> 8), (UNS8)(mask4 >> 8), /* filter 4 id10...3*/ +00360 (UNS8)acceptanceFilter4 , (UNS8)mask4 /* filter 4 id2 ... */ +00361 }; +00362 canChangeFilter(CANOPEN_LINE_NUMBER_USED, filterConfiguration); +00363 MSG_WAR (0x3F04, "Downloaded CAN Rcv filter applied ", 0); +00364 } +00365 } +00366 +00367 //------------------------------------------------------------------------------ +00368 void gene_SYNC_stopped() +00369 { +00370 MSG_WAR (0x3F02, "Entering in STOPPED ", 0); +00371 IO_PORTS_8(PORTB) |= 0x0E; // leds 1, 2, 3, 4 : OFF +00372 } +00373 +00374 // End functions which are part of Canfestival +00375 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +00376 +00377 +00378 /******************************************************************************/ +00379 /********************************* MAIN ***************************************/ +00380 /******************************************************************************/ +00381 +00382 +00383 UNS8 main (void) +00384 { +00385 +00386 MSG_WAR(0x3F34, "Entering in the main ", 0); +00387 //----------------------------- INITIALISATION -------------------------------- +00388 gene_SYNC_Data.heartbeatError = gene_SYNC_heartbeatError; +00389 gene_SYNC_Data.initialisation = gene_SYNC_initialisation; +00390 gene_SYNC_Data.preOperational = gene_SYNC_preOperational; +00391 gene_SYNC_Data.preOperational = gene_SYNC_operational; +00392 gene_SYNC_Data.stopped = gene_SYNC_stopped; +00393 +00394 +00395 /* Put the node in Initialisation mode */ +00396 MSG_WAR(0x3F35, "Will entering in INIT ", 0); +00397 setState(&gene_SYNC_Data, Initialisation); +00398 +00399 //----------------------------- START ----------------------------------------- +00400 /* Put the node in pre-operational mode */ +00401 //MSG_WAR(0x3F36, "va passer en pre-op", 0); +00402 //setState(&gene_SYNC_Data, Pre_operational); +00403 +00404 // Loop of receiving messages +00405 while (1) { +00406 Message m; +00407 if (f_can_receive(0, &m)) { +00408 //MSG_WAR(0x3F36, "Msg received", m.cob_id.w); +00409 lock(); // Not to have interruptions by timer, which can corrupt the data +00410 canDispatch(&gene_SYNC_Data, &m); +00411 unlock(); +00412 } +00413 } +00414 +00415 return (0); +00416 } +00417 +00418 +00419 +
#include <stddef.h>
#include <asm-m68hc12/portsaccess.h>
#include <asm-m68hc12/ports_def.h>
#include <asm-m68hc12/ports.h>
#include <interrupt.h>
#include "../include/data.h"
#include <applicfg.h>
#include "../include/hcs12/candriver.h"
#include "../include/hcs12/canOpenDriver.h"
#include "../include/def.h"
#include "../include/can.h"
#include "../include/objdictdef.h"
#include "../include/objacces.h"
#include "../include/sdo.h"
#include "../include/pdo.h"
#include "../include/timer.h"
#include "../include/lifegrd.h"
#include "../include/sync.h"
#include "../include/nmtSlave.h"
#include "objdict.h"
+Include dependency graph for appli.c:
+Go to the source code of this file.
Defines | |
#define | DEBUG_WAR_CONSOLE_ON |
#define | DEBUG_ERR_CONSOLE_ON |
Enumerations | |
enum | E_CanBaudrate { CAN_BAUDRATE_250K, +CAN_BAUDRATE_500K, +CAN_BAUDRATE_1M + } |
Functions | |
void | initCanopencapteur (void) |
void | initSensor (void) |
void | initPortB (void) |
void | initPortH (void) |
void | gene_SYNC_heartbeatError (UNS8 heartbeatID) |
void | gene_SYNC_initialisation () |
void | gene_SYNC_preOperational () |
void | gene_SYNC_operational () |
void | gene_SYNC_stopped () |
UNS8 | main (void) |
Variables | |
const canBusTime | CAN_Baudrates [] |
+
enum E_CanBaudrate | +
+
void gene_SYNC_heartbeatError | +( | +UNS8 | +heartbeatID | +) | ++ |
void gene_SYNC_initialisation | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 272 of file appli.c. +
+References initSensor(), IO_PORTS_8, MSG_WAR, and PORTB. +
+Referenced by main(). +
+Here is the call graph for this function:
void gene_SYNC_operational | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 314 of file appli.c. +
+References acceptanceFilter1, acceptanceFilter2, acceptanceFilter3, acceptanceFilter4, applyDownloadedFilters, canChangeFilter(), CANOPEN_LINE_NUMBER_USED, IO_PORTS_8, mask1, mask2, mask3, mask4, MSG_WAR, PORTB, UNS16, and UNS8. +
+Referenced by main(). +
+Here is the call graph for this function:
void gene_SYNC_preOperational | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 284 of file appli.c. +
+References applyDownloadedFilters, canChangeFilter(), CANOPEN_LINE_NUMBER_USED, IO_PORTS_8, MSG_WAR, and PORTB. +
+Referenced by main(). +
+Here is the call graph for this function:
void gene_SYNC_stopped | +( | +void | ++ | ) | ++ |
void initCanopencapteur | +( | +void | ++ | ) | ++ |
+ +
void initPortB | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 149 of file appli.c. +
+References DDRB, IO_PORTS_8, and PORTB. +
+Referenced by initSensor(). +
void initPortH | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 159 of file appli.c. +
+References DDRH, IO_PORTS_8, PERH, and PPSH. +
+Referenced by initSensor(). +
void initSensor | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 170 of file appli.c. +
+References CAN_BAUDRATE_1M, CAN_BAUDRATE_250K, CAN_BAUDRATE_500K, CAN_Baudrates, canInit(), CANOPEN_LINE_NUMBER_USED, canBusInit::clk, gene_SYNC_Data, getNodeId(), initHCS12(), initPortB(), initPortH(), initTimer(), IO_PORTS_8, MSG_WAR, PORTB, PTH, setNodeId(), unlock(), and UNS8. +
+Referenced by gene_SYNC_initialisation(). +
+Here is the call graph for this function:
UNS8 main | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 383 of file appli.c. +
+References canDispatch(), f_can_receive(), gene_SYNC_Data, gene_SYNC_heartbeatError(), gene_SYNC_initialisation(), gene_SYNC_operational(), gene_SYNC_preOperational(), gene_SYNC_stopped(), struct_CO_Data::heartbeatError, Initialisation, struct_CO_Data::initialisation, lock(), MSG_WAR, struct_CO_Data::preOperational, setState(), struct_CO_Data::stopped, and unlock(). +
+Here is the call graph for this function:
+
const canBusTime CAN_Baudrates[] | +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #define DEBUG_WAR_CONSOLE_ON +00024 #define DEBUG_ERR_CONSOLE_ON +00025 +00026 #include <stddef.h> /* for NULL */ +00027 +00028 #include "../include/hcs12/asm-m68hc12/portsaccess.h" +00029 #include "../include/hcs12/asm-m68hc12/ports_def.h" +00030 #include "../include/hcs12/asm-m68hc12/ports.h" +00031 #include "../include/data.h" +00032 #include "../include/hcs12/applicfg.h" +00033 #include "../include/hcs12/candriver.h" +00034 #include "../include/hcs12/interrupt.h" +00035 #include "../include/hcs12/canOpenDriver.h" +00036 #include "../include/can.h" +00037 #include "../include/objdictdef.h" +00038 #include "../include/timer.h" +00039 +00040 +00041 +00042 +00043 +00044 +00045 volatile static Message stackMsgRcv[NB_LINE_CAN][MAX_STACK_MSG_RCV]; +00046 volatile static t_pointerStack ptrMsgRcv[NB_LINE_CAN]; +00047 +00048 volatile static TIMEVAL last_time_set = TIMEVAL_MAX; +00049 static UNS8 timer_is_set = 0; +00050 +00051 /* Prototypes */ +00052 UNS8 f_can_receive(UNS8 notused, Message *m); +00053 UNS8 canSend(UNS8 notused, Message *m); +00054 void __attribute__((interrupt)) timer4Hdl (void); +00055 +00056 #define max(a,b) a>b?a:b +00057 +00058 /******************************************************************************/ +00059 void setTimer(TIMEVAL value) +00060 { +00061 IO_PORTS_16(TC4H) += value; +00062 timer_is_set = 1; +00063 } +00064 +00065 /******************************************************************************/ +00066 TIMEVAL getElapsedTime() +00067 { +00068 return (IO_PORTS_16(TC4H) > last_time_set ? IO_PORTS_16(TC4H) - last_time_set : last_time_set - IO_PORTS_16(TC4H)); +00069 } +00070 +00071 +00072 /******************************************************************************/ +00073 void resetTimer(void) +00074 { +00075 +00076 } +00077 +00078 /******************************************************************************/ +00079 void initTimer(void) +00080 { +00081 lock(); // Inhibition of interruptions +00082 +00083 // Configure the timer channel 4 +00084 IO_PORTS_8(TIOS) |= 0x10; // Canal 4 in output +00085 IO_PORTS_8(TCTL1) &= ~(0x01 + 0x02); // Canal 4 unconnected to pin output +00086 IO_PORTS_8(TIE) |= 0x10; // allow interruption channel 4 +00087 IO_PORTS_8(TSCR2) |= 0X05; // Pre-scaler = 32 +00088 // If this value is changed, change must be done also +00089 // in void __attribute__((interrupt)) timer4Hdl (void) +00090 +00091 IO_PORTS_8(TSCR1) |= 0x80; // Start timer +00092 unlock(); // Allow interruptions +00093 } +00094 +00095 /******************************************************************************/ +00096 void __attribute__((interrupt)) timer4Hdl (void) +00097 { +00098 lock(); +00099 last_time_set = IO_PORTS_16(TC4H); +00100 IO_PORTS_8(TFLG1) = 0x10; // RAZ flag interruption timer channel 4 +00101 // Compute the next event : When the timer reach the value of TC4, an interrupt is +00102 // started +00103 //IO_PORTS_16(TC4H) += 250; // To have an interruption every 1 ms +00104 //timerInterrupt(0); +00105 //MSG_WAR(0xFFFF, "timer4 IT", 0); +00106 { +00107 //MSG_WAR(0xFFFF, "t4 ", IO_PORTS_16(TCNTH) - IO_PORTS_16(TC4H)); +00108 } +00109 TimeDispatch(); +00110 unlock(); +00111 } +00112 +00113 +00114 /******************************************************************************/ +00115 void initSCI_0(void) +00116 { +00117 IO_PORTS_16(SCI0 + SCIBDH) = +00118 ((1000000 / SERIAL_SCI0_BAUD_RATE) * BUS_CLOCK) >> 4 ; +00119 IO_PORTS_8(SCI0 + SCICR1) = 0; // format 8N1 +00120 IO_PORTS_8(SCI0 + SCICR2) = 0x08; // Transmit enable only +00121 } +00122 +00123 /******************************************************************************/ +00124 void initSCI_1(void) +00125 { +00126 IO_PORTS_16(SCI1 + SCIBDH) = +00127 ((1000000 / SERIAL_SCI1_BAUD_RATE) * BUS_CLOCK) >> 4 ; +00128 IO_PORTS_8(SCI1 + SCICR1) = 0; // format 8N1 +00129 IO_PORTS_8(SCI1 + SCICR2) = 0x08; // Transmit enable only +00130 } +00131 +00132 +00133 /******************************************************************************/ +00134 char * +00135 hex_convert (char *buf, unsigned long value, char lastCar) +00136 { +00137 //Thanks to Stéphane Carrez for this function +00138 char num[32]; +00139 int pos; +00140 +00141 *buf++ = '0'; +00142 *buf++ = 'x'; +00143 +00144 pos = 0; +00145 while (value != 0) { +00146 char c = value & 0x0F; +00147 num[pos++] = "0123456789ABCDEF"[(unsigned) c]; +00148 value = (value >> 4) & (0x0fffffffL); +00149 } +00150 if (pos == 0) +00151 num[pos++] = '0'; +00152 +00153 while (--pos >= 0) +00154 *buf++ = num[pos]; +00155 +00156 *buf++ = lastCar; +00157 *buf = 0; +00158 return buf; +00159 } +00160 +00161 /******************************************************************************/ +00162 void printSCI_str(char sci, const char * str) +00163 { +00164 char i = 0; +00165 +00166 while ((*(str + i) != 0) && (i < 0xFF)) { +00167 if (*(str + i) == '\n') +00168 { +00169 while ((IO_PORTS_8(sci + SCISR1) & 0X80) == 0); // wait if buffer not empty +00170 IO_PORTS_8(sci + SCIDRL) = 13; // return to start of line +00171 } +00172 while ((IO_PORTS_8(sci + SCISR1) & 0X80) == 0); // wait if buffer not empty +00173 IO_PORTS_8(sci + SCIDRL) = *(str + i++); +00174 } +00175 +00176 } +00177 +00178 /******************************************************************************/ +00179 void printSCI_nbr(char sci, unsigned long nbr, char lastCar) +00180 { +00181 char strNbr[12]; +00182 hex_convert(strNbr, nbr, lastCar); +00183 printSCI_str(sci, strNbr); +00184 } +00185 +00186 /******************************************************************************/ +00187 // PLL 24 MHZ if quartz on board is 16 MHZ +00188 void initPLL(void) +00189 { +00190 IO_PORTS_8(CLKSEL) &= ~0x80; // unselect the PLL +00191 IO_PORTS_8(PLLCTL) |= 0X60; // PLL ON and bandwidth auto +00192 IO_PORTS_8(SYNR) = 0x02; +00193 IO_PORTS_8(REFDV) = 0x01; +00194 while ((IO_PORTS_8(CRGFLG) & 0x08) == 0); +00195 IO_PORTS_8(CLKSEL) |= 0x80; +00196 } +00197 +00198 /******************************************************************************/ +00199 void initHCS12(void) +00200 { +00201 +00202 # ifdef USE_PLL +00203 MSG_WAR(0x3620, "Use the PLL ", 0); +00204 initPLL(); +00205 # endif +00206 +00207 } +00208 +00209 /***************************************************************************/ +00210 char canAddIdToFilter(UNS16 adrCAN, UNS8 nFilter, UNS16 id) +00211 { +00212 UNS8 fiMsb; +00213 UNS8 fiLsb; +00214 UNS8 idMsb = (UNS8) (id >> 3); +00215 UNS8 idLsb = (UNS8) (id << 5); +00216 +00217 if (! canTestInitMode(adrCAN)) { +00218 /* Error because not init mode */ +00219 MSG_WAR(0X2600, "Not in init mode ", 0); +00220 return 1; +00221 } +00222 switch (nFilter) { +00223 case 0: +00224 nFilter = CANIDAR0; /* First bank */ +00225 break; +00226 case 1: +00227 nFilter = CANIDAR2; /* First bank */ +00228 break; +00229 case 2: +00230 nFilter = CANIDAR4; /* Second bank */ +00231 break; +00232 case 3: +00233 nFilter = CANIDAR6; /* Second bank */ +00234 } +00235 if (! IO_PORTS_16(adrCAN + nFilter)) { +00236 /* if CANIDARx = 0 */ +00237 IO_PORTS_8(adrCAN + nFilter) = idMsb; +00238 IO_PORTS_8(adrCAN + nFilter + 1) = idLsb; +00239 } +00240 fiMsb = IO_PORTS_8(adrCAN + nFilter) ^ idMsb; +00241 fiLsb = IO_PORTS_8(adrCAN + nFilter + 1) ^ idLsb; +00242 /* address of CANIDMRx */ +00243 IO_PORTS_8(adrCAN + nFilter + 4) = IO_PORTS_8(adrCAN + nFilter + 4) | fiMsb; +00244 IO_PORTS_8(adrCAN + nFilter + 5) = IO_PORTS_8(adrCAN + nFilter + 5) | fiLsb; +00245 IO_PORTS_8(adrCAN + nFilter + 5) |= 0x10; /* Not filtering on rtr value */ +00246 return 0; +00247 } +00248 +00249 /***************************************************************************/ +00250 char canChangeFilter(UNS16 adrCAN, canBusFilterInit fi) +00251 { +00252 /* If not in init mode, go to sleep before going in init mode*/ +00253 if (! canTestInitMode(adrCAN)) { +00254 canSleepMode(adrCAN); +00255 canInitMode(adrCAN); +00256 } +00257 //update the filters configuration +00258 canInitFilter(adrCAN, fi); +00259 canInitModeQ(adrCAN); +00260 canSleepModeQ(adrCAN); +00261 canSetInterrupt(adrCAN); +00262 return 0; +00263 } +00264 +00265 /***************************************************************************/ +00266 char canEnable(UNS16 adrCAN) +00267 { +00268 /* Register CANCTL1 +00269 bit 7 : 1 MSCAN enabled +00270 Other bits : default reset values +00271 */ +00272 IO_PORTS_8(adrCAN + CANCTL1) = 0X80; +00273 return 0; +00274 } +00275 +00276 /***************************************************************************/ +00277 char canInit(UNS16 adrCAN, canBusInit bi) +00278 { +00279 /* If not in init mode, go to sleep before going in init mode*/ +00280 if (! canTestInitMode(adrCAN)) { +00281 canSleepMode(adrCAN); +00282 canInitMode(adrCAN); +00283 } +00284 +00285 canEnable(adrCAN); /* Does nothing if already enable */ +00286 /* The most secure way to go in init mode : put before MSCAN in sleep mode */ +00287 //canSleepMode(adrCAN); +00288 /* Put MSCAN in Init mode */ +00289 //canInitMode(adrCAN); +00290 canInitClock(adrCAN, bi.clk); +00291 /* Init CANCTL1 register. Must be in init mode */ +00292 IO_PORTS_8(adrCAN + CANCTL1) &=0xC4;// 0xCB; /* Clr the bits that may be modified */ +00293 IO_PORTS_8(adrCAN + CANCTL1) = (bi.cane << 7) | (bi.loopb << 5 ) | +00294 (bi.listen << 4) | (bi.wupm << 2); +00295 /* Initialize the filters for received msgs */ +00296 /* We should decide to accept all the msgs */ +00297 canInitFilter(adrCAN, bi.fi); +00298 /* Before to modify CANCTL0, we must leave the init mode */ +00299 canInitModeQ(adrCAN); +00300 /* Init CANCTL0 register. MSCAN must not be in init mode */ +00301 /* Do not change the value of wupe (should be 0) and slprq (should be 1) */ +00302 /* Do not change the value of initrq (should be 0) */ +00303 /* rxfrm is cleared, mupe also (should be before)*/ +00304 IO_PORTS_8(adrCAN + CANCTL0) &= 0x53; /* Clr the bits that may be modified */ +00305 IO_PORTS_8(adrCAN + CANCTL0) = (bi.cswai << 5) | (bi.time << 3); +00306 canSetInterrupt(adrCAN); +00307 canInitModeQ(adrCAN); /* Leave the init mode */ +00308 canSleepModeQ(adrCAN); /* Leave the sleep mode */ +00309 return 0; +00310 } +00311 +00312 /***************************************************************************/ +00313 char canInitClock(UNS16 adrCAN, canBusTime clk) +00314 { +00315 if (! canTestInitMode(adrCAN)) { +00316 /* Not in Init mode */ +00317 MSG_WAR(0X2601, "not in init mode ", 0); +00318 return 1; +00319 } +00320 /* Set or reset CLKSRC (register CANCTL1). Does not change the other bits*/ +00321 clk.clksrc = clk.clksrc << 6; +00322 IO_PORTS_8(adrCAN + CANCTL1) &= 0xBF; +00323 IO_PORTS_8(adrCAN + CANCTL1) |= clk.clksrc; +00324 /* Build the CANBTR0 register */ +00325 IO_PORTS_8(adrCAN + CANBTR0) = 0x00; /* Clear before changes */ +00326 IO_PORTS_8(adrCAN + CANBTR0) = (clk.sjw << 6) | (clk.brp); +00327 /* Build the CANBTR1 register */ +00328 IO_PORTS_8(adrCAN + CANBTR1) = 0x00; /* Clear before changes */ +00329 IO_PORTS_8(adrCAN + CANBTR1) = (clk.samp << 7) | (clk.tseg2 << 4) | +00330 (clk.tseg1); +00331 return 0; +00332 } +00333 +00334 /***************************************************************************/ +00335 char canInit1Filter(UNS16 adrCAN, UNS8 nFilter, UNS16 ar, UNS16 mr) +00336 { +00337 if (! canTestInitMode(adrCAN)) { +00338 /* Error because not init mode */ +00339 MSG_WAR(0X2602, "not in init mode ", 0); +00340 return 1; +00341 } +00342 switch (nFilter) { +00343 case 0: +00344 nFilter = CANIDAR0; /* First bank */ +00345 break; +00346 case 1: +00347 nFilter = CANIDAR2; /* First bank */ +00348 break; +00349 case 2: +00350 nFilter = CANIDAR4; /* Second bank */ +00351 break; +00352 case 3: +00353 nFilter = CANIDAR6; /* Second bank */ +00354 } +00355 /* address of CANIDARx */ +00356 IO_PORTS_8(adrCAN + nFilter) = (UNS8) (ar >> 8); +00357 IO_PORTS_8(adrCAN + nFilter + 1) = (UNS8) (ar); +00358 IO_PORTS_8(adrCAN + nFilter + 4) = (UNS8) (mr >> 8); +00359 IO_PORTS_8(adrCAN + nFilter + 5) = (UNS8) (mr); +00360 return 0; +00361 } +00362 +00363 /***************************************************************************/ +00364 char canInitFilter(UNS16 adrCAN, canBusFilterInit fi) +00365 { +00366 if (! canTestInitMode(adrCAN)) { +00367 /* Error because not init mode */ +00368 MSG_WAR(0X2603, "not in init mode ", 0); +00369 return 1; +00370 } +00371 IO_PORTS_8(adrCAN + CANIDAC) = fi.idam << 4; +00372 IO_PORTS_8(adrCAN + CANIDAR0) = fi.canidar0; +00373 IO_PORTS_8(adrCAN + CANIDMR0) = fi.canidmr0; +00374 IO_PORTS_8(adrCAN + CANIDAR1) = fi.canidar1; +00375 IO_PORTS_8(adrCAN + CANIDMR1) = fi.canidmr1; +00376 IO_PORTS_8(adrCAN + CANIDAR2) = fi.canidar2; +00377 IO_PORTS_8(adrCAN + CANIDMR2) = fi.canidmr2; +00378 IO_PORTS_8(adrCAN + CANIDAR3) = fi.canidar3; +00379 IO_PORTS_8(adrCAN + CANIDMR3) = fi.canidmr3; +00380 IO_PORTS_8(adrCAN + CANIDAR4) = fi.canidar4; +00381 IO_PORTS_8(adrCAN + CANIDMR4) = fi.canidmr4; +00382 IO_PORTS_8(adrCAN + CANIDAR5) = fi.canidar5; +00383 IO_PORTS_8(adrCAN + CANIDMR5) = fi.canidmr5; +00384 IO_PORTS_8(adrCAN + CANIDAR6) = fi.canidar6; +00385 IO_PORTS_8(adrCAN + CANIDMR6) = fi.canidmr6; +00386 IO_PORTS_8(adrCAN + CANIDAR7) = fi.canidar7; +00387 IO_PORTS_8(adrCAN + CANIDMR7) = fi.canidmr7; +00388 return 0; +00389 } +00390 +00391 /***************************************************************************/ +00392 char canInitMode(UNS16 adrCAN) +00393 { +00394 IO_PORTS_8(adrCAN + CANCTL0) |= 0x01; /* Set the bit INITRQ */ +00395 while (! canTestInitMode(adrCAN)) { +00396 } +00397 return 0; +00398 } +00399 +00400 /***************************************************************************/ +00401 char canInitModeQ(UNS16 adrCAN) +00402 { +00403 IO_PORTS_8(adrCAN + CANCTL0) &= 0xFE; /* Clear the bit INITRQ */ +00404 while (canTestInitMode(adrCAN)) { +00405 } +00406 return 0; +00407 } +00408 +00409 /***************************************************************************/ +00410 char canMsgTransmit(UNS16 adrCAN, Message msg) +00411 { +00412 /* Remind : only CAN A msg implemented. ie id on 11 bits, not 29 */ +00413 UNS8 cantflg; +00414 UNS8 i; +00415 /* Looking for a free buffer */ +00416 cantflg = IO_PORTS_8(adrCAN + CANTFLG); +00417 if ( cantflg == 0) { /* all the TXEx are set */ +00418 MSG_WAR(0X2604, "No buffer free. Msg to transmit is losted ", 0); +00419 return 1; /* No buffer free */ +00420 } +00421 else{ +00422 /* Selecting a buffer */ +00423 IO_PORTS_8(adrCAN + CANTBSEL) = cantflg; +00424 /* We put ide = 0 because id is on 11 bits only */ +00425 IO_PORTS_8(adrCAN + CANTRSID) = (UNS8)(msg.cob_id.w >> 3); +00426 IO_PORTS_8(adrCAN + CANTRSID + 1) = (UNS8)((msg.cob_id.w << 5)| +00427 (msg.rtr << 4)); +00428 +00429 IO_PORTS_8(adrCAN + CANTRSLEN) = msg.len & 0X0F; +00430 /* For the priority, we put the highter bits of the cob_id */ +00431 IO_PORTS_8(adrCAN + CANTRSPRI) = IO_PORTS_8(adrCAN + CANTRSID); +00432 for (i = 0 ; i < msg.len ; i++) { +00433 IO_PORTS_8(adrCAN + CANTRSDTA + i) = msg.data[i]; +00434 } +00435 /* Transmitting the message */ +00436 cantflg = IO_PORTS_8(adrCAN + CANTBSEL);/* to know which buf is selected */ +00437 IO_PORTS_8(adrCAN + CANTBSEL) = 0x00; +00438 IO_PORTS_8(adrCAN + CANTFLG) = cantflg; /* Ready to transmit ! */ +00439 +00440 } +00441 return 0; +00442 } +00443 +00444 /***************************************************************************/ +00445 char canSetInterrupt(UNS16 adrCAN) +00446 { +00447 IO_PORTS_8(adrCAN + CANRIER) = 0X01; /* Allow interruptions on receive */ +00448 IO_PORTS_8(adrCAN + CANTIER) = 0X00; /* disallow interruptions on transmit */ +00449 return 0; +00450 } +00451 /***************************************************************************/ +00452 char canSleepMode(UNS16 adrCAN) +00453 { +00454 IO_PORTS_8(adrCAN + CANCTL0) &= 0xFB; /* clr the bit WUPE to avoid a wake-up*/ +00455 IO_PORTS_8(adrCAN + CANCTL0) |= 0x02; /* Set the bit SLPRQ. go to Sleep !*/ +00456 +00457 // IO_PORTS_8(adrCAN + CANCTL1) |= 0x04; +00458 // IO_PORTS_8(adrCAN + CANCTL0) |= 0x02; /* Set the bit SLPRQ */ +00459 while ( ! canTestSleepMode(adrCAN)) { +00460 } +00461 +00462 return 0; +00463 } +00464 +00465 /***************************************************************************/ +00466 char canSleepModeQ(UNS16 adrCAN) +00467 { +00468 if (canTestInitMode(adrCAN)) { +00469 /* Error because in init mode */ +00470 MSG_WAR(0X2606, "not in init mode ", 0); +00471 return 1; +00472 } +00473 IO_PORTS_8(adrCAN + CANCTL0) &= 0xFD; /* clr the bit SLPRQ */ +00474 while ( canTestSleepMode(adrCAN)) { +00475 } +00476 return 0; +00477 } +00478 +00479 /***************************************************************************/ +00480 char canSleepWupMode(UNS16 adrCAN) +00481 { +00482 if (canTestInitMode(adrCAN)) { +00483 MSG_WAR(0X2607, "not in init mode ", 0); +00484 return 1; +00485 } +00486 IO_PORTS_8(adrCAN + CANCTL0) |= 0x06; /* Set the bits WUPE & SLPRQ */ +00487 while ( ! canTestSleepMode(adrCAN)) { +00488 } +00489 return 0; +00490 } +00491 +00492 /***************************************************************************/ +00493 char canTestInitMode(UNS16 adrCAN) +00494 { +00495 return IO_PORTS_8(adrCAN + CANCTL1) & 0x01; /* Test the bit INITAK */ +00496 } +00497 +00498 /***************************************************************************/ +00499 char canTestSleepMode(UNS16 adrCAN) +00500 { +00501 return IO_PORTS_8(adrCAN + CANCTL1) & 0x02; /* Test the bit SLPAK */ +00502 } +00503 +00504 /***************************************************************************/ +00505 UNS8 canSend(UNS8 notused, Message *m) +00506 { +00507 canMsgTransmit(CANOPEN_LINE_NUMBER_USED, *m); +00508 return 0; +00509 } +00510 +00511 +00512 /**************************************************************************/ +00513 UNS8 f_can_receive(UNS8 notused, Message *msgRcv) +00514 { +00515 UNS8 i, j; +00516 +00517 switch (CANOPEN_LINE_NUMBER_USED) { +00518 case CAN0 : j = 0; break; +00519 case CAN1 : j = 1; break; +00520 case CAN2 : j = 2; break; +00521 case CAN3 : j = 3; break; +00522 case CAN4 : j = 4; break; +00523 } +00524 +00525 /* See if a message is pending in the stack */ +00526 if (ptrMsgRcv[j].r == ptrMsgRcv[j].w) +00527 return 0x0; // No new message +00528 +00529 /* Increment the reading pointer of the stack */ +00530 if (ptrMsgRcv[j].r == (MAX_STACK_MSG_RCV - 1)) +00531 ptrMsgRcv[j].r = 0; +00532 else +00533 ptrMsgRcv[j].r ++; +00534 +00535 /* Store the message from the stack*/ +00536 msgRcv->cob_id.w = stackMsgRcv[j][ptrMsgRcv[j].r].cob_id.w; +00537 msgRcv->len = stackMsgRcv[j][ptrMsgRcv[j].r].len; +00538 msgRcv->rtr = stackMsgRcv[j][ptrMsgRcv[j].r].rtr; +00539 for (i = 0 ; i < stackMsgRcv[j][ptrMsgRcv[j].r].len ; i++) +00540 msgRcv->data[i] = stackMsgRcv[j][ptrMsgRcv[j].r].data[i]; +00541 return 0xFF; +00542 } +00543 +00544 +00545 /****************************************************************************** +00546 ******************************* CAN INTERRUPT *******************************/ +00547 +00548 void __attribute__((interrupt)) can0HdlTra (void) +00549 { +00550 +00551 } +00552 +00553 void __attribute__((interrupt)) can0HdlRcv (void) +00554 { +00555 UNS8 i; +00556 lock(); +00557 IO_PORTS_8(PORTB) &= ~ 0x40; // led 6 port B : ON +00558 UNS8 NewPtrW; +00559 /* We are obliged to save the message while the interruption is pending */ +00560 /* Increment the writing stack pointer before writing the msg */ +00561 if (ptrMsgRcv[0].w == (MAX_STACK_MSG_RCV - 1)) +00562 NewPtrW = 0; +00563 else +00564 NewPtrW = ptrMsgRcv[0].w + 1; +00565 +00566 if (NewPtrW == ptrMsgRcv[0].r) { +00567 /* The stack is full. The last msg received before this one is lost */ +00568 MSG_WAR(0X1620, "Stack for received msg is full", 0); +00569 //IO_PORTS_8(PORTB) &= ~0x40; // led 6 : ON (for debogue) +00570 } +00571 else +00572 ptrMsgRcv[0].w = NewPtrW; +00573 +00574 /* Store the message */ +00575 stackMsgRcv[0][ptrMsgRcv[0].w].cob_id.w = IO_PORTS_16(CAN0 + CANRCVID) >> 5; +00576 stackMsgRcv[0][ptrMsgRcv[0].w].len = IO_PORTS_8(CAN0 + CANRCVLEN) & 0x0F; +00577 stackMsgRcv[0][ptrMsgRcv[0].w].rtr = (IO_PORTS_8(CAN0 + CANRCVID + 1) >> 4) & 0x01; +00578 for (i = 0 ; i < stackMsgRcv[0][ptrMsgRcv[0].w].len ; i++) +00579 stackMsgRcv[0][ptrMsgRcv[0].w].data[i] = IO_PORTS_8(CAN0 + CANRCVDTA + i); +00580 +00581 // The message is stored , so +00582 // we can now release the receive foreground buffer +00583 // and acknowledge the interruption +00584 IO_PORTS_8(CAN0 + CANRFLG) |= 0x01; +00585 // Not very usefull +00586 IO_PORTS_8(CAN0 + CANCTL0) |= 0x80; +00587 IO_PORTS_8(PORTB) |= 0x40; // led 6 port B : OFF +00588 unlock(); +00589 } +00590 +00591 void __attribute__((interrupt)) can0HdlWup (void) +00592 { +00593 +00594 } +00595 +00596 void __attribute__((interrupt)) can0HdlErr (void) +00597 { +00598 +00599 } +00600 +00601 void __attribute__((interrupt)) can1HdlTra (void) +00602 { +00603 +00604 } +00605 +00606 void __attribute__((interrupt)) can1HdlRcv (void) +00607 { +00608 UNS8 i; +00609 lock(); +00610 UNS8 NewPtrW; +00611 /* We are obliged to save the message while the interruption is pending */ +00612 /* Increment the writing stack pointer before writing the msg */ +00613 if (ptrMsgRcv[1].w == (MAX_STACK_MSG_RCV - 1)) +00614 NewPtrW = 0; +00615 else +00616 NewPtrW = ptrMsgRcv[1].w + 1; +00617 +00618 if (NewPtrW == ptrMsgRcv[1].r) { +00619 /* The stack is full. The last msg received before this one is lost */ +00620 MSG_WAR(0X2620, "Stack for received msg is full", 0); +00621 } +00622 else +00623 ptrMsgRcv[1].w = NewPtrW; +00624 +00625 /* Store the message */ +00626 stackMsgRcv[1][ptrMsgRcv[1].w].cob_id.w = IO_PORTS_16(CAN1 + CANRCVID) >> 5; +00627 stackMsgRcv[1][ptrMsgRcv[1].w].len = IO_PORTS_8(CAN1 + CANRCVLEN) & 0x0F; +00628 stackMsgRcv[0][ptrMsgRcv[0].w].rtr = (IO_PORTS_8(CAN1 + CANRCVID + 1) >> 4) & 0x01; +00629 for (i = 0 ; i < stackMsgRcv[1][ptrMsgRcv[1].w].len ; i++) +00630 stackMsgRcv[1][ptrMsgRcv[1].w].data[i] = IO_PORTS_8(CAN1 + CANRCVDTA + i); +00631 +00632 // The message is stored , so +00633 // we can now release the receive foreground buffer +00634 // and acknowledge the interruption +00635 IO_PORTS_8(CAN1 + CANRFLG) |= 0x01; +00636 // Not very usefull +00637 IO_PORTS_8(CAN1 + CANCTL0) |= 0x80; +00638 unlock(); +00639 } +00640 +00641 void __attribute__((interrupt)) can1HdlWup (void) +00642 { +00643 +00644 } +00645 +00646 void __attribute__((interrupt)) can1HdlErr (void) +00647 { +00648 +00649 } +00650 +00651 void __attribute__((interrupt)) can2HdlTra (void) +00652 { +00653 +00654 } +00655 +00656 void __attribute__((interrupt)) can2HdlRcv (void) +00657 { +00658 +00659 } +00660 +00661 void __attribute__((interrupt)) can2HdlWup (void) +00662 { +00663 +00664 } +00665 +00666 void __attribute__((interrupt)) can2HdlErr (void) +00667 { +00668 +00669 } +00670 +00671 void __attribute__((interrupt)) can3HdlTra (void) +00672 { +00673 +00674 } +00675 +00676 void __attribute__((interrupt)) can3HdlRcv (void) +00677 { +00678 +00679 } +00680 +00681 void __attribute__((interrupt)) can3HdlWup (void) +00682 { +00683 +00684 } +00685 +00686 void __attribute__((interrupt)) can3HdlErr (void) +00687 { +00688 +00689 } +00690 +00691 void __attribute__((interrupt)) can4HdlTra (void) +00692 { +00693 +00694 } +00695 +00696 void __attribute__((interrupt)) can4HdlRcv (void) +00697 { +00698 +00699 } +00700 +00701 void __attribute__((interrupt)) can4HdlWup (void) +00702 { +00703 +00704 } +00705 +00706 void __attribute__((interrupt)) can4HdlErr (void) +00707 { +00708 +00709 } +00710 +00711 +00712 +
#include <stddef.h>
#include "../include/hcs12/asm-m68hc12/portsaccess.h"
#include "../include/hcs12/asm-m68hc12/ports_def.h"
#include "../include/hcs12/asm-m68hc12/ports.h"
#include "../include/data.h"
#include "../include/hcs12/applicfg.h"
#include "../include/hcs12/candriver.h"
#include "../include/hcs12/interrupt.h"
#include "../include/hcs12/canOpenDriver.h"
#include "../include/can.h"
#include "../include/objdictdef.h"
#include "../include/timer.h"
+Include dependency graph for canOpenDriver.c:
+Go to the source code of this file.
Defines | |
#define | DEBUG_WAR_CONSOLE_ON |
#define | DEBUG_ERR_CONSOLE_ON |
#define | max(a, b) a>b?a:b |
Functions | |
UNS8 | f_can_receive (UNS8 notused, Message *m) |
UNS8 | canSend (UNS8 notused, Message *m) |
void | __attribute__ ((interrupt)) |
TIMEVAL | getElapsedTime () |
void | resetTimer (void) |
void | initTimer (void) |
void | initSCI_0 (void) |
Initialisation of the serial port 0. | |
void | initSCI_1 (void) |
Initialisation of the serial port 1. | |
char * | hex_convert (char *buf, unsigned long value, char lastCar) |
void | printSCI_str (char sci, const char *str) |
void | printSCI_nbr (char sci, unsigned long nbr, char lastCar) |
void | initPLL (void) |
void | initHCS12 (void) |
Put here all the code to init the HCS12. | |
char | canAddIdToFilter (UNS16 adrCAN, UNS8 nFilter, UNS16 id) |
char | canChangeFilter (UNS16 adrCAN, canBusFilterInit fi) |
char | canEnable (UNS16 adrCAN) |
char | canInit (UNS16 adrCAN, canBusInit bi) |
char | canInitClock (UNS16 adrCAN, canBusTime clk) |
char | canInit1Filter (UNS16 adrCAN, UNS8 nFilter, UNS16 ar, UNS16 mr) |
char | canInitFilter (UNS16 adrCAN, canBusFilterInit fi) |
char | canInitMode (UNS16 adrCAN) |
char | canInitModeQ (UNS16 adrCAN) |
char | canMsgTransmit (UNS16 adrCAN, Message msg) |
char | canSetInterrupt (UNS16 adrCAN) |
char | canSleepMode (UNS16 adrCAN) |
char | canSleepModeQ (UNS16 adrCAN) |
char | canSleepWupMode (UNS16 adrCAN) |
char | canTestInitMode (UNS16 adrCAN) |
char | canTestSleepMode (UNS16 adrCAN) |
#define DEBUG_ERR_CONSOLE_ON | +
+ +
+Definition at line 24 of file canOpenDriver.c. +
#define DEBUG_WAR_CONSOLE_ON | +
+ +
+Definition at line 23 of file canOpenDriver.c. +
#define max | +( | +a, | |||
+ | + | b | ++ | ) | +a>b?a:b | +
+ +
+
void __attribute__ | +( | +(interrupt) | ++ | ) | ++ |
+Message transmitted on MSCAN 0 +
+Definition at line 54 of file canOpenDriver.c. +
+References IO_PORTS_16, and TC4H. +
char canAddIdToFilter | +( | +UNS16 | +adrCAN, | +|
+ | + | UNS8 | +nFilter, | +|
+ | + | UNS16 | +id | + |
+ | ) | ++ |
+ +
+Definition at line 210 of file canOpenDriver.c. +
+References CANIDAR0, CANIDAR2, CANIDAR4, CANIDAR6, canTestInitMode(), IO_PORTS_16, IO_PORTS_8, MSG_WAR, and UNS8. +
+Here is the call graph for this function:
char canChangeFilter | +( | +UNS16 | +adrCAN, | +|
+ | + | canBusFilterInit | +fi | + |
+ | ) | ++ |
+ +
+Definition at line 250 of file canOpenDriver.c. +
+References canInitFilter(), canInitMode(), canInitModeQ(), canSetInterrupt(), canSleepMode(), canSleepModeQ(), and canTestInitMode(). +
+Referenced by gene_SYNC_operational(), and gene_SYNC_preOperational(). +
+Here is the call graph for this function:
char canEnable | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 266 of file canOpenDriver.c. +
+References CANCTL1, and IO_PORTS_8. +
+Referenced by canInit(). +
char canInit | +( | +UNS16 | +adrCAN, | +|
+ | + | canBusInit | +bi | + |
+ | ) | ++ |
+ +
+Definition at line 277 of file canOpenDriver.c. +
+References CANCTL0, CANCTL1, canBusInit::cane, canEnable(), canInitClock(), canInitFilter(), canInitMode(), canInitModeQ(), canSetInterrupt(), canSleepMode(), canSleepModeQ(), canTestInitMode(), canBusInit::clk, canBusInit::cswai, canBusInit::fi, IO_PORTS_8, canBusInit::listen, canBusInit::loopb, canBusInit::time, and canBusInit::wupm. +
+Here is the call graph for this function:
char canInit1Filter | +( | +UNS16 | +adrCAN, | +|
+ | + | UNS8 | +nFilter, | +|
+ | + | UNS16 | +ar, | +|
+ | + | UNS16 | +mr | + |
+ | ) | ++ |
+ +
+Definition at line 335 of file canOpenDriver.c. +
+References CANIDAR0, CANIDAR2, CANIDAR4, CANIDAR6, canTestInitMode(), IO_PORTS_8, MSG_WAR, and UNS8. +
+Here is the call graph for this function:
char canInitClock | +( | +UNS16 | +adrCAN, | +|
+ | + | canBusTime | +clk | + |
+ | ) | ++ |
+ +
+Definition at line 313 of file canOpenDriver.c. +
+References canBusTime::brp, CANBTR0, CANBTR1, CANCTL1, canTestInitMode(), canBusTime::clksrc, IO_PORTS_8, MSG_WAR, canBusTime::samp, canBusTime::sjw, canBusTime::tseg1, and canBusTime::tseg2. +
+Referenced by canInit(). +
+Here is the call graph for this function:
char canInitFilter | +( | +UNS16 | +adrCAN, | +|
+ | + | canBusFilterInit | +fi | + |
+ | ) | ++ |
+ +
+Definition at line 364 of file canOpenDriver.c. +
+References CANIDAC, CANIDAR0, canBusFilterInit::canidar0, CANIDAR1, canBusFilterInit::canidar1, CANIDAR2, canBusFilterInit::canidar2, CANIDAR3, canBusFilterInit::canidar3, CANIDAR4, canBusFilterInit::canidar4, CANIDAR5, canBusFilterInit::canidar5, CANIDAR6, canBusFilterInit::canidar6, CANIDAR7, canBusFilterInit::canidar7, CANIDMR0, canBusFilterInit::canidmr0, CANIDMR1, canBusFilterInit::canidmr1, CANIDMR2, canBusFilterInit::canidmr2, CANIDMR3, canBusFilterInit::canidmr3, CANIDMR4, canBusFilterInit::canidmr4, CANIDMR5, canBusFilterInit::canidmr5, CANIDMR6, canBusFilterInit::canidmr6, CANIDMR7, canBusFilterInit::canidmr7, canTestInitMode(), canBusFilterInit::idam, IO_PORTS_8, and MSG_WAR. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canInitMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 392 of file canOpenDriver.c. +
+References CANCTL0, canTestInitMode(), and IO_PORTS_8. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canInitModeQ | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 401 of file canOpenDriver.c. +
+References CANCTL0, canTestInitMode(), and IO_PORTS_8. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canMsgTransmit | +( | +UNS16 | +adrCAN, | +|
+ | + | Message | +msg | + |
+ | ) | ++ |
+ +
+Definition at line 410 of file canOpenDriver.c. +
+References CANTBSEL, CANTFLG, CANTRSDTA, CANTRSID, CANTRSLEN, CANTRSPRI, Message::cob_id, Message::data, IO_PORTS_8, Message::len, MSG_WAR, Message::rtr, UNS8, and SHORT_CAN::w. +
+Referenced by canSend(). +
UNS8 canSend | +( | +UNS8 | +notused, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 505 of file canOpenDriver.c. +
+References canMsgTransmit(), and CANOPEN_LINE_NUMBER_USED. +
+Referenced by canSend(), LoadCanDriver(), masterSendNMTnodeguard(), masterSendNMTstateChange(), proceedNODE_GUARD(), ProducerHearbeatAlarm(), sendPDO(), sendSDO(), sendSYNC(), and slaveSendBootUp(). +
+Here is the call graph for this function:
char canSetInterrupt | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 445 of file canOpenDriver.c. +
+References CANRIER, CANTIER, and IO_PORTS_8. +
+Referenced by canChangeFilter(), and canInit(). +
char canSleepMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 452 of file canOpenDriver.c. +
+References CANCTL0, canTestSleepMode(), and IO_PORTS_8. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canSleepModeQ | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 466 of file canOpenDriver.c. +
+References CANCTL0, canTestInitMode(), canTestSleepMode(), IO_PORTS_8, and MSG_WAR. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canSleepWupMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 480 of file canOpenDriver.c. +
+References CANCTL0, canTestInitMode(), canTestSleepMode(), IO_PORTS_8, and MSG_WAR. +
+Here is the call graph for this function:
char canTestInitMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 493 of file canOpenDriver.c. +
+References CANCTL1, and IO_PORTS_8. +
+Referenced by canAddIdToFilter(), canChangeFilter(), canInit(), canInit1Filter(), canInitClock(), canInitFilter(), canInitMode(), canInitModeQ(), canSleepModeQ(), and canSleepWupMode(). +
char canTestSleepMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 499 of file canOpenDriver.c. +
+References CANCTL1, and IO_PORTS_8. +
+Referenced by canSleepMode(), canSleepModeQ(), and canSleepWupMode(). +
UNS8 f_can_receive | +( | +UNS8 | +notused, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 513 of file canOpenDriver.c. +
+References CAN0, CAN1, CAN2, CAN3, CAN4, CANOPEN_LINE_NUMBER_USED, Message::cob_id, Message::data, Message::len, MAX_STACK_MSG_RCV, t_pointerStack::r, Message::rtr, UNS8, and SHORT_CAN::w. +
+Referenced by main(). +
TIMEVAL getElapsedTime | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 66 of file canOpenDriver.c. +
+Referenced by StartTimerLoop(), and TimeDispatch(). +
char* hex_convert | +( | +char * | +buf, | +|
+ | + | unsigned long | +value, | +|
+ | + | char | +lastCar | + |
+ | ) | ++ |
+Convert an integer to a string in hexadecimal format If you do not wants to use a lastCar, put lastCar = '' (end of string) ex : value = 0XABCDEF and lastCar = '
+' buf[0] = '0' buf[1] = 'X' buf[2] = 'A' .... buf[7] = 'F' buf[8] = '
+' buf[9] = ''
+
+Definition at line 135 of file canOpenDriver.c. +
+Referenced by printSCI_nbr(). +
void initHCS12 | +( | +void | ++ | ) | ++ |
+Put here all the code to init the HCS12. +
+ +
+Definition at line 199 of file canOpenDriver.c. +
+References initPLL(), and MSG_WAR. +
+Referenced by initSensor(). +
+Here is the call graph for this function:
void initPLL | +( | +void | ++ | ) | ++ |
+to start using the PLL. Bus clock becomes 24 MHz if the quartz on the board is at 16 MHz +
+Definition at line 188 of file canOpenDriver.c. +
+References CLKSEL, CRGFLG, IO_PORTS_8, PLLCTL, REFDV, and SYNR. +
+Referenced by initHCS12(). +
void initSCI_0 | +( | +void | ++ | ) | ++ |
+Initialisation of the serial port 0. +
+ +
+Definition at line 115 of file canOpenDriver.c. +
+References BUS_CLOCK, IO_PORTS_16, IO_PORTS_8, SCI0, SCIBDH, SCICR1, SCICR2, and SERIAL_SCI0_BAUD_RATE. +
void initSCI_1 | +( | +void | ++ | ) | ++ |
+Initialisation of the serial port 1. +
+ +
+Definition at line 124 of file canOpenDriver.c. +
+References BUS_CLOCK, IO_PORTS_16, IO_PORTS_8, SCI1, SCIBDH, SCICR1, SCICR2, and SERIAL_SCI1_BAUD_RATE. +
void initTimer | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 79 of file canOpenDriver.c. +
+Referenced by initSensor(), and StartTimerLoop(). +
void printSCI_nbr | +( | +char | +sci, | +|
+ | + | unsigned long | +nbr, | +|
+ | + | char | +lastCar | + |
+ | ) | ++ |
+Print the number in hexadecimal to the serial port sci (sci takes the values SCI0 or SCI1) +
+Definition at line 179 of file canOpenDriver.c. +
+References hex_convert(), and printSCI_str(). +
+Here is the call graph for this function:
void printSCI_str | +( | +char | +sci, | +|
+ | + | const char * | +str | + |
+ | ) | ++ |
+Print the string to the serial port sci (sci takes the values SCI0 or SCI1) +
+Definition at line 162 of file canOpenDriver.c. +
+References IO_PORTS_8, SCIDRL, and SCISR1. +
+Referenced by printSCI_nbr(). +
void resetTimer | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 73 of file canOpenDriver.c. +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 +00024 #ifndef __CANOPENDRIVER__ +00025 #define __CANOPENDRIVER__ +00026 +00027 +00028 +00029 // --------- to be called by user app --------- +00030 +00031 void initTimer(void); +00032 void resetTimer(void); +00033 void TimerLoop(void); +00034 +00041 UNS8 f_can_receive(UNS8 notused, Message *m); +00042 +00043 #endif +
+Go to the source code of this file.
Functions | |
void | initTimer (void) |
void | resetTimer (void) |
void | TimerLoop (void) |
UNS8 | f_can_receive (UNS8 notused, Message *m) |
UNS8 f_can_receive | +( | +UNS8 | +notused, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+Returns 0 if no message received, 0xFF if the receiving stack is not empty. May be call in polling. You can also call canDispatch(...) in void __attribute__((interrupt)) can0HdlRcv (void) (see include/hcs12/canOpenDriver.c) +
void initTimer | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 79 of file canOpenDriver.c. +
+References IO_PORTS_8, last_sig, lock(), TCTL1, TIE, timer, timer_notify(), TIOS, TSCR1, TSCR2, and unlock(). +
+Here is the call graph for this function:
void resetTimer | +( | +void | ++ | ) | ++ |
+ +
+Definition at line 73 of file canOpenDriver.c. +
void TimerLoop | +( | +void | ++ | ) | ++ |
+ +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #ifndef __can_h__ +00024 #define __can_h__ +00025 +00026 #include "applicfg.h" +00028 /* +00029 union SHORT_CAN { +00030 struct { UNS8 b0,b1; } b; +00031 UNS32 w; +00032 }; +00033 */ +00034 +00035 typedef struct { +00036 UNS32 w; /* 32 bits */ +00037 } SHORT_CAN; +00038 +00039 +00041 typedef struct { +00042 SHORT_CAN cob_id; /* l'ID du mesg */ +00043 UNS8 rtr; /* remote transmission request. 0 if not rtr, +00044 1 for a rtr message */ +00045 UNS8 len; /* message length (0 to 8) */ +00046 UNS8 data[8]; /* data */ +00047 } Message; +00048 +00049 +00050 typedef UNS8 (*canSend_t)(Message *); +00051 +00052 #endif /* __can_h__ */ +
#include "applicfg.h"
+Include dependency graph for can.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Data Structures | |
struct | SHORT_CAN |
struct | Message |
Typedefs | |
typedef UNS8(*) | canSend_t (Message *) |
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #ifndef __can_driver_h__ +00024 #define __can_driver_h__ +00025 +00026 struct struct_s_BOARD; +00027 +00028 typedef struct struct_s_BOARD s_BOARD; +00029 +00030 #include "applicfg.h" +00031 #include "can.h" +00032 +00033 struct struct_s_BOARD { +00034 char * busname; +00035 char * baudrate; +00036 }; +00037 +00038 #ifndef DLL_CALL +00039 #define DLL_CALL(funcname) funcname##_driver +00040 #endif +00041 +00042 #ifndef FCT_PTR_INIT +00043 #define FCT_PTR_INIT +00044 #endif +00045 +00046 +00047 UNS8 DLL_CALL(canReceive)(CAN_HANDLE, Message *)FCT_PTR_INIT; +00048 UNS8 DLL_CALL(canSend)(CAN_HANDLE, Message *)FCT_PTR_INIT; +00049 CAN_HANDLE DLL_CALL(canOpen)(s_BOARD *)FCT_PTR_INIT; +00050 int DLL_CALL(canClose)(CAN_HANDLE)FCT_PTR_INIT; +00051 +00052 #endif +
#include "applicfg.h"
#include "can.h"
+Include dependency graph for can_driver.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Data Structures | |
struct | struct_s_BOARD |
Defines | |
#define | DLL_CALL(funcname) funcname##_driver |
Typedefs | |
typedef struct_s_BOARD | s_BOARD |
Functions | |
UNS8 DLL_CALL() | canReceive (CAN_HANDLE, Message *) FCT_PTR_INIT |
UNS8 DLL_CALL() | canSend (CAN_HANDLE, Message *) FCT_PTR_INIT |
CAN_HANDLE DLL_CALL() | canOpen (s_BOARD *) FCT_PTR_INIT |
int DLL_CALL() | canClose (CAN_HANDLE) FCT_PTR_INIT |
#define DLL_CALL | +( | +funcname | ++ | ) | +funcname##_driver | +
+ +
+Definition at line 39 of file can_driver.h. +
+
typedef struct struct_s_BOARD s_BOARD | +
+ +
+Definition at line 28 of file can_driver.h. +
+
int DLL_CALL() canClose | +( | +CAN_HANDLE | ++ | ) | ++ |
+ +
CAN_HANDLE DLL_CALL() canOpen | +( | +s_BOARD * | ++ | ) | ++ |
+ +
UNS8 DLL_CALL() canReceive | +( | +CAN_HANDLE | +, | +|
+ | + | Message * | ++ | |
+ | ) | ++ |
+ +
+Definition at line 124 of file drivers_win32.cpp. +
+References driver_data::inst, driver_procs::m_canReceive, and s_driver_procs. +
+Referenced by canReceiveLoop(), and LoadCanDriver(). +
UNS8 DLL_CALL() canSend | +( | +CAN_HANDLE | +, | +|
+ | + | Message * | ++ | |
+ | ) | ++ |
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #include <stdio.h> +00024 #include <string.h> +00025 #include <errno.h> +00026 #include <fcntl.h> +00027 +00028 #include "canmsg.h" +00029 #include "lincan.h" +00030 +00031 #include "can_driver.h" +00032 +00033 /*********functions which permit to communicate with the board****************/ +00034 UNS8 canReceive_driver(CAN_HANDLE fd0, Message *m) +00035 { +00036 int res; +00037 struct canmsg_t canmsg; +00038 +00039 canmsg.flags = 0; /* Ensure standard receive, not required for LinCAN>=0.3.1 */ +00040 +00041 do{ +00042 res = read(fd0,&canmsg,sizeof(canmsg_t)); +00043 if((res<0)&&(errno == -EAGAIN)) res = 0; +00044 }while(res==0); +00045 +00046 if(res != sizeof(canmsg_t)) // No new message +00047 return 1; +00048 +00049 if(canmsg.flags&MSG_EXT){ +00050 /* There is no mark for extended messages in CanFestival */; +00051 } +00052 +00053 m->cob_id.w = canmsg.id; +00054 m->len = canmsg.length; +00055 if(canmsg.flags&MSG_RTR){ +00056 m->rtr = 1; +00057 }else{ +00058 m->rtr = 0; +00059 memcpy(m->data,canmsg.data,8); +00060 } +00061 +00062 return 0; +00063 } +00064 +00065 /***************************************************************************/ +00066 UNS8 canSend_driver(CAN_HANDLE fd0, Message *m) +00067 { +00068 int res; +00069 struct canmsg_t canmsg; +00070 +00071 +00072 canmsg.flags = 0; +00073 canmsg.id = m->cob_id.w; +00074 canmsg.length = m->len; +00075 if(m->rtr){ +00076 canmsg.flags |= MSG_RTR; +00077 }else{ +00078 memcpy(canmsg.data,m->data,8); +00079 } +00080 +00081 if(canmsg.id >= 0x800){ +00082 canmsg.flags |= MSG_EXT; +00083 } +00084 +00085 res = write(fd0,&canmsg,sizeof(canmsg_t)); +00086 if(res!=sizeof(canmsg_t)) +00087 return 1; +00088 +00089 return 0; +00090 } +00091 +00092 /***************************************************************************/ +00093 static const char lnx_can_dev_prefix[] = "/dev/can"; +00094 +00095 CAN_HANDLE canOpen_driver(s_BOARD *board) +00096 { +00097 int name_len = strlen(board->busname); +00098 int prefix_len = strlen(lnx_can_dev_prefix); +00099 char dev_name[prefix_len+name_len+1]; +00100 int o_flags = 0; +00101 CAN_HANDLE fd0; +00102 +00103 fd0=malloc(sizeof(*fd0)); +00104 if(fd0==NULL) +00105 return NULL; +00106 +00107 /*o_flags = O_NONBLOCK;*/ +00108 +00109 memcpy(dev_name,lnx_can_dev_prefix,prefix_len); +00110 memcpy(dev_name+prefix_len,board->busname,name_len); +00111 dev_name[prefix_len+name_len] = 0; +00112 +00113 fd0 = open(dev_name, O_RDWR|o_flags); +00114 if(fd0 < 0){ +00115 fprintf(stderr,"!!! Board %s is unknown. See can_lincan.c\n", board->busname); +00116 goto error_ret; +00117 } +00118 +00119 return fd0; +00120 +00121 error_ret: +00122 free(fd0); +00123 return NULL; +00124 } +00125 +00126 /***************************************************************************/ +00127 int canClose_driver(CAN_HANDLE fd0) +00128 { +00129 if(!fd0) +00130 return 0; +00131 close(fd0); +00132 return 0; +00133 } +
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include "canmsg.h"
#include "lincan.h"
#include "can_driver.h"
+Include dependency graph for can_lincan.c:
+Go to the source code of this file.
Functions | |
UNS8 | canReceive_driver (CAN_HANDLE fd0, Message *m) |
UNS8 | canSend_driver (CAN_HANDLE fd0, Message *m) |
CAN_HANDLE | canOpen_driver (s_BOARD *board) |
int | canClose_driver (CAN_HANDLE fd0) |
int canClose_driver | +( | +CAN_HANDLE | +fd0 | +) | ++ |
+ +
+Definition at line 127 of file can_lincan.c. +
CAN_HANDLE canOpen_driver | +( | +s_BOARD * | +board | +) | ++ |
UNS8 canReceive_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 34 of file can_lincan.c. +
+References Message::cob_id, canmsg_t::data, Message::data, canmsg_t::flags, canmsg_t::id, Message::len, canmsg_t::length, MSG_EXT, MSG_RTR, Message::rtr, and SHORT_CAN::w. +
UNS8 canSend_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 66 of file can_lincan.c. +
+References Message::cob_id, Message::data, canmsg_t::data, canmsg_t::flags, canmsg_t::id, Message::len, canmsg_t::length, MSG_EXT, MSG_RTR, Message::rtr, and SHORT_CAN::w. +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #include <stdio.h> +00024 #include <string.h> +00025 #include <errno.h> +00026 #include <fcntl.h> +00027 +00028 /* driver pcan pci for Peak board */ +00029 //#include "libpcan.h" +00030 //#include "pcan.h" +00031 +00032 #include "libpcan.h" // for CAN_HANDLE +00033 +00034 #include "can_driver.h" +00035 +00036 // Define for rtr CAN message +00037 #define CAN_INIT_TYPE_ST_RTR MSGTYPE_STANDARD | MSGTYPE_RTR +00038 +00039 /*********functions which permit to communicate with the board****************/ +00040 UNS8 canReceive_driver(CAN_HANDLE fd0, Message *m) +00041 { +00042 UNS8 data; +00043 TPCANMsg peakMsg; +00044 if ((errno = CAN_Read(fd0, & peakMsg))) { // Blocks until no new message or error. +00045 if(errno != -EIDRM && errno != -EPERM) // error is not "Can Port closed while reading" +00046 { +00047 perror("canReceive_driver (Peak_Linux) : error of reading.\n"); +00048 } +00049 return 1; +00050 } +00051 m->cob_id.w = peakMsg.ID; +00052 if (peakMsg.MSGTYPE == CAN_INIT_TYPE_ST) /* bits of MSGTYPE_*/ +00053 m->rtr = 0; +00054 else +00055 m->rtr = 1; +00056 m->len = peakMsg.LEN; /* count of data bytes (0..8) */ +00057 for(data = 0 ; data < peakMsg.LEN ; data++) +00058 m->data[data] = peakMsg.DATA[data]; /* data bytes, up to 8 */ +00059 +00060 return 0; +00061 } +00062 +00063 /***************************************************************************/ +00064 UNS8 canSend_driver(CAN_HANDLE fd0, Message *m) +00065 { +00066 UNS8 data; +00067 TPCANMsg peakMsg; +00068 peakMsg.ID=m -> cob_id.w; /* 11/29 bit code */ +00069 if(m->rtr == 0) +00070 peakMsg.MSGTYPE = CAN_INIT_TYPE_ST; /* bits of MSGTYPE_*/ +00071 else { +00072 peakMsg.MSGTYPE = CAN_INIT_TYPE_ST_RTR; /* bits of MSGTYPE_*/ +00073 } +00074 peakMsg.LEN = m->len; +00075 /* count of data bytes (0..8) */ +00076 for(data = 0 ; data < m->len; data ++) +00077 peakMsg.DATA[data] = m->data[data]; /* data bytes, up to 8 */ +00078 +00079 if((errno = CAN_Write(fd0, & peakMsg))) { +00080 perror("canSend_driver (Peak_Linux) : error of writing.\n"); +00081 return 1; +00082 } +00083 return 0; +00084 +00085 } +00086 +00087 +00088 /***************************************************************************/ +00089 int TranslateBaudeRate(char* optarg){ +00090 if(!strcmp( optarg, "1M")) return CAN_BAUD_1M; +00091 if(!strcmp( optarg, "500K")) return CAN_BAUD_500K; +00092 if(!strcmp( optarg, "250K")) return CAN_BAUD_250K; +00093 if(!strcmp( optarg, "125K")) return CAN_BAUD_125K; +00094 if(!strcmp( optarg, "100K")) return CAN_BAUD_100K; +00095 if(!strcmp( optarg, "50K")) return CAN_BAUD_50K; +00096 if(!strcmp( optarg, "20K")) return CAN_BAUD_20K; +00097 if(!strcmp( optarg, "10K")) return CAN_BAUD_10K; +00098 if(!strcmp( optarg, "5K")) return CAN_BAUD_5K; +00099 if(!strcmp( optarg, "none")) return 0; +00100 return 0x0000; +00101 } +00102 +00103 /***************************************************************************/ +00104 CAN_HANDLE canOpen_driver(s_BOARD *board) +00105 { +00106 HANDLE fd0 = NULL; +00107 char busname[64]; +00108 char* pEnd; +00109 int i; +00110 int baudrate; +00111 +00112 if(strtol(board->busname, &pEnd,0) >= 0) +00113 { +00114 sprintf(busname,"/dev/pcan%s",board->busname); +00115 fd0 = LINUX_CAN_Open(busname, O_RDWR); +00116 } +00117 +00118 if(fd0 && (baudrate = TranslateBaudeRate(board->baudrate))) +00119 { +00120 CAN_Init(fd0, baudrate, CAN_INIT_TYPE_ST); +00121 }else{ +00122 fprintf(stderr, "canOpen_driver (Peak_Linux) : error opening %s\n", busname); +00123 } +00124 +00125 return (CAN_HANDLE)fd0; +00126 } +00127 +00128 /***************************************************************************/ +00129 int canClose_driver(CAN_HANDLE fd0) +00130 { +00131 CAN_Close(fd0); +00132 return 0; +00133 } +
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include "libpcan.h"
#include "can_driver.h"
+Include dependency graph for can_peak_linux.c:
+Go to the source code of this file.
Defines | |
#define | CAN_INIT_TYPE_ST_RTR MSGTYPE_STANDARD | MSGTYPE_RTR |
Functions | |
UNS8 | canReceive_driver (CAN_HANDLE fd0, Message *m) |
UNS8 | canSend_driver (CAN_HANDLE fd0, Message *m) |
int | TranslateBaudeRate (char *optarg) |
CAN_HANDLE | canOpen_driver (s_BOARD *board) |
int | canClose_driver (CAN_HANDLE fd0) |
#define CAN_INIT_TYPE_ST_RTR MSGTYPE_STANDARD | MSGTYPE_RTR | +
+
int canClose_driver | +( | +CAN_HANDLE | +fd0 | +) | ++ |
+ +
+Definition at line 129 of file can_peak_linux.c. +
CAN_HANDLE canOpen_driver | +( | +s_BOARD * | +board | +) | ++ |
+ +
+Definition at line 104 of file can_peak_linux.c. +
+References struct_s_BOARD::baudrate, struct_s_BOARD::busname, and TranslateBaudeRate(). +
+Here is the call graph for this function:
UNS8 canReceive_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 40 of file can_peak_linux.c. +
+References Message::cob_id, Message::data, Message::len, Message::rtr, UNS8, and SHORT_CAN::w. +
UNS8 canSend_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 64 of file can_peak_linux.c. +
+References CAN_INIT_TYPE_ST_RTR, Message::data, Message::len, Message::rtr, and UNS8. +
int TranslateBaudeRate | +( | +char * | +optarg | +) | ++ |
+ +
+Definition at line 89 of file can_peak_linux.c. +
+Referenced by canInit(), and canOpen_driver(). +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #if defined(WIN32) && !defined(__CYGWIN__) +00024 #define usleep(micro) Sleep(micro%1000 ? (micro/1000) + 1 : (micro/1000)) +00025 #else +00026 #include <stdio.h> +00027 #include <string.h> +00028 #include <errno.h> +00029 #include <fcntl.h> +00030 #endif +00031 +00032 #include "cancfg.h" +00033 #include "can_driver.h" +00034 +00035 #ifndef extra_PCAN_init_params +00036 #define extra_PCAN_init_params +00037 #else +00038 #define extra_PCAN_init_params\ +00039 ,getenv("PCANHwType") ? strtol(getenv("PCANHwType"),NULL,0):0\ +00040 ,getenv("PCANIO_Port") ? strtol(getenv("PCANIO_Port"),NULL,0):0\ +00041 ,getenv("PCANInterupt") ? strtol(getenv("PCANInterupt"),NULL,0):0 +00042 #endif +00043 +00044 static s_BOARD *first_board = NULL; +00045 #ifdef PCAN2_HEADER_ +00046 static s_BOARD *second_board = NULL; +00047 #endif +00048 +00049 //pthread_mutex_t PeakCan_mutex = PTHREAD_MUTEX_INITIALIZER; +00050 +00051 // Define for rtr CAN message +00052 #define CAN_INIT_TYPE_ST_RTR MSGTYPE_STANDARD | MSGTYPE_RTR +00053 +00054 /***************************************************************************/ +00055 int TranslateBaudeRate(char* optarg){ +00056 if(!strcmp( optarg, "1M")) return CAN_BAUD_1M; +00057 if(!strcmp( optarg, "500K")) return CAN_BAUD_500K; +00058 if(!strcmp( optarg, "250K")) return CAN_BAUD_250K; +00059 if(!strcmp( optarg, "125K")) return CAN_BAUD_125K; +00060 if(!strcmp( optarg, "100K")) return CAN_BAUD_100K; +00061 if(!strcmp( optarg, "50K")) return CAN_BAUD_50K; +00062 if(!strcmp( optarg, "20K")) return CAN_BAUD_20K; +00063 if(!strcmp( optarg, "10K")) return CAN_BAUD_10K; +00064 if(!strcmp( optarg, "5K")) return CAN_BAUD_5K; +00065 if(!strcmp( optarg, "none")) return 0; +00066 return 0x0000; +00067 } +00068 +00069 void +00070 canInit (s_BOARD *board) +00071 { +00072 int baudrate; +00073 +00074 #ifdef PCAN2_HEADER_ +00075 // if not the first handler +00076 if(second_board == (s_BOARD *)board) +00077 if(baudrate = TranslateBaudeRate(board->baudrate)) +00078 CAN2_Init (baudrate, +00079 CAN_INIT_TYPE_ST extra_PCAN_init_params); +00080 #endif +00081 if(first_board == (s_BOARD *)board) +00082 if(baudrate = TranslateBaudeRate(board->baudrate)) +00083 CAN_Init (baudrate, +00084 CAN_INIT_TYPE_ST extra_PCAN_init_params); +00085 } +00086 +00087 /*********functions which permit to communicate with the board****************/ +00088 UNS8 +00089 canReceive_driver (CAN_HANDLE fd0, Message * m) +00090 { +00091 UNS8 data; +00092 TPCANMsg peakMsg; +00093 +00094 DWORD Res; +00095 +00096 do{ +00097 // We read the queue looking for messages. +00098 // +00099 //pthread_mutex_lock (&PeakCan_mutex); +00100 #ifdef PCAN2_HEADER_ +00101 // if not the first handler +00102 if(second_board == (s_BOARD *)fd0) +00103 Res = CAN2_Read (&peakMsg); +00104 else +00105 #endif +00106 if(first_board == (s_BOARD *)fd0) +00107 Res = CAN_Read (&peakMsg); +00108 else +00109 Res = CAN_ERR_BUSOFF; +00110 +00111 // A message was received +00112 // We process the message(s) +00113 // +00114 if (Res == CAN_ERR_OK) +00115 { +00116 // if something different that 11bit or rtr... problem +00117 if (peakMsg.MSGTYPE & ~(MSGTYPE_STANDARD | MSGTYPE_RTR)) +00118 { +00119 if (peakMsg.MSGTYPE == CAN_ERR_BUSOFF) +00120 { +00121 printf ("!!! Peak board read : re-init\n"); +00122 canInit((s_BOARD*) fd0); +00123 usleep (10000); +00124 } +00125 +00126 // If status, return status if 29bit, return overrun +00127 //pthread_mutex_unlock (&PeakCan_mutex); +00128 return peakMsg.MSGTYPE == +00129 MSGTYPE_STATUS ? peakMsg.DATA[2] : CAN_ERR_OVERRUN; +00130 } +00131 m->cob_id.w = peakMsg.ID; +00132 if (peakMsg.MSGTYPE == CAN_INIT_TYPE_ST) /* bits of MSGTYPE_ */ +00133 m->rtr = 0; +00134 else +00135 m->rtr = 1; +00136 m->len = peakMsg.LEN; /* count of data bytes (0..8) */ +00137 for (data = 0; data < peakMsg.LEN; data++) +00138 m->data[data] = peakMsg.DATA[data]; /* data bytes, up to 8 */ +00139 +00140 }else{ +00141 //pthread_mutex_unlock (&PeakCan_mutex); +00142 //if (Res != CAN_ERR_OK) +00143 //{ +00144 if (! +00145 (Res & CAN_ERR_QRCVEMPTY || Res & CAN_ERR_BUSLIGHT +00146 || Res & CAN_ERR_BUSHEAVY)) +00147 { +00148 printf ("canReceive returned error (%d)\n", Res); +00149 return 1; +00150 } +00151 usleep (1000); +00152 } +00153 }while(Res != CAN_ERR_OK); +00154 return 0; +00155 } +00156 +00157 /***************************************************************************/ +00158 UNS8 +00159 canSend_driver (CAN_HANDLE fd0, Message * m) +00160 { +00161 UNS8 data; +00162 TPCANMsg peakMsg; +00163 peakMsg.ID = m->cob_id.w; /* 11/29 bit code */ +00164 if (m->rtr == 0) +00165 peakMsg.MSGTYPE = CAN_INIT_TYPE_ST; /* bits of MSGTYPE_ */ +00166 else +00167 { +00168 peakMsg.MSGTYPE = CAN_INIT_TYPE_ST_RTR; /* bits of MSGTYPE_ */ +00169 } +00170 peakMsg.LEN = m->len; +00171 /* count of data bytes (0..8) */ +00172 for (data = 0; data < m->len; data++) +00173 peakMsg.DATA[data] = m->data[data]; /* data bytes, up to 8 */ +00174 do +00175 { +00176 #ifdef PCAN2_HEADER_ +00177 // if not the first handler +00178 if(second_board == (s_BOARD *)fd0) +00179 errno = CAN2_Write (&peakMsg); +00180 else +00181 #endif +00182 if(first_board == (s_BOARD *)fd0) +00183 errno = CAN_Write (&peakMsg); +00184 else +00185 goto fail; +00186 if (errno) +00187 { +00188 if (errno == CAN_ERR_BUSOFF) +00189 { +00190 printf ("!!! Peak board write : re-init\n"); +00191 canInit((s_BOARD*)fd0); +00192 usleep (10000); +00193 } +00194 usleep (1000); +00195 } +00196 } +00197 while (errno != CAN_ERR_OK); +00198 return 0; +00199 fail: +00200 return 1; +00201 } +00202 +00203 /***************************************************************************/ +00204 CAN_HANDLE +00205 canOpen_driver (s_BOARD * board) +00206 { +00207 #ifdef PCAN2_HEADER_ +00208 if(first_board != NULL && second_board != NULL) +00209 #else +00210 if(first_board != NULL) +00211 #endif +00212 { +00213 fprintf (stderr, "Open failed.\n"); +00214 fprintf (stderr, +00215 "can_peak_win32.c: no more can port available with this pcan library\n"); +00216 fprintf (stderr, +00217 "can_peak_win32.c: please link another executable with another pcan lib\n"); +00218 return NULL; +00219 } +00220 +00221 #ifdef PCAN2_HEADER_ +00222 if(first_board == NULL) +00223 first_board = board; +00224 else +00225 second_board = board; +00226 #else +00227 first_board = board; +00228 #endif +00229 +00230 canInit(board); +00231 +00232 return (CAN_HANDLE)board; +00233 } +00234 +00235 /***************************************************************************/ +00236 int +00237 canClose_driver (CAN_HANDLE fd0) +00238 { +00239 #ifdef PCAN2_HEADER_ +00240 // if not the first handler +00241 if(second_board == (s_BOARD *)fd0) +00242 { +00243 CAN2_Close (); +00244 second_board = (s_BOARD *)NULL; +00245 }else +00246 #endif +00247 if(first_board == (s_BOARD *)fd0) +00248 { +00249 CAN_Close (); +00250 first_board = (s_BOARD *)NULL; +00251 } +00252 return 0; +00253 } +
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include "cancfg.h"
#include "can_driver.h"
+Include dependency graph for can_peak_win32.c:
+Go to the source code of this file.
Defines | |
#define | extra_PCAN_init_params |
#define | CAN_INIT_TYPE_ST_RTR MSGTYPE_STANDARD | MSGTYPE_RTR |
Functions | |
int | TranslateBaudeRate (char *optarg) |
void | canInit (s_BOARD *board) |
UNS8 | canReceive_driver (CAN_HANDLE fd0, Message *m) |
UNS8 | canSend_driver (CAN_HANDLE fd0, Message *m) |
CAN_HANDLE | canOpen_driver (s_BOARD *board) |
int | canClose_driver (CAN_HANDLE fd0) |
#define CAN_INIT_TYPE_ST_RTR MSGTYPE_STANDARD | MSGTYPE_RTR | +
+ +
+Definition at line 52 of file can_peak_win32.c. +
#define extra_PCAN_init_params | +
+
int canClose_driver | +( | +CAN_HANDLE | +fd0 | +) | ++ |
+ +
+Definition at line 237 of file can_peak_win32.c. +
void canInit | +( | +s_BOARD * | +board | +) | ++ |
+ +
+Definition at line 70 of file can_peak_win32.c. +
+References struct_s_BOARD::baudrate, extra_PCAN_init_params, and TranslateBaudeRate(). +
+Referenced by canOpen_driver(), canReceive_driver(), canSend_driver(), and initSensor(). +
+Here is the call graph for this function:
CAN_HANDLE canOpen_driver | +( | +s_BOARD * | +board | +) | ++ |
+ +
+Definition at line 205 of file can_peak_win32.c. +
+References canInit(). +
+Here is the call graph for this function:
UNS8 canReceive_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 89 of file can_peak_win32.c. +
+References canInit(), Message::cob_id, Message::data, Message::len, Message::rtr, UNS8, and SHORT_CAN::w. +
+Here is the call graph for this function:
UNS8 canSend_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 159 of file can_peak_win32.c. +
+References CAN_INIT_TYPE_ST_RTR, canInit(), Message::cob_id, Message::data, Message::len, Message::rtr, UNS8, and SHORT_CAN::w. +
+Here is the call graph for this function:
int TranslateBaudeRate | +( | +char * | +optarg | +) | ++ |
+ +
+Definition at line 55 of file can_peak_win32.c. +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #include <stdio.h> +00024 #include <string.h> +00025 #include <stdlib.h> +00026 #include <stddef.h> /* for NULL */ +00027 #include <errno.h> +00028 +00029 #include "config.h" +00030 +00031 #ifdef RTCAN_SOCKET +00032 #include "rtdm/rtcan.h" +00033 #define CAN_IFNAME "rtcan%s" +00034 #define CAN_SOCKET rt_dev_socket +00035 #define CAN_CLOSE rt_dev_close +00036 #define CAN_RECV rt_dev_recv +00037 #define CAN_SEND rt_dev_send +00038 #define CAN_BIND rt_dev_bind +00039 #define CAN_IOCTL rt_dev_ioctl +00040 #define CAN_ERRNO(err) (-err) +00041 #else +00042 #include <sys/socket.h> +00043 #include <sys/ioctl.h> +00044 #include "linux/can.h" +00045 #include "linux/can/raw.h" +00046 #include "net/if.h" +00047 #define PF_CAN 29 +00048 #define AF_CAN PF_CAN +00049 //#include "af_can.h" +00050 #define CAN_IFNAME "can%s" +00051 #define CAN_SOCKET socket +00052 #define CAN_CLOSE close +00053 #define CAN_RECV recv +00054 #define CAN_SEND send +00055 #define CAN_BIND bind +00056 #define CAN_IOCTL ioctl +00057 #define CAN_ERRNO(err) errno +00058 #endif +00059 +00060 #include "can_driver.h" +00061 +00062 /*********functions which permit to communicate with the board****************/ +00063 UNS8 +00064 canReceive_driver (CAN_HANDLE fd0, Message * m) +00065 { +00066 int res; +00067 struct can_frame frame; +00068 +00069 res = CAN_RECV (*(int *) fd0, &frame, sizeof (frame), 0); +00070 if (res < 0) +00071 { +00072 fprintf (stderr, "Recv failed: %s\n", strerror (CAN_ERRNO (res))); +00073 return 1; +00074 } +00075 +00076 m->cob_id.w = frame.can_id & CAN_EFF_MASK; +00077 m->len = frame.can_dlc; +00078 if (frame.can_id & CAN_RTR_FLAG) +00079 m->rtr = 1; +00080 else +00081 m->rtr = 0; +00082 memcpy (m->data, frame.data, 8); +00083 +00084 return 0; +00085 } +00086 +00087 +00088 /***************************************************************************/ +00089 UNS8 +00090 canSend_driver (CAN_HANDLE fd0, Message * m) +00091 { +00092 int res; +00093 struct can_frame frame; +00094 +00095 frame.can_id = m->cob_id.w; +00096 if (frame.can_id >= 0x800) +00097 frame.can_id |= CAN_EFF_FLAG; +00098 frame.can_dlc = m->len; +00099 if (m->rtr) +00100 frame.can_id |= CAN_RTR_FLAG; +00101 else +00102 memcpy (frame.data, m->data, 8); +00103 +00104 res = CAN_SEND (*(int *) fd0, &frame, sizeof (frame), 0); +00105 if (res < 0) +00106 { +00107 fprintf (stderr, "Send failed: %s\n", strerror (CAN_ERRNO (res))); +00108 return 1; +00109 } +00110 +00111 return 0; +00112 } +00113 +00114 /***************************************************************************/ +00115 #ifdef RTCAN_SOCKET +00116 int +00117 TranslateBaudRate (const char *optarg) +00118 { +00119 int baudrate; +00120 int val, len; +00121 char *pos = NULL; +00122 +00123 len = strlen (optarg); +00124 if (!len) +00125 return 0; +00126 +00127 switch ((int) optarg[len - 1]) +00128 { +00129 case 'M': +00130 baudrate = 1000000; +00131 break; +00132 case 'K': +00133 baudrate = 1000; +00134 break; +00135 default: +00136 baudrate = 1; +00137 break; +00138 } +00139 if ((sscanf (optarg, "%i", &val)) == 1) +00140 baudrate *= val; +00141 else +00142 baudrate = 0;; +00143 +00144 return baudrate; +00145 } +00146 #endif +00147 +00148 /***************************************************************************/ +00149 CAN_HANDLE +00150 canOpen_driver (s_BOARD * board) +00151 { +00152 struct ifreq ifr; +00153 struct sockaddr_can addr; +00154 int err; +00155 CAN_HANDLE fd0 = malloc (sizeof (int)); +00156 #ifdef RTCAN_SOCKET +00157 can_baudrate_t *baudrate; +00158 can_mode_t *mode; +00159 #endif +00160 +00161 *(int *) fd0 = CAN_SOCKET (PF_CAN, SOCK_RAW, CAN_RAW); +00162 if (*(int *) fd0 < 0) +00163 { +00164 fprintf (stderr, "Socket creation failed: %s\n", +00165 strerror (CAN_ERRNO (*(int *) fd0))); +00166 goto error_ret; +00167 } +00168 +00169 if (*board->busname >= '0' && *board->busname <= '9') +00170 snprintf (ifr.ifr_name, IFNAMSIZ, CAN_IFNAME, board->busname); +00171 else +00172 strncpy (ifr.ifr_name, board->busname, IFNAMSIZ); +00173 err = CAN_IOCTL (*(int *) fd0, SIOCGIFINDEX, &ifr); +00174 if (err) +00175 { +00176 fprintf (stderr, "Getting IF index for %s failed: %s\n", +00177 ifr.ifr_name, strerror (CAN_ERRNO (err))); +00178 goto error_close; +00179 } +00180 +00181 addr.can_family = AF_CAN; +00182 addr.can_ifindex = ifr.ifr_ifindex; +00183 err = CAN_BIND (*(int *) fd0, (struct sockaddr *) &addr, sizeof (addr)); +00184 if (err) +00185 { +00186 fprintf (stderr, "Binding failed: %s\n", strerror (CAN_ERRNO (err))); +00187 goto error_close; +00188 } +00189 +00190 #ifdef RTCAN_SOCKET +00191 baudrate = (can_baudrate_t *) & ifr.ifr_ifru; +00192 *baudrate = TranslateBaudRate (board->baudrate); +00193 if (!*baudrate) +00194 goto error_close; +00195 +00196 err = CAN_IOCTL (*(int *) fd0, SIOCSCANBAUDRATE, &ifr); +00197 if (err) +00198 { +00199 fprintf (stderr, +00200 "Setting baudrate %d failed: %s\n", +00201 *baudrate, strerror (CAN_ERRNO (err))); +00202 goto error_close; +00203 } +00204 +00205 mode = (can_mode_t *) & ifr.ifr_ifru; +00206 *mode = CAN_MODE_START; +00207 err = CAN_IOCTL (*(int *) fd0, SIOCSCANMODE, &ifr); +00208 if (err) +00209 { +00210 fprintf (stderr, "Starting CAN device failed: %s\n", +00211 strerror (CAN_ERRNO (err))); +00212 goto error_close; +00213 } +00214 #endif +00215 +00216 return fd0; +00217 +00218 error_close: +00219 CAN_CLOSE (*(int *) fd0); +00220 +00221 error_ret: +00222 free (fd0); +00223 return NULL; +00224 } +00225 +00226 /***************************************************************************/ +00227 int +00228 canClose_driver (CAN_HANDLE fd0) +00229 { +00230 if (fd0) +00231 { +00232 CAN_CLOSE (*(int *) fd0); +00233 free (fd0); +00234 } +00235 return 0; +00236 } +
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <errno.h>
#include "config.h"
#include <sys/socket.h>
#include <sys/ioctl.h>
#include "linux/can.h"
#include "linux/can/raw.h"
#include "net/if.h"
#include "can_driver.h"
+Include dependency graph for can_socket.c:
+Go to the source code of this file.
Defines | |
#define | PF_CAN 29 |
#define | AF_CAN PF_CAN |
#define | CAN_IFNAME "can%s" |
#define | CAN_SOCKET socket |
#define | CAN_CLOSE close |
#define | CAN_RECV recv |
#define | CAN_SEND send |
#define | CAN_BIND bind |
#define | CAN_IOCTL ioctl |
#define | CAN_ERRNO(err) errno |
Functions | |
UNS8 | canReceive_driver (CAN_HANDLE fd0, Message *m) |
UNS8 | canSend_driver (CAN_HANDLE fd0, Message *m) |
CAN_HANDLE | canOpen_driver (s_BOARD *board) |
int | canClose_driver (CAN_HANDLE fd0) |
#define AF_CAN PF_CAN | +
#define CAN_BIND bind | +
#define CAN_CLOSE close | +
+ +
+Definition at line 52 of file can_socket.c. +
+Referenced by canClose_driver(), and canOpen_driver(). +
#define CAN_ERRNO | +( | +err | ++ | ) | +errno | +
+ +
+Definition at line 57 of file can_socket.c. +
+Referenced by canOpen_driver(), canReceive_driver(), and canSend_driver(). +
#define CAN_IFNAME "can%s" | +
#define CAN_IOCTL ioctl | +
#define CAN_RECV recv | +
#define CAN_SEND send | +
#define CAN_SOCKET socket | +
#define PF_CAN 29 | +
+
int canClose_driver | +( | +CAN_HANDLE | +fd0 | +) | ++ |
CAN_HANDLE canOpen_driver | +( | +s_BOARD * | +board | +) | ++ |
+ +
+Definition at line 150 of file can_socket.c. +
+References AF_CAN, struct_s_BOARD::baudrate, struct_s_BOARD::busname, CAN_BIND, CAN_CLOSE, CAN_ERRNO, CAN_IFNAME, CAN_IOCTL, CAN_SOCKET, and PF_CAN. +
UNS8 canReceive_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 64 of file can_socket.c. +
+References CAN_ERRNO, CAN_RECV, Message::cob_id, Message::data, Message::len, Message::rtr, and SHORT_CAN::w. +
UNS8 canSend_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 90 of file can_socket.c. +
+References CAN_ERRNO, CAN_SEND, Message::cob_id, Message::data, Message::len, Message::rtr, and SHORT_CAN::w. +
+
00001 // can_uvccm_win32 adapter (http://www.gridconnect.com) +00002 // driver for CanFestival-3 Win32 port +00003 // Copyright (C) 2007 Leonid Tochinski, ChattenAssociates, Inc. +00004 +00005 +00006 #include <sstream> +00007 #include <iomanip> +00008 #if 0 // change to 1 if you use boost +00009 #include <boost/algorithm/string/case_conv.hpp> +00010 #else +00011 #include <algorithm> +00012 #endif +00013 +00014 extern "C" { +00015 #include "can_driver.h" +00016 } +00017 class can_uvccm_win32 +00018 { +00019 public: +00020 class error +00021 { +00022 }; +00023 can_uvccm_win32(s_BOARD *board); +00024 ~can_uvccm_win32(); +00025 bool send(const Message *m); +00026 bool receive(Message *m); +00027 private: +00028 bool open_rs232(int port = 1, int baud_rate = 57600); +00029 bool close_rs232(); +00030 bool get_can_data(const char* can_cmd_buf, long& bufsize, Message* m); +00031 bool set_can_data(const Message& m, std::string& can_cmd); +00032 private: +00033 HANDLE m_port; +00034 HANDLE m_read_event; +00035 HANDLE m_write_event; +00036 std::string m_residual_buffer; +00037 }; +00038 +00039 can_uvccm_win32::can_uvccm_win32(s_BOARD *board) : m_port(INVALID_HANDLE_VALUE), +00040 m_read_event(0), +00041 m_write_event(0) +00042 { +00043 if (strcmp( board->baudrate, "125K") || !open_rs232(1)) +00044 throw error(); +00045 } +00046 +00047 can_uvccm_win32::~can_uvccm_win32() +00048 { +00049 close_rs232(); +00050 } +00051 +00052 bool can_uvccm_win32::send(const Message *m) +00053 { +00054 if (m_port == INVALID_HANDLE_VALUE) +00055 return false; +00056 +00057 // build can_uvccm_win32 command string +00058 std::string can_cmd; +00059 set_can_data(*m, can_cmd); +00060 +00061 OVERLAPPED overlapped; +00062 ::memset(&overlapped, 0, sizeof overlapped); +00063 overlapped.hEvent = m_write_event; +00064 ::ResetEvent(overlapped.hEvent); +00065 +00066 unsigned long bytes_written = 0; +00067 ::WriteFile(m_port, can_cmd.c_str(), (unsigned long)can_cmd.size(), &bytes_written, &overlapped); +00068 // wait for write operation completion +00069 enum { WRITE_TIMEOUT = 1000 }; +00070 ::WaitForSingleObject(overlapped.hEvent, WRITE_TIMEOUT); +00071 // get number of bytes written +00072 ::GetOverlappedResult(m_port, &overlapped, &bytes_written, FALSE); +00073 +00074 bool result = (bytes_written == can_cmd.size()); +00075 +00076 return result; +00077 } +00078 +00079 +00080 bool can_uvccm_win32::receive(Message *m) +00081 { +00082 if (m_port == INVALID_HANDLE_VALUE) +00083 return false; +00084 +00085 long res_buffer_size = (long)m_residual_buffer.size(); +00086 bool result = get_can_data(m_residual_buffer.c_str(), res_buffer_size, m); +00087 if (result) +00088 { +00089 m_residual_buffer.erase(0, res_buffer_size); +00090 return true; +00091 } +00092 +00093 enum { READ_TIMEOUT = 500 }; +00094 +00095 OVERLAPPED overlapped; +00096 ::memset(&overlapped, 0, sizeof overlapped); +00097 overlapped.hEvent = m_read_event; +00098 ::ResetEvent(overlapped.hEvent); +00099 unsigned long event_mask = 0; +00100 +00101 if (FALSE == ::WaitCommEvent(m_port, &event_mask, &overlapped) && ERROR_IO_PENDING == ::GetLastError()) +00102 { +00103 if (WAIT_TIMEOUT == ::WaitForSingleObject(overlapped.hEvent, READ_TIMEOUT)) +00104 return false; +00105 } +00106 +00107 // get number of bytes in the input que +00108 COMSTAT stat; +00109 ::memset(&stat, 0, sizeof stat); +00110 unsigned long errors = 0; +00111 ::ClearCommError(m_port, &errors, &stat); +00112 if (stat.cbInQue == 0) +00113 return false; +00114 char buffer[3000]; +00115 +00116 unsigned long bytes_to_read = min(stat.cbInQue, sizeof (buffer)); +00117 +00118 unsigned long bytes_read = 0; +00119 ::ReadFile(m_port, buffer, bytes_to_read, &bytes_read, &overlapped); +00120 // wait for read operation completion +00121 ::WaitForSingleObject(overlapped.hEvent, READ_TIMEOUT); +00122 // get number of bytes read +00123 ::GetOverlappedResult(m_port, &overlapped, &bytes_read, FALSE); +00124 result = false; +00125 if (bytes_read > 0) +00126 { +00127 m_residual_buffer.append(buffer, bytes_read); +00128 res_buffer_size = (long)m_residual_buffer.size(); +00129 result = get_can_data(m_residual_buffer.c_str(), res_buffer_size, m); +00130 if (result) +00131 m_residual_buffer.erase(0, res_buffer_size); +00132 } +00133 return result; +00134 } +00135 +00136 bool can_uvccm_win32::open_rs232(int port, int baud_rate) +00137 { +00138 if (m_port != INVALID_HANDLE_VALUE) +00139 return true; +00140 +00141 std::ostringstream device_name; +00142 device_name << "COM" << port; +00143 +00144 m_port = ::CreateFile(device_name.str().c_str(), +00145 GENERIC_READ | GENERIC_WRITE, +00146 0, // exclusive access +00147 NULL, // no security +00148 OPEN_EXISTING, +00149 FILE_FLAG_OVERLAPPED, // overlapped I/O +00150 NULL); // null template +00151 +00152 // Check the returned handle for INVALID_HANDLE_VALUE and then set the buffer sizes. +00153 if (m_port == INVALID_HANDLE_VALUE) +00154 return false; +00155 +00156 // SetCommMask(m_hCom,EV_RXCHAR|EV_TXEMPTY|EV_CTS|EV_DSR|EV_RLSD|EV_BREAK|EV_ERR|EV_RING); // +00157 ::SetCommMask(m_port, EV_RXFLAG); +00158 +00159 COMMTIMEOUTS timeouts; +00160 ::memset(&timeouts, 0, sizeof (timeouts)); +00161 timeouts.ReadIntervalTimeout = -1; +00162 timeouts.ReadTotalTimeoutConstant = 0; +00163 timeouts.ReadTotalTimeoutMultiplier = 0; +00164 timeouts.WriteTotalTimeoutConstant = 5000; +00165 timeouts.WriteTotalTimeoutMultiplier = 0; +00166 SetCommTimeouts(m_port, &timeouts); // +00167 +00168 ::SetupComm(m_port, 1024, 512); // set buffer sizes +00169 +00170 // Port settings are specified in a Data Communication Block (DCB). The easiest way to initialize a DCB is to call GetCommState to fill in its default values, override the values that you want to change and then call SetCommState to set the values. +00171 DCB dcb; +00172 ::memset(&dcb, 0, sizeof (dcb)); +00173 ::GetCommState(m_port, &dcb); +00174 dcb.BaudRate = baud_rate; +00175 dcb.ByteSize = 8; +00176 dcb.Parity = NOPARITY; +00177 dcb.StopBits = ONESTOPBIT; +00178 dcb.fAbortOnError = TRUE; +00179 dcb.EvtChar = 0x0A; // '\n' character +00180 ::SetCommState(m_port, &dcb); +00181 +00182 ::PurgeComm(m_port, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); +00183 +00184 m_read_event = ::CreateEvent(NULL, TRUE, FALSE, NULL); +00185 m_write_event = ::CreateEvent(NULL, TRUE, FALSE, NULL); +00186 +00187 return true; +00188 } +00189 +00190 bool can_uvccm_win32::close_rs232() +00191 { +00192 if (m_port != INVALID_HANDLE_VALUE) +00193 { +00194 ::PurgeComm(m_port, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); +00195 ::CloseHandle(m_port); +00196 m_port = INVALID_HANDLE_VALUE; +00197 ::CloseHandle(m_read_event); +00198 m_read_event = 0; +00199 ::CloseHandle(m_write_event); +00200 m_write_event = 0; +00201 m_residual_buffer.clear(); +00202 } +00203 return true; +00204 } +00205 +00206 bool can_uvccm_win32::get_can_data(const char* can_cmd_buf, long& bufsize, Message* m) +00207 { +00208 if (bufsize < 5) +00209 { +00210 bufsize = 0; +00211 return false; +00212 } +00213 +00214 Message msg; +00215 ::memset(&msg, 0 , sizeof (msg)); +00216 char colon = 0, type = 0, request = 0; +00217 std::istringstream buf(std::string(can_cmd_buf, bufsize)); +00218 buf >> colon >> type >> std::hex >> msg.cob_id.w >> request; +00219 if (colon != ':' || (type != 'S' && type != 'X')) +00220 { +00221 bufsize = 0; +00222 return false; +00223 } +00224 if (request == 'N') +00225 { +00226 msg.rtr = 0; +00227 for (msg.len = 0; msg.len < 8; ++msg.len) +00228 { +00229 std::string data_byte_str; +00230 buf >> std::setw(2) >> data_byte_str; +00231 if (data_byte_str[0] == ';') +00232 break; +00233 long byte_val = -1; +00234 std::istringstream(data_byte_str) >> std::hex >> byte_val; +00235 if (byte_val == -1) +00236 { +00237 bufsize = 0; +00238 return false; +00239 } +00240 msg.data[msg.len] = (UNS8)byte_val; +00241 } +00242 if (msg.len == 8) +00243 { +00244 char semicolon = 0; +00245 buf >> semicolon; +00246 if (semicolon != ';') +00247 { +00248 bufsize = 0; +00249 return false; +00250 } +00251 } +00252 +00253 } +00254 else if (request == 'R') +00255 { +00256 msg.rtr = 1; +00257 buf >> msg.len; +00258 } +00259 else +00260 { +00261 bufsize = 0; +00262 return false; +00263 } +00264 +00265 bufsize = buf.tellg(); +00266 +00267 *m = msg; +00268 return true; +00269 } +00270 +00271 bool can_uvccm_win32::set_can_data(const Message& m, std::string& can_cmd) +00272 { +00273 // build can_uvccm_win32 command string +00274 std::ostringstream can_cmd_str; +00275 can_cmd_str << ":S" << std::hex << m.cob_id.w; +00276 if (m.rtr == 1) +00277 { +00278 can_cmd_str << 'R' << (long)m.len; +00279 } +00280 else +00281 { +00282 can_cmd_str << 'N'; +00283 for (int i = 0; i < m.len; ++i) +00284 can_cmd_str << std::hex << std::setfill('0') << std::setw(2) << (long)m.data[i]; +00285 } +00286 can_cmd_str << ';'; +00287 can_cmd = can_cmd_str.str(); +00288 #ifdef BOOST_VERSION +00289 boost::to_upper(can_cmd); +00290 #else +00291 std::transform(can_cmd.begin(),can_cmd.end(),can_cmd.begin(),::toupper); +00292 #endif +00293 return true; +00294 } +00295 +00296 +00297 //------------------------------------------------------------------------ +00298 extern "C" +00299 UNS8 canReceive_driver(CAN_HANDLE fd0, Message *m) +00300 { +00301 return (UNS8)(!(reinterpret_cast<can_uvccm_win32*>(fd0)->receive(m))); +00302 } +00303 +00304 extern "C" +00305 UNS8 canSend_driver(CAN_HANDLE fd0, Message *m) +00306 { +00307 return (UNS8)reinterpret_cast<can_uvccm_win32*>(fd0)->send(m); +00308 } +00309 +00310 extern "C" +00311 CAN_HANDLE canOpen_driver(s_BOARD *board) +00312 { +00313 try +00314 { +00315 return (CAN_HANDLE) new can_uvccm_win32(board); +00316 } +00317 catch (can_uvccm_win32::error&) +00318 { +00319 return NULL; +00320 } +00321 } +00322 +00323 extern "C" +00324 int canClose_driver(CAN_HANDLE inst) +00325 { +00326 delete reinterpret_cast<can_uvccm_win32*>(inst); +00327 return 1; +00328 } +00329 +00330 +00331 +
#include <sstream>
#include <iomanip>
#include <algorithm>
#include "can_driver.h"
+Include dependency graph for can_uvccm_win32.cpp:
+Go to the source code of this file.
Data Structures | |
class | can_uvccm_win32 |
class | can_uvccm_win32::error |
Functions | |
UNS8 | canReceive_driver (CAN_HANDLE fd0, Message *m) |
UNS8 | canSend_driver (CAN_HANDLE fd0, Message *m) |
CAN_HANDLE | canOpen_driver (s_BOARD *board) |
int | canClose_driver (CAN_HANDLE inst) |
int canClose_driver | +( | +CAN_HANDLE | +inst | +) | ++ |
+ +
+Definition at line 324 of file can_uvccm_win32.cpp. +
CAN_HANDLE canOpen_driver | +( | +s_BOARD * | +board | +) | ++ |
+ +
+Definition at line 311 of file can_uvccm_win32.cpp. +
UNS8 canReceive_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
UNS8 canSend_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 /* +00024 Virtual CAN driver. +00025 */ +00026 +00027 #include <stdio.h> +00028 #include <unistd.h> +00029 +00030 #include "can_driver.h" +00031 #include "def.h" +00032 +00033 #define MAX_NB_CAN_PIPES 16 +00034 +00035 typedef struct { +00036 char used; +00037 int pipe[2]; +00038 } CANPipe; +00039 +00040 CANPipe canpipes[MAX_NB_CAN_PIPES] = {{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},}; +00041 +00042 /*********functions which permit to communicate with the board****************/ +00043 UNS8 canReceive_driver(CAN_HANDLE fd0, Message *m) +00044 { +00045 if(read(((CANPipe*)fd0)->pipe[0], m, sizeof(Message)) != (ssize_t)sizeof(Message)) +00046 { +00047 return 1; +00048 } +00049 return 0; +00050 } +00051 +00052 #define MyCase(fc) case fc: printf(#fc);break; +00053 void print_message(Message *m) +00054 { +00055 int i; +00056 switch(m->cob_id.w >> 7) +00057 { +00058 MyCase(SYNC) +00059 MyCase(TIME_STAMP) +00060 MyCase(PDO1tx) +00061 MyCase(PDO1rx) +00062 MyCase(PDO2tx) +00063 MyCase(PDO2rx) +00064 MyCase(PDO3tx) +00065 MyCase(PDO3rx) +00066 MyCase(PDO4tx) +00067 MyCase(PDO4rx) +00068 MyCase(SDOtx) +00069 MyCase(SDOrx) +00070 MyCase(NODE_GUARD) +00071 MyCase(NMT) +00072 } +00073 printf(" rtr:%d", m->rtr); +00074 printf(" len:%d", m->len); +00075 for (i = 0 ; i < m->len ; i++) +00076 printf(" %02x", m->data[i]); +00077 printf("\n"); +00078 } +00079 +00080 /***************************************************************************/ +00081 UNS8 canSend_driver(CAN_HANDLE fd0, Message *m) +00082 { +00083 int i; +00084 +00085 printf("%x->[ ", (CANPipe*)fd0 - &canpipes[0]); +00086 for(i=0; i < MAX_NB_CAN_PIPES; i++) +00087 { +00088 if(canpipes[i].used && &canpipes[i] != (CANPipe*)fd0) +00089 { +00090 printf("%x ",i); +00091 } +00092 } +00093 printf(" ]"); +00094 print_message(m); +00095 +00096 // Send to all readers, except myself +00097 for(i=0; i < MAX_NB_CAN_PIPES; i++) +00098 { +00099 if(canpipes[i].used && &canpipes[i] != (CANPipe*)fd0) +00100 { +00101 write(canpipes[i].pipe[1], m, sizeof(Message)); +00102 } +00103 } +00104 return 0; +00105 } +00106 /* +00107 int TranslateBaudeRate(char* optarg){ +00108 if(!strcmp( optarg, "1M")) return 1000; +00109 if(!strcmp( optarg, "500K")) return 500; +00110 if(!strcmp( optarg, "250K")) return 250; +00111 if(!strcmp( optarg, "125K")) return 125; +00112 if(!strcmp( optarg, "100K")) return 100; +00113 if(!strcmp( optarg, "50K")) return 50; +00114 if(!strcmp( optarg, "20K")) return 20; +00115 if(!strcmp( optarg, "10K")) return 10; +00116 if(!strcmp( optarg, "5K")) return 5; +00117 if(!strcmp( optarg, "none")) return 0; +00118 return 0; +00119 }*/ +00120 /***************************************************************************/ +00121 CAN_HANDLE canOpen_driver(s_BOARD *board) +00122 { +00123 int i; +00124 for(i=0; i < MAX_NB_CAN_PIPES; i++) +00125 { +00126 if(!canpipes[i].used) +00127 break; +00128 } +00129 +00130 /* Create the pipe. */ +00131 if (i==MAX_NB_CAN_PIPES || pipe(canpipes[i].pipe)) +00132 { +00133 fprintf (stderr, "Open failed.\n"); +00134 return (CAN_HANDLE)NULL; +00135 } +00136 +00137 canpipes[i].used = 1; +00138 return (CAN_HANDLE) &canpipes[i]; +00139 } +00140 +00141 /***************************************************************************/ +00142 int canClose_driver(CAN_HANDLE fd0) +00143 { +00144 close(((CANPipe*)fd0)->pipe[0]); +00145 close(((CANPipe*)fd0)->pipe[1]); +00146 ((CANPipe*)fd0)->used = 0; +00147 return 0; +00148 } +00149 +00150 +
#include <stdio.h>
#include <unistd.h>
#include "can_driver.h"
#include "def.h"
+Include dependency graph for can_virtual.c:
+Go to the source code of this file.
Data Structures | |
struct | CANPipe |
Defines | |
#define | MAX_NB_CAN_PIPES 16 |
#define | MyCase(fc) case fc: printf(#fc);break; |
Functions | |
UNS8 | canReceive_driver (CAN_HANDLE fd0, Message *m) |
void | print_message (Message *m) |
UNS8 | canSend_driver (CAN_HANDLE fd0, Message *m) |
CAN_HANDLE | canOpen_driver (s_BOARD *board) |
int | canClose_driver (CAN_HANDLE fd0) |
Variables | |
CANPipe | canpipes [MAX_NB_CAN_PIPES] = {{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},} |
#define MAX_NB_CAN_PIPES 16 | +
+ +
+Definition at line 33 of file can_virtual.c. +
+Referenced by canOpen_driver(), and canSend_driver(). +
#define MyCase | +( | +fc | ++ | ) | +case fc: printf(#fc);break; | +
+
int canClose_driver | +( | +CAN_HANDLE | +fd0 | +) | ++ |
+ +
+Definition at line 142 of file can_virtual.c. +
CAN_HANDLE canOpen_driver | +( | +s_BOARD * | +board | +) | ++ |
+ +
+Definition at line 121 of file can_virtual.c. +
+References canpipes, MAX_NB_CAN_PIPES, and CANPipe::used. +
UNS8 canReceive_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 43 of file can_virtual.c. +
UNS8 canSend_driver | +( | +CAN_HANDLE | +fd0, | +|
+ | + | Message * | +m | + |
+ | ) | ++ |
+ +
+Definition at line 81 of file can_virtual.c. +
+References canpipes, MAX_NB_CAN_PIPES, and print_message(). +
+Here is the call graph for this function:
void print_message | +( | +Message * | +m | +) | ++ |
+ +
+Definition at line 53 of file can_virtual.c. +
+References Message::cob_id, Message::data, Message::len, MyCase, NMT, NODE_GUARD, PDO1rx, PDO1tx, PDO2rx, PDO2tx, PDO3rx, PDO3tx, PDO4rx, PDO4tx, Message::rtr, SDOrx, SDOtx, SYNC, TIME_STAMP, and SHORT_CAN::w. +
+Referenced by canSend_driver(). +
+
CANPipe canpipes[MAX_NB_CAN_PIPES] = {{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},} | +
+ +
+Definition at line 40 of file can_virtual.c. +
+Referenced by canOpen_driver(), and canSend_driver(). +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #ifndef __CANDRIVER__ +00024 #define __CANDRIVER__ +00025 +00026 //#include DEBUG_CAN +00027 +00028 #include <can.h> +00029 #include <objdictdef.h> +00030 +00031 +00032 /* +00033 The CAN message received are stored in a fifo stack +00034 We consider one stack for all the 5 can devices. It is a choice ! +00035 */ +00036 +00037 /* Be free to change this value */ +00038 #define MAX_STACK_MSG_RCV 5 +00039 +00040 /* Number of incomings and outcomings CAN Line. The layer CanOpen must be +00041 used only for ONE line CAN. But you may used one or more CAN drivers, without +00042 a CanOpen layer. +00043 Only 2 lines are implemented. If more lines are needed, copy void __attribute__((interrupt)) can0HdlRcv (void) to void __attribute__((interrupt)) canXHdlRcv (void) and make +00044 changes : [0] to [x], CAN0 to CANX, etc +00045 */ +00046 #define NB_LINE_CAN 1 +00047 +00048 /* Whose hardware HCS12 CAN block is used for CanOpen ? Chose between CAN0, ..., CAN4 +00049 If you use CANOPEN_LINE_NUMBER_USED = CANI, the value of NB_LINE_CAN must be +00050 more or equal to I + 1 +00051 Value other than CAN0 not tested, but should work fine. +00052 */ +00053 #define CANOPEN_LINE_NUMBER_USED CAN0 +00054 +00055 /* Stack of received messages +00056 MSG received on CAN0 module is stored in stackMsgRcv[0], etc +00057 */ +00058 extern volatile Message stackMsgRcv[NB_LINE_CAN][MAX_STACK_MSG_RCV]; +00059 +00060 +00061 /* Copy from the stack of the message to treat */ +00062 extern Message msgRcv; +00063 +00064 +00065 /* To move on the stack of messages +00066 */ +00067 typedef struct { +00068 UNS8 w ; /* received */ +00069 UNS8 r ; /* To transmit */ +00070 } t_pointerStack; +00071 +00072 +00073 /* Pointer for write or read a message in/from the reception stack */ +00074 extern volatile t_pointerStack ptrMsgRcv[NB_LINE_CAN]; +00075 +00076 /* +00077 Parameters to define the clock system for the CAN bus +00078 example : +00079 CAN_BUS_TIME clk = { +00080 1, // clksrc: Use the bus clock : 16 MHz, the freq. of the quartz's board +00081 0, // brp : chose btw 0 and 63 (6 bits). freq time quantum = 16MHz / (brp + 1) +00082 1, // sjw : chose btw 0 and 3 (2 bits). Sync on (sjw + 1 ) time quantum +00083 1, // samp : chose btw 0 and 3 (2 bits) (samp + 1 ) samples per bit +00084 4, // tseg2 : chose btw 0 and 7 (3 bits) Segment 2 width = (tseg2 + 1) tq +00085 9, // tseg1 : chose btw 0 and 15 (4 bits) Segment 1 width = (tseg1 + 1) tq +00086 +00087 +00088 With these values, +00089 - The width of the bit time is 16 time quantum : +00090 - 1 tq for the SYNC segment (could not be modified) +00091 - 10 tq for the TIME 1 segment (tseg1 = 9) +00092 - 5 tq for the TIME 2 segment (tseg2 = 4) +00093 - Because the bus clock of the MSCAN is 16 MHZ, and the +00094 freq of the time quantum is 16 MHZ (brp = 0), and there are 16 tq in the bit time, +00095 so the freq of the bit time is 1 MHz. +00096 +00097 }; +00098 */ +00099 typedef struct { +00100 UNS8 clksrc; /* use of internal clock or clock bus */ +00101 UNS8 brp; /* define the bus speed */ +00102 UNS8 sjw; /* Number of time quantum for synchro - 1 */ +00103 UNS8 samp; /* Number of sample per bit (1 or 3) */ +00104 UNS8 tseg2; /* Width of the time segment 2 (in tq) - 1 */ +00105 UNS8 tseg1; /* Width of the time segment 1 (in tq) - 1 */ +00106 } canBusTime; +00107 +00108 /* +00109 Parameters to init the filters for received messages +00110 */ +00111 typedef struct { +00112 UNS8 idam; /* Put 0x01 for 16 bits acceptance filter */ +00113 UNS8 canidar0; +00114 UNS8 canidmr0; +00115 UNS8 canidar1; +00116 UNS8 canidmr1; +00117 UNS8 canidar2; +00118 UNS8 canidmr2; +00119 UNS8 canidar3; +00120 UNS8 canidmr3; +00121 UNS8 canidar4; +00122 UNS8 canidmr4; +00123 UNS8 canidar5; +00124 UNS8 canidmr5; +00125 UNS8 canidar6; +00126 UNS8 canidmr6; +00127 UNS8 canidar7; +00128 UNS8 canidmr7; +00129 } canBusFilterInit; +00130 +00131 /* +00132 Parameters to init MSCAN +00133 Example +00134 CAN_BUS_INIT bi = { +00135 0, no low power +00136 0, no time stamp +00137 1, enable MSCAN +00138 0, clock source : oscillator +00139 0, no loop back +00140 0, no listen only +00141 0, no low pass filter for wk up +00142 { +00143 1, Use the oscillator clock +00144 0, Quartz oscillator : freq time quantum = freq oscillator clock / (0 + 1) +00145 1, Sync on (1 + 1) time quantum +00146 1, 1 sample per bit +00147 4, time segment 2 width : (4 + 1) tq +00148 9, time segment 1 width : (9 + 1) tq +00149 } +00150 }; +00151 */ +00152 +00153 typedef struct { +00154 UNS8 cswai; /* Low power/normal in wait mode (1/0) */ +00155 UNS8 time; /* Timer for time-stamp enable/disable (1/0) */ +00156 UNS8 cane; /* Enable MSCAN (yes=1) Do it ! */ +00157 UNS8 clksrc; /* clock source bus/oscillator (1/0) */ +00158 UNS8 loopb; /* loop back mode for test (yes=1/no=0) */ +00159 UNS8 listen; /* MSCAN is listen only (yes=1/no=0 ie normal)*/ +00160 UNS8 wupm; /* low pas filter for wake up (yes=1/no=0) */ +00161 canBusTime +00162 clk; /* Values for clock system init */ +00163 canBusFilterInit +00164 fi; /* Values for filter acceptance msg init */ +00165 +00166 } canBusInit; +00167 +00168 extern canBusInit bi; +00169 +00170 +00171 +00172 /* +00173 For the received messsage, add a Identificator to +00174 the list of ID to accept. +00175 You can use several times this function to accept several messages. +00176 It configures registers on 16 bits. +00177 Automatically, it configure the filter to +00178 - not accepting the msg on 29 bits (ide=1 refused) +00179 - not filtering on rtr state (rtr = 1 and rtr = 0 are accepted) +00180 Algo : +00181 if CANIDARx = 0 then CANIDARx = id . else do nothing +00182 CANIDMRx = CANIDMRx OR (CANIDARx XOR id ) +00183 nFilter : 0 to 3 +00184 Must be in init mode before. +00185 */ +00186 char canAddIdToFilter ( +00187 UNS16 adrCAN, +00188 UNS8 nFilter, +00189 UNS16 id /* 11 bits, the 5 msb not used */ +00190 ); +00191 +00192 /* +00193 Use this function to change the CAN message acceptance filters and masks. +00194 */ +00195 char canChangeFilter (UNS16 adrCAN, canBusFilterInit fi); +00196 +00197 +00198 /* +00199 Enable one of the 5 MSCAN. +00200 Must be done only one time after a reset of the CPU. +00201 To do before any CAN initialisation +00202 */ +00203 char canEnable ( +00204 UNS16 adrCAN /* First address of MSCANx registers */ +00205 ); +00206 +00207 +00208 /* +00209 Initialize one of the 5 mscan +00210 can be done multiple times in your code +00211 Return 0 : OK +00212 When it return from the function, +00213 mscan is on sleep mode with wake up disabled. +00214 is not on init mode +00215 */ +00216 char canInit ( +00217 UNS16 adrCAN, /* First address of MSCANx registers */ +00218 canBusInit +00219 bi /* All the parameters to init the bus */ +00220 ); +00221 /* +00222 Initialize the parameters of the system clock for the MSCAN +00223 You must put the MSCAN in sleep mode before with canSleepMode() +00224 Return 0 : OK +00225 1 : Not in sleep mode. Unable to init MSCAN +00226 */ +00227 char canInitClock ( +00228 UNS16 adrCAN, /* First address of MSCANx registers */ +00229 canBusTime clk); +00230 +00231 /* +00232 Initialize one filter for acceptance of received msg. +00233 Filters MUST be configured on 16 bits +00234 (See doc Motorola mscan bloc guide fig 4.3) +00235 Must be in init mode before. +00236 adrCAN : adress of the first register of the mscan module +00237 nFilter : the filter : 0 to 3. +00238 ar : Value to write in acceptance register +00239 Beware ! hight byte and low byte inverted. +00240 for example if nFilter = 0, hight byte of ar -> CANIDAR0 +00241 low byte of ar -> CANIDAR1 +00242 mr : Value to write in mask register +00243 Beware ! hight byte and low byte inverted. +00244 for example if nFilter = 2, hight byte of ar -> CANIDMR4 +00245 low byte of ar -> CANIDMR5 +00246 */ +00247 char canInit1Filter ( +00248 UNS16 adrCAN, +00249 UNS8 nFilter, +00250 UNS16 ar, +00251 UNS16 mr +00252 ); +00253 +00254 /* +00255 Initialise the parameters for filtering the messages received. +00256 You must put the MSCAN in init mode before with canInitMode() +00257 Return 0 : OK +00258 1 : Not in init mode. Unable to init MSCAN +00259 */ +00260 +00261 char canInitFilter ( +00262 UNS16 adrCAN, /* First address of MSCANx registers */ +00263 canBusFilterInit fi); +00264 /* +00265 Put one of the 5 mscan in Init mode +00266 Loop until init mode is reached. +00267 */ +00268 +00269 char canInitMode ( +00270 UNS16 adrCAN /* First address of MSCANx registers */ +00271 ); +00272 +00273 /* +00274 Leave the Init mode +00275 loop until init mode leaved. +00276 */ +00277 +00278 char canInitModeQ ( +00279 UNS16 adrCAN /* First address of MSCANx registers */ +00280 ); +00281 +00282 +00283 +00284 /* +00285 Transmit a msg on CAN "adrCan" +00286 Return : 0 No error +00287 other error : no buffer available to make the transmission +00288 */ +00289 +00290 char canMsgTransmit ( +00291 UNS16 adrCAN, /* First address of MSCANx registers */ +00292 Message msg /* Message to transmit */ +00293 ); +00294 +00295 /* +00296 Set the interruptions. Must be call just after having left the init mode. +00297 */ +00298 char canSetInterrupt (UNS16 adrCAN); +00299 +00300 /* +00301 Put one of the 5 mscan in sleep mode +00302 Beware! If some messages are to be sent, +00303 or if it is receiving, going into sleep mode +00304 may take time. +00305 Wake up is disabled : stay in sleep mode even if +00306 bus traffic detected. +00307 return 0 if 0K, other if error : mscan is on init mode. +00308 Stay in this function until the sleep mode +00309 is reached. +00310 */ +00311 char canSleepMode ( +00312 UNS16 adrCAN /* First address of MSCANx registers */ +00313 ); +00314 +00315 /* +00316 Leave the sleep mode +00317 loop until sleep mode leaved. +00318 return 0 : OK +00319 return 1 : error : in init mode +00320 */ +00321 char canSleepModeQ ( +00322 UNS16 adrCAN /* First address of MSCANx registers */ +00323 ); +00324 +00325 /* +00326 Put one of the 5 mscan in sleep mode +00327 MSCAN must not be in init mode. +00328 wake up is enabled : wake up if traffic on CAN is detected +00329 Beware! If some messages are to be sent, +00330 or if it is receiving, going into sleep mode +00331 may take time. +00332 Loop until sleep mode reached. +00333 return 0 if 0K, other if error +00334 */ +00335 char canSleepWupMode ( +00336 UNS16 adrCAN /* First address of MSCANx registers */ +00337 ); +00338 +00339 /* +00340 Test if one of the 5 mscan is in init mode. +00341 Return +00342 0 -> Not in init mode +00343 other -> In init mode +00344 */ +00345 char canTestInitMode ( +00346 UNS16 adrCAN /* First address of MSCANx registers */ +00347 ); +00348 +00349 /* +00350 Test if one of the 5 mscan is in sleep mode. +00351 Return +00352 0 -> Not in sleep mode +00353 other -> In sleep mode +00354 */ +00355 char canTestSleepMode ( +00356 UNS16 adrCAN /* First address of MSCANx registers */ +00357 ); +00358 +00359 +00360 +00361 #endif /*__CANDRIVER__*/ +00362 +
#include <can.h>
#include <objdictdef.h>
+Include dependency graph for candriver.h:
+Go to the source code of this file.
Data Structures | |
struct | t_pointerStack |
struct | canBusTime |
struct | canBusFilterInit |
struct | canBusInit |
Defines | |
#define | MAX_STACK_MSG_RCV 5 |
#define | NB_LINE_CAN 1 |
#define | CANOPEN_LINE_NUMBER_USED CAN0 |
Functions | |
char | canAddIdToFilter (UNS16 adrCAN, UNS8 nFilter, UNS16 id) |
char | canChangeFilter (UNS16 adrCAN, canBusFilterInit fi) |
char | canEnable (UNS16 adrCAN) |
char | canInit (UNS16 adrCAN, canBusInit bi) |
char | canInitClock (UNS16 adrCAN, canBusTime clk) |
char | canInit1Filter (UNS16 adrCAN, UNS8 nFilter, UNS16 ar, UNS16 mr) |
char | canInitFilter (UNS16 adrCAN, canBusFilterInit fi) |
char | canInitMode (UNS16 adrCAN) |
char | canInitModeQ (UNS16 adrCAN) |
char | canMsgTransmit (UNS16 adrCAN, Message msg) |
char | canSetInterrupt (UNS16 adrCAN) |
char | canSleepMode (UNS16 adrCAN) |
char | canSleepModeQ (UNS16 adrCAN) |
char | canSleepWupMode (UNS16 adrCAN) |
char | canTestInitMode (UNS16 adrCAN) |
char | canTestSleepMode (UNS16 adrCAN) |
Variables | |
volatile Message | stackMsgRcv [NB_LINE_CAN][MAX_STACK_MSG_RCV] |
Message | msgRcv |
volatile t_pointerStack | ptrMsgRcv [NB_LINE_CAN] |
canBusInit | bi |
#define CANOPEN_LINE_NUMBER_USED CAN0 | +
+ +
+Definition at line 53 of file candriver.h. +
+Referenced by canSend(), f_can_receive(), gene_SYNC_operational(), gene_SYNC_preOperational(), and initSensor(). +
#define MAX_STACK_MSG_RCV 5 | +
#define NB_LINE_CAN 1 | +
+ +
+Definition at line 46 of file candriver.h. +
+
char canAddIdToFilter | +( | +UNS16 | +adrCAN, | +|
+ | + | UNS8 | +nFilter, | +|
+ | + | UNS16 | +id | + |
+ | ) | ++ |
+ +
+Definition at line 210 of file canOpenDriver.c. +
+References CANIDAR0, CANIDAR2, CANIDAR4, CANIDAR6, canTestInitMode(), IO_PORTS_16, IO_PORTS_8, MSG_WAR, and UNS8. +
+Here is the call graph for this function:
char canChangeFilter | +( | +UNS16 | +adrCAN, | +|
+ | + | canBusFilterInit | +fi | + |
+ | ) | ++ |
+ +
+Definition at line 250 of file canOpenDriver.c. +
+References canInitFilter(), canInitMode(), canInitModeQ(), canSetInterrupt(), canSleepMode(), canSleepModeQ(), and canTestInitMode(). +
+Referenced by gene_SYNC_operational(), and gene_SYNC_preOperational(). +
+Here is the call graph for this function:
char canEnable | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 266 of file canOpenDriver.c. +
+References CANCTL1, and IO_PORTS_8. +
+Referenced by canInit(). +
char canInit | +( | +UNS16 | +adrCAN, | +|
+ | + | canBusInit | +bi | + |
+ | ) | ++ |
+ +
+Definition at line 277 of file canOpenDriver.c. +
+References CANCTL0, CANCTL1, canBusInit::cane, canEnable(), canInitClock(), canInitFilter(), canInitMode(), canInitModeQ(), canSetInterrupt(), canSleepMode(), canSleepModeQ(), canTestInitMode(), canBusInit::clk, canBusInit::cswai, canBusInit::fi, IO_PORTS_8, canBusInit::listen, canBusInit::loopb, canBusInit::time, and canBusInit::wupm. +
+Here is the call graph for this function:
char canInit1Filter | +( | +UNS16 | +adrCAN, | +|
+ | + | UNS8 | +nFilter, | +|
+ | + | UNS16 | +ar, | +|
+ | + | UNS16 | +mr | + |
+ | ) | ++ |
+ +
+Definition at line 335 of file canOpenDriver.c. +
+References CANIDAR0, CANIDAR2, CANIDAR4, CANIDAR6, canTestInitMode(), IO_PORTS_8, MSG_WAR, and UNS8. +
+Here is the call graph for this function:
char canInitClock | +( | +UNS16 | +adrCAN, | +|
+ | + | canBusTime | +clk | + |
+ | ) | ++ |
+ +
+Definition at line 313 of file canOpenDriver.c. +
+References canBusTime::brp, CANBTR0, CANBTR1, CANCTL1, canTestInitMode(), canBusTime::clksrc, IO_PORTS_8, MSG_WAR, canBusTime::samp, canBusTime::sjw, canBusTime::tseg1, and canBusTime::tseg2. +
+Referenced by canInit(). +
+Here is the call graph for this function:
char canInitFilter | +( | +UNS16 | +adrCAN, | +|
+ | + | canBusFilterInit | +fi | + |
+ | ) | ++ |
+ +
+Definition at line 364 of file canOpenDriver.c. +
+References CANIDAC, canBusFilterInit::canidar0, CANIDAR0, canBusFilterInit::canidar1, CANIDAR1, canBusFilterInit::canidar2, CANIDAR2, canBusFilterInit::canidar3, CANIDAR3, canBusFilterInit::canidar4, CANIDAR4, canBusFilterInit::canidar5, CANIDAR5, canBusFilterInit::canidar6, CANIDAR6, canBusFilterInit::canidar7, CANIDAR7, canBusFilterInit::canidmr0, CANIDMR0, canBusFilterInit::canidmr1, CANIDMR1, canBusFilterInit::canidmr2, CANIDMR2, canBusFilterInit::canidmr3, CANIDMR3, canBusFilterInit::canidmr4, CANIDMR4, canBusFilterInit::canidmr5, CANIDMR5, canBusFilterInit::canidmr6, CANIDMR6, canBusFilterInit::canidmr7, CANIDMR7, canTestInitMode(), canBusFilterInit::idam, IO_PORTS_8, and MSG_WAR. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canInitMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 392 of file canOpenDriver.c. +
+References CANCTL0, canTestInitMode(), and IO_PORTS_8. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canInitModeQ | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 401 of file canOpenDriver.c. +
+References CANCTL0, canTestInitMode(), and IO_PORTS_8. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canMsgTransmit | +( | +UNS16 | +adrCAN, | +|
+ | + | Message | +msg | + |
+ | ) | ++ |
+ +
+Definition at line 410 of file canOpenDriver.c. +
+References CANTBSEL, CANTFLG, CANTRSDTA, CANTRSID, CANTRSLEN, CANTRSPRI, Message::cob_id, Message::data, IO_PORTS_8, Message::len, MSG_WAR, Message::rtr, UNS8, and SHORT_CAN::w. +
+Referenced by canSend(). +
char canSetInterrupt | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 445 of file canOpenDriver.c. +
+References CANRIER, CANTIER, and IO_PORTS_8. +
+Referenced by canChangeFilter(), and canInit(). +
char canSleepMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 452 of file canOpenDriver.c. +
+References CANCTL0, canTestSleepMode(), and IO_PORTS_8. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canSleepModeQ | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 466 of file canOpenDriver.c. +
+References CANCTL0, canTestInitMode(), canTestSleepMode(), IO_PORTS_8, and MSG_WAR. +
+Referenced by canChangeFilter(), and canInit(). +
+Here is the call graph for this function:
char canSleepWupMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 480 of file canOpenDriver.c. +
+References CANCTL0, canTestInitMode(), canTestSleepMode(), IO_PORTS_8, and MSG_WAR. +
+Here is the call graph for this function:
char canTestInitMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 493 of file canOpenDriver.c. +
+References CANCTL1, and IO_PORTS_8. +
+Referenced by canAddIdToFilter(), canChangeFilter(), canInit(), canInit1Filter(), canInitClock(), canInitFilter(), canInitMode(), canInitModeQ(), canSleepModeQ(), and canSleepWupMode(). +
char canTestSleepMode | +( | +UNS16 | +adrCAN | +) | ++ |
+ +
+Definition at line 499 of file canOpenDriver.c. +
+References CANCTL1, and IO_PORTS_8. +
+Referenced by canSleepMode(), canSleepModeQ(), and canSleepWupMode(). +
+
canBusInit bi | +
+ +
volatile t_pointerStack ptrMsgRcv[NB_LINE_CAN] | +
+ +
volatile Message stackMsgRcv[NB_LINE_CAN][MAX_STACK_MSG_RCV] | +
+ +
+
00001 /* canmsg.h - common kernel-space and user-space CAN message structure +00002 * Linux CAN-bus device driver. +00003 * Written by Pavel Pisa - OCERA team member +00004 * email:pisa@cmp.felk.cvut.cz +00005 * This software is released under the GPL-License. +00006 * Version lincan-0.3 17 Jun 2004 +00007 */ +00008 +00009 #ifndef _CANMSG_T_H +00010 #define _CANMSG_T_H +00011 +00012 #ifdef __KERNEL__ +00013 +00014 #include <linux/time.h> +00015 #include <linux/types.h> +00016 +00017 #else /* __KERNEL__ */ +00018 +00019 #include <sys/time.h> +00020 #include <sys/types.h> +00021 +00022 #endif /* __KERNEL__ */ +00023 +00024 #ifdef __cplusplus +00025 extern "C" { +00026 #endif +00027 +00028 /* +00029 * CAN_MSG_VERSION_2 enables new canmsg_t layout compatible with +00030 * can4linux project from http://www.port.de/ +00031 * +00032 */ +00033 #define CAN_MSG_VERSION_2 +00034 +00035 /* Number of data bytes in one CAN message */ +00036 #define CAN_MSG_LENGTH 8 +00037 +00038 #ifdef CAN_MSG_VERSION_2 +00039 +00040 typedef struct timeval canmsg_tstamp_t ; +00041 +00042 typedef unsigned long canmsg_id_t; +00043 +00059 struct canmsg_t { +00060 int flags; +00061 int cob; +00062 canmsg_id_t id; +00063 canmsg_tstamp_t timestamp; +00064 unsigned short length; +00065 unsigned char data[CAN_MSG_LENGTH]; +00066 }; +00067 +00068 #else /*CAN_MSG_VERSION_2*/ +00069 #ifndef PACKED +00070 #define PACKED __attribute__((packed)) +00071 #endif +00072 /* Old, deprecated version of canmsg_t structure */ +00073 struct canmsg_t { +00074 short flags; +00075 int cob; +00076 canmsg_id_t id; +00077 unsigned long timestamp; +00078 unsigned int length; +00079 unsigned char data[CAN_MSG_LENGTH]; +00080 } PACKED; +00081 #endif /*CAN_MSG_VERSION_2*/ +00082 +00083 typedef struct canmsg_t canmsg_t; +00084 +00105 struct canfilt_t { +00106 int flags; +00107 int queid; +00108 int cob; +00109 canmsg_id_t id; +00110 canmsg_id_t mask; +00111 }; +00112 +00113 typedef struct canfilt_t canfilt_t; +00114 +00115 /* Definitions to use for canmsg_t and canfilt_t flags */ +00116 #define MSG_RTR (1<<0) +00117 #define MSG_OVR (1<<1) +00118 #define MSG_EXT (1<<2) +00119 #define MSG_LOCAL (1<<3) +00120 /* If you change above lines, check canque_filtid2internal function */ +00121 +00122 /* Additional definitions used for canfilt_t only */ +00123 #define MSG_FILT_MASK_SHIFT 8 +00124 #define MSG_RTR_MASK (MSG_RTR<<MSG_FILT_MASK_SHIFT) +00125 #define MSG_EXT_MASK (MSG_EXT<<MSG_FILT_MASK_SHIFT) +00126 #define MSG_LOCAL_MASK (MSG_LOCAL<<MSG_FILT_MASK_SHIFT) +00127 #define MSG_PROCESSLOCAL (MSG_OVR<<MSG_FILT_MASK_SHIFT) +00128 +00129 /* Can message ID mask */ +00130 #define MSG_ID_MASK ((1l<<29)-1) +00131 +00132 #ifdef __cplusplus +00133 } /* extern "C"*/ +00134 #endif +00135 +00136 #endif /*_CANMSG_T_H*/ +
#include <sys/time.h>
#include <sys/types.h>
+Include dependency graph for canmsg.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Data Structures | |
struct | canmsg_t |
struct | canfilt_t |
Defines | |
#define | CAN_MSG_VERSION_2 |
#define | CAN_MSG_LENGTH 8 |
#define | MSG_RTR (1<<0) |
#define | MSG_OVR (1<<1) |
#define | MSG_EXT (1<<2) |
#define | MSG_LOCAL (1<<3) |
#define | MSG_FILT_MASK_SHIFT 8 |
#define | MSG_RTR_MASK (MSG_RTR<<MSG_FILT_MASK_SHIFT) |
#define | MSG_EXT_MASK (MSG_EXT<<MSG_FILT_MASK_SHIFT) |
#define | MSG_LOCAL_MASK (MSG_LOCAL<<MSG_FILT_MASK_SHIFT) |
#define | MSG_PROCESSLOCAL (MSG_OVR<<MSG_FILT_MASK_SHIFT) |
#define | MSG_ID_MASK ((1l<<29)-1) |
Typedefs | |
typedef timeval | canmsg_tstamp_t |
typedef unsigned long | canmsg_id_t |
typedef canmsg_t | canmsg_t |
typedef canfilt_t | canfilt_t |
#define MSG_EXT (1<<2) | +
+ +
+Definition at line 118 of file canmsg.h. +
+Referenced by canReceive_driver(), and canSend_driver(). +
#define MSG_EXT_MASK (MSG_EXT<<MSG_FILT_MASK_SHIFT) | +
#define MSG_ID_MASK ((1l<<29)-1) | +
#define MSG_LOCAL_MASK (MSG_LOCAL<<MSG_FILT_MASK_SHIFT) | +
#define MSG_PROCESSLOCAL (MSG_OVR<<MSG_FILT_MASK_SHIFT) | +
#define MSG_RTR (1<<0) | +
+ +
+Definition at line 116 of file canmsg.h. +
+Referenced by canReceive_driver(), and canSend_driver(). +
#define MSG_RTR_MASK (MSG_RTR<<MSG_FILT_MASK_SHIFT) | +
+
typedef unsigned long canmsg_id_t | +
typedef struct timeval canmsg_tstamp_t | +
+
Public Member Functions | |
can_uvccm_win32 (s_BOARD *board) | |
~can_uvccm_win32 () | |
bool | send (const Message *m) |
bool | receive (Message *m) |
Private Member Functions | |
bool | open_rs232 (int port=1, int baud_rate=57600) |
bool | close_rs232 () |
bool | get_can_data (const char *can_cmd_buf, long &bufsize, Message *m) |
bool | set_can_data (const Message &m, std::string &can_cmd) |
Private Attributes | |
HANDLE | m_port |
HANDLE | m_read_event |
HANDLE | m_write_event |
std::string | m_residual_buffer |
Data Structures | |
class | error |
+ +
+Definition at line 17 of file can_uvccm_win32.cpp.
can_uvccm_win32::can_uvccm_win32 | +( | +s_BOARD * | +board | +) | ++ |
+ +
+Definition at line 39 of file can_uvccm_win32.cpp. +
+References struct_s_BOARD::baudrate, and open_rs232(). +
+Here is the call graph for this function:
can_uvccm_win32::~can_uvccm_win32 | +( | ++ | ) | ++ |
+ +
+Definition at line 47 of file can_uvccm_win32.cpp. +
+References close_rs232(). +
+Here is the call graph for this function:
+
bool can_uvccm_win32::send | +( | +const Message * | +m | +) | ++ |
+ +
+Definition at line 52 of file can_uvccm_win32.cpp. +
+References FALSE, m_port, m_write_event, and set_can_data(). +
+Here is the call graph for this function:
bool can_uvccm_win32::receive | +( | +Message * | +m | +) | ++ |
+ +
+Definition at line 80 of file can_uvccm_win32.cpp. +
+References FALSE, get_can_data(), m_port, m_read_event, and m_residual_buffer. +
+Here is the call graph for this function:
bool can_uvccm_win32::open_rs232 | +( | +int | + port = 1 , |
+ |
+ | + | int | + baud_rate = 57600 | + |
+ | ) | + [private] |
+
+ +
+Definition at line 136 of file can_uvccm_win32.cpp. +
+References FALSE, m_port, m_read_event, m_write_event, and TRUE. +
+Referenced by can_uvccm_win32(). +
bool can_uvccm_win32::close_rs232 | +( | ++ | ) | + [private] |
+
+ +
+Definition at line 190 of file can_uvccm_win32.cpp. +
+References m_port, m_read_event, m_residual_buffer, and m_write_event. +
+Referenced by ~can_uvccm_win32(). +
bool can_uvccm_win32::get_can_data | +( | +const char * | +can_cmd_buf, | +|
+ | + | long & | +bufsize, | +|
+ | + | Message * | +m | + |
+ | ) | + [private] |
+
+ +
+Definition at line 206 of file can_uvccm_win32.cpp. +
+References Message::cob_id, Message::data, Message::len, Message::rtr, UNS8, and SHORT_CAN::w. +
+Referenced by receive(). +
bool can_uvccm_win32::set_can_data | +( | +const Message & | +m, | +|
+ | + | std::string & | +can_cmd | + |
+ | ) | + [private] |
+
+ +
+Definition at line 271 of file can_uvccm_win32.cpp. +
+References Message::cob_id, Message::data, Message::len, Message::rtr, and SHORT_CAN::w. +
+Referenced by send(). +
+
HANDLE can_uvccm_win32::m_port [private] |
+
+ +
+Definition at line 33 of file can_uvccm_win32.cpp. +
+Referenced by close_rs232(), open_rs232(), receive(), and send(). +
HANDLE can_uvccm_win32::m_read_event [private] |
+
+ +
+Definition at line 34 of file can_uvccm_win32.cpp. +
+Referenced by close_rs232(), open_rs232(), and receive(). +
HANDLE can_uvccm_win32::m_write_event [private] |
+
+ +
+Definition at line 35 of file can_uvccm_win32.cpp. +
+Referenced by close_rs232(), open_rs232(), and send(). +
std::string can_uvccm_win32::m_residual_buffer [private] |
+
+ +
+Definition at line 36 of file can_uvccm_win32.cpp. +
+Referenced by close_rs232(), and receive(). +
+
+ +
+Definition at line 20 of file can_uvccm_win32.cpp.
Public Member Functions | |
ccritical_section () | |
~ccritical_section () | |
void | enter () |
void | leave () |
Private Attributes | |
CRITICAL_SECTION | m_cs |
+ +
+Definition at line 38 of file timers_win32.cpp.
ccritical_section::ccritical_section | +( | ++ | ) | + [inline] |
+
ccritical_section::~ccritical_section | +( | ++ | ) | + [inline] |
+
+
void ccritical_section::enter | +( | ++ | ) | + [inline] |
+
+ +
+Definition at line 49 of file timers_win32.cpp. +
+References m_cs. +
+Referenced by EnterMutex(). +
void ccritical_section::leave | +( | ++ | ) | + [inline] |
+
+ +
+Definition at line 53 of file timers_win32.cpp. +
+References m_cs. +
+Referenced by LeaveMutex(). +
+
CRITICAL_SECTION ccritical_section::m_cs [private] |
+
+ +
+Definition at line 58 of file timers_win32.cpp. +
+Referenced by ccritical_section(), enter(), leave(), and ~ccritical_section(). +
+
Public Member Functions | |
class_timers () | |
~class_timers () | |
void | start_timer_thread () |
void | resume_timer_thread () |
void | stop_timer_thread () |
void | set_timer (TIMEVAL value) |
TIMEVAL | get_elapsed_time () |
Private Member Functions | |
TIMEVAL | get_timer () const |
Static Private Member Functions | |
static DWORD WINAPI | timer_loop_thread_proc (void *arg) |
Private Attributes | |
TIMEVAL | m_last_occured_alarm_time |
volatile TIMEVAL | m_last_alarm_set_time |
HANDLE | m_timer_thread |
volatile bool | m_continue_timer_loop |
bool | m_use_hi_res_timer |
double | m_counts_per_usec |
+ +
+Definition at line 94 of file timers_win32.cpp.
class_timers::class_timers | +( | ++ | ) | ++ |
+ +
+Definition at line 116 of file timers_win32.cpp. +
+References m_counts_per_usec, and m_use_hi_res_timer. +
class_timers::~class_timers | +( | ++ | ) | ++ |
+ +
+Definition at line 133 of file timers_win32.cpp. +
+References stop_timer_thread(). +
+Here is the call graph for this function:
+
void class_timers::start_timer_thread | +( | ++ | ) | ++ |
+ +
+Definition at line 173 of file timers_win32.cpp. +
+References get_timer(), m_last_alarm_set_time, m_last_occured_alarm_time, m_timer_thread, timer_loop_thread_proc(), and TIMEVAL_MAX. +
+Referenced by StartTimerLoop(). +
+Here is the call graph for this function:
void class_timers::resume_timer_thread | +( | ++ | ) | ++ |
+ +
+Definition at line 184 of file timers_win32.cpp. +
+References m_continue_timer_loop, and m_timer_thread. +
+Referenced by StartTimerLoop(). +
void class_timers::stop_timer_thread | +( | ++ | ) | ++ |
+ +
+Definition at line 193 of file timers_win32.cpp. +
+References m_continue_timer_loop, and m_timer_thread. +
+Referenced by StopTimerLoop(), and ~class_timers(). +
void class_timers::set_timer | +( | +TIMEVAL | +value | +) | ++ |
+ +
+Definition at line 204 of file timers_win32.cpp. +
+References get_timer(), m_last_alarm_set_time, and TIMEVAL_MAX. +
+Referenced by setTimer(). +
+Here is the call graph for this function:
TIMEVAL class_timers::get_elapsed_time | +( | ++ | ) | ++ |
+ +
+Definition at line 210 of file timers_win32.cpp. +
+References get_timer(), and m_last_occured_alarm_time. +
+Referenced by getElapsedTime(). +
+Here is the call graph for this function:
TIMEVAL class_timers::get_timer | +( | ++ | ) | + const [private] |
+
+ +
+Definition at line 139 of file timers_win32.cpp. +
+References m_counts_per_usec, m_use_hi_res_timer, and TIMEVAL. +
+Referenced by get_elapsed_time(), set_timer(), start_timer_thread(), and timer_loop_thread_proc(). +
DWORD WINAPI class_timers::timer_loop_thread_proc | +( | +void * | +arg | +) | + [static, private] |
+
+ +
+Definition at line 151 of file timers_win32.cpp. +
+References EnterMutex(), get_timer(), LeaveMutex(), m_continue_timer_loop, m_last_alarm_set_time, m_last_occured_alarm_time, TimeDispatch(), TIMEVAL, and TIMEVAL_MAX. +
+Referenced by start_timer_thread(). +
+Here is the call graph for this function:
+
TIMEVAL class_timers::m_last_occured_alarm_time [private] |
+
+ +
+Definition at line 108 of file timers_win32.cpp. +
+Referenced by get_elapsed_time(), start_timer_thread(), and timer_loop_thread_proc(). +
volatile TIMEVAL class_timers::m_last_alarm_set_time [private] |
+
+ +
+Definition at line 109 of file timers_win32.cpp. +
+Referenced by set_timer(), start_timer_thread(), and timer_loop_thread_proc(). +
HANDLE class_timers::m_timer_thread [private] |
+
+ +
+Definition at line 110 of file timers_win32.cpp. +
+Referenced by resume_timer_thread(), start_timer_thread(), and stop_timer_thread(). +
volatile bool class_timers::m_continue_timer_loop [private] |
+
+ +
+Definition at line 111 of file timers_win32.cpp. +
+Referenced by resume_timer_thread(), stop_timer_thread(), and timer_loop_thread_proc(). +
bool class_timers::m_use_hi_res_timer [private] |
+
+ +
+Definition at line 112 of file timers_win32.cpp. +
+Referenced by class_timers(), and get_timer(). +
double class_timers::m_counts_per_usec [private] |
+
+ +
+Definition at line 113 of file timers_win32.cpp. +
+Referenced by class_timers(), and get_timer(). +
+
Public Member Functions | |
driver_procs () | |
~driver_procs () | |
HMODULE | load_canfestival_driver (LPCTSTR driver_name) |
bool | can_driver_valid () const |
Data Fields | |
CANRECEIVE_DRIVER_PROC | m_canReceive |
CANSEND_DRIVER_PROC | m_canSend |
CANOPEN_DRIVER_PROC | m_canOpen |
CANCLOSE_DRIVER_PROC | m_canClose |
HMODULE | m_driver_handle |
+ +
+Definition at line 46 of file drivers_win32.cpp.
driver_procs::driver_procs | +( | ++ | ) | ++ |
+ +
+Definition at line 66 of file drivers_win32.cpp. +
driver_procs::~driver_procs | +( | ++ | ) | ++ |
+
HMODULE driver_procs::load_canfestival_driver | +( | +LPCTSTR | +driver_name | +) | ++ |
+ +
+Definition at line 94 of file drivers_win32.cpp. +
+References can_driver_valid(), m_canClose, m_canOpen, m_canReceive, m_canSend, m_driver_handle, and myTEXT. +
+Referenced by LoadCanDriver(). +
+Here is the call graph for this function:
bool driver_procs::can_driver_valid | +( | ++ | ) | +const | +
+ +
+Definition at line 79 of file drivers_win32.cpp. +
+References m_canClose, m_canOpen, m_canReceive, and m_canSend. +
+Referenced by load_canfestival_driver(). +
+
CANRECEIVE_DRIVER_PROC driver_procs::m_canReceive | +
+ +
+Definition at line 57 of file drivers_win32.cpp. +
+Referenced by can_driver_valid(), canReceive(), and load_canfestival_driver(). +
CANSEND_DRIVER_PROC driver_procs::m_canSend | +
+ +
+Definition at line 58 of file drivers_win32.cpp. +
+Referenced by can_driver_valid(), canSend(), and load_canfestival_driver(). +
CANOPEN_DRIVER_PROC driver_procs::m_canOpen | +
+ +
+Definition at line 59 of file drivers_win32.cpp. +
+Referenced by can_driver_valid(), canOpen(), and load_canfestival_driver(). +
CANCLOSE_DRIVER_PROC driver_procs::m_canClose | +
+ +
+Definition at line 60 of file drivers_win32.cpp. +
+Referenced by can_driver_valid(), canClose(), and load_canfestival_driver(). +
HMODULE driver_procs::m_driver_handle | +
+ +
+Definition at line 63 of file drivers_win32.cpp. +
+Referenced by load_canfestival_driver(), and ~driver_procs(). +
+
00001 /* !!!!!!!!!! FILE GENERATED by configure. DO NOT EDIT !!!!!!!!!!*/ +00002 +00003 /* +00004 This file is part of CanFestival, a library implementing CanOpen Stack. +00005 +00006 Copyright (C): Edouard TISSERANT and Francis DUPIN +00007 See COPYING file for copyrights details. +00008 +00009 This library is free software; you can redistribute it and/or +00010 modify it under the terms of the GNU Lesser General Public +00011 License as published by the Free Software Foundation; either +00012 version 2.1 of the License, or (at your option) any later version. +00013 +00014 This library is distributed in the hope that it will be useful, +00015 but WITHOUT ANY WARRANTY; without even the implied warranty of +00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00017 Lesser General Public License for more details. +00018 +00019 You should have received a copy of the GNU Lesser General Public +00020 License along with this library; if not, write to the Free Software +00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00022 */ +00023 +00024 #ifndef _CONFIG_H_ +00025 #define _CONFIG_H_ +00026 +00027 #define MAX_CAN_BUS_ID 1 +00028 #define SDO_MAX_LENGTH_TRANSFERT 32 +00029 #define SDO_MAX_SIMULTANEOUS_TRANSFERTS 4 +00030 #define NMT_MAX_NODE_ID 128 +00031 #define SDO_TIMEOUT_MS 3000 +00032 #define MAX_NB_TIMER 32 +00033 /* CANOPEN_BIG_ENDIAN is not defined */ +00034 /* US_TO_TIMEVAL_FACTOR is not defined */ +00035 /* TIMEVAL is not defined */ +00036 /* TIMEVAL_MAX is not defined */ +00037 /* RTCAN_SOCKET is not defined */ +00038 +00039 #define REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(repeat)\ +00040 repeat repeat repeat repeat +00041 #define REPEAT_NMT_MAX_NODE_ID_TIMES(repeat)\ +00042 repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat +00043 #endif /* _CONFIG_H_ */ +
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Defines | |
#define | MAX_CAN_BUS_ID 1 |
#define | SDO_MAX_LENGTH_TRANSFERT 32 |
#define | SDO_MAX_SIMULTANEOUS_TRANSFERTS 4 |
#define | NMT_MAX_NODE_ID 128 |
#define | SDO_TIMEOUT_MS 3000 |
#define | MAX_NB_TIMER 32 |
#define | REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(repeat) repeat repeat repeat repeat |
#define | REPEAT_NMT_MAX_NODE_ID_TIMES(repeat) repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat |
#define MAX_NB_TIMER 32 | +
#define NMT_MAX_NODE_ID 128 | +
#define REPEAT_NMT_MAX_NODE_ID_TIMES | +( | +repeat | ++ | ) | +repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat repeat | +
#define REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES | +( | +repeat | ++ | ) | +repeat repeat repeat repeat | +
#define SDO_MAX_LENGTH_TRANSFERT 32 | +
+ +
+Definition at line 28 of file config.h. +
+Referenced by lineToSDO(), resetSDOline(), SDOtoLine(), and setSDOlineRestBytes(). +
#define SDO_MAX_SIMULTANEOUS_TRANSFERTS 4 | +
+ +
+Definition at line 29 of file config.h. +
+Referenced by getSDOfreeLine(), getSDOlineOnUse(), and resetSDO(). +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 +00024 #ifndef __data_h__ +00025 #define __data_h__ +00026 +00027 /* declaration of CO_Data type let us include all necessary headers +00028 struct struct_CO_Data can then be defined later +00029 */ +00030 typedef struct struct_CO_Data CO_Data; +00031 +00032 #include "applicfg.h" +00033 #include "def.h" +00034 #include "can.h" +00035 #include "objdictdef.h" +00036 #include "objacces.h" +00037 #include "sdo.h" +00038 #include "pdo.h" +00039 #include "states.h" +00040 #include "lifegrd.h" +00041 #include "sync.h" +00042 #include "nmtMaster.h" +00043 +00044 /* This structurs contains all necessary information for a CanOpen node */ +00045 struct struct_CO_Data { +00046 /* Object dictionary */ +00047 UNS8 *bDeviceNodeId; +00048 const indextable *objdict; +00049 UNS8 *count_sync; +00050 quick_index *firstIndex; +00051 quick_index *lastIndex; +00052 UNS16 *ObjdictSize; +00053 const UNS8 *iam_a_slave; +00054 valueRangeTest_t valueRangeTest; +00055 +00056 /* SDO */ +00057 s_transfer transfers[SDO_MAX_SIMULTANEOUS_TRANSFERTS]; +00058 /* s_sdo_parameter *sdo_parameters; */ +00059 +00060 /* State machine */ +00061 e_nodeState nodeState; +00062 s_state_communication CurrentCommunicationState; +00063 initialisation_t initialisation; +00064 preOperational_t preOperational; +00065 operational_t operational; +00066 stopped_t stopped; +00067 +00068 /* NMT-heartbeat */ +00069 UNS8 *ConsumerHeartbeatCount; +00070 UNS32 *ConsumerHeartbeatEntries; +00071 TIMER_HANDLE *ConsumerHeartBeatTimers; +00072 UNS16 *ProducerHeartBeatTime; +00073 TIMER_HANDLE ProducerHeartBeatTimer; +00074 heartbeatError_t heartbeatError; +00075 e_nodeState NMTable[NMT_MAX_NODE_ID]; +00076 +00077 /* SYNC */ +00078 TIMER_HANDLE syncTimer; +00079 UNS32 *COB_ID_Sync; +00080 UNS32 *Sync_Cycle_Period; +00081 /*UNS32 *Sync_window_length;;*/ +00082 post_sync_t post_sync; +00083 post_TPDO_t post_TPDO; +00084 +00085 /* PDO */ +00086 s_process_var process_var; +00087 +00088 /* General */ +00089 UNS8 toggle; +00090 CAN_HANDLE canHandle; +00091 scanIndexOD_t scanIndexOD; +00092 storeODSubIndex_t storeODSubIndex; +00093 +00094 /* DCF concise */ +00095 UNS8* dcf_cursor; +00096 UNS32 dcf_count_targets; +00097 +00098 }; +00099 +00100 #define NMTable_Initializer Unknown_state, +00101 +00102 #define s_transfer_Initializer {\ +00103 0, /* nodeId */\ +00104 0, /* wohami */\ +00105 SDO_RESET, /* state */\ +00106 0, /* toggle */\ +00107 0, /* abortCode */\ +00108 0, /* index */\ +00109 0, /* subIndex */\ +00110 0, /* count */\ +00111 0, /* offset */\ +00112 {0}, /* data (static use, so that all the table is initialize at 0)*/\ +00113 0, /* dataType */\ +00114 -1, /* timer */\ +00115 NULL /* Callback */\ +00116 }, +00117 +00118 /* A macro to initialize the data in client app.*/ +00119 /* CO_Data structure */ +00120 #define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX) {\ +00121 /* Object dictionary*/\ +00122 & NODE_PREFIX ## _bDeviceNodeId, /* bDeviceNodeId */\ +00123 NODE_PREFIX ## _objdict, /* objdict */\ +00124 NODE_PREFIX ## _count_sync, /* count_sync */\ +00125 & NODE_PREFIX ## _firstIndex, /* firstIndex */\ +00126 & NODE_PREFIX ## _lastIndex, /* lastIndex */\ +00127 & NODE_PREFIX ## _ObjdictSize, /* ObjdictSize */\ +00128 & NODE_PREFIX ## _iam_a_slave, /* iam_a_slave */\ +00129 NODE_PREFIX ## _valueRangeTest, /* valueRangeTest */\ +00130 \ +00131 /* SDO, structure s_transfer */\ +00132 {\ +00133 REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(s_transfer_Initializer)\ +00134 },\ +00135 \ +00136 /* State machine*/\ +00137 Unknown_state, /* nodeState */\ +00138 /* structure s_state_communication */\ +00139 {\ +00140 0, /* csBoot_Up */\ +00141 0, /* csSDO */\ +00142 0, /* csEmergency */\ +00143 0, /* csSYNC */\ +00144 0, /* csHeartbeat */\ +00145 0 /* csPDO */\ +00146 },\ +00147 _initialisation, /* initialisation */\ +00148 _preOperational, /* preOperational */\ +00149 _operational, /* operational */\ +00150 _stopped, /* stopped */\ +00151 \ +00152 /* NMT-heartbeat */\ +00153 & NODE_PREFIX ## _highestSubIndex_obj1016, /* ConsumerHeartbeatCount */\ +00154 NODE_PREFIX ## _obj1016, /* ConsumerHeartbeatEntries */\ +00155 NODE_PREFIX ## _heartBeatTimers, /* ConsumerHeartBeatTimers */\ +00156 & NODE_PREFIX ## _obj1017, /* ProducerHeartBeatTime */\ +00157 TIMER_NONE, /* ProducerHeartBeatTimer */\ +00158 _heartbeatError, /* heartbeatError */\ +00159 \ +00160 {REPEAT_NMT_MAX_NODE_ID_TIMES(NMTable_Initializer)},\ +00161 /* is well initialized at "Unknown_state". Is it ok ? (FD)*/\ +00162 \ +00163 /* SYNC */\ +00164 TIMER_NONE, /* syncTimer */\ +00165 & NODE_PREFIX ## _obj1005, /* COB_ID_Sync */\ +00166 & NODE_PREFIX ## _obj1006, /* Sync_Cycle_Period */\ +00167 /*& NODE_PREFIX ## _obj1007, */ /* Sync_window_length */\ +00168 _post_sync, /* post_sync */\ +00169 _post_TPDO, /* post_TPDO */\ +00170 \ +00171 /* PDO, structure s_process_var */\ +00172 {\ +00173 0, /* count */\ +00174 {0} /* data (static use, so that all the table is initialize at 0)*/\ +00175 },\ +00176 \ +00177 /* General */\ +00178 0, /* toggle */\ +00179 NULL, /* canSend */\ +00180 NODE_PREFIX ## _scanIndexOD, /* scanIndexOD */\ +00181 _storeODSubIndex, /* storeODSubIndex */\ +00182 NULL, /*dcf_cursor*/\ +00183 1 /*dcf_count_targets*/\ +00184 } +00185 +00186 #endif /* __data_h__ */ +00187 +00188 +
#include "applicfg.h"
#include "def.h"
#include "can.h"
#include "objdictdef.h"
#include "objacces.h"
#include "sdo.h"
#include "pdo.h"
#include "states.h"
#include "lifegrd.h"
#include "sync.h"
#include "nmtMaster.h"
+Include dependency graph for data.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Data Structures | |
struct | struct_CO_Data |
Typedefs | |
typedef struct_CO_Data | CO_Data |
typedef struct struct_CO_Data CO_Data | +
+
00001 /* + +dcf.c
Go to the documentation of this file.00001 /* 00002 This file is part of CanFestival, a library implementing CanOpen 00003 Stack. 00004 @@ -40,91 +44,97 @@ 00023 */ 00024 00025 -00035 #include "objacces.h" -00036 #include "sdo.h" -00037 #include "dcf.h" -00038 #include "sysdep.h" -00039 -00040 -00054 extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, -00055 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize); +00037 #include "objacces.h" +00038 #include "sdo.h" +00039 #include "dcf.h" +00040 #include "sysdep.h" +00041 +00042 extern UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, +00043 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize); +00044 +00045 const indextable *ptrTable; +00046 +00053 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId) +00054 { +00055 UNS32 abortCode; 00056 -00057 const indextable *ptrTable; -00058 -00065 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId) -00066 { -00067 UNS32 abortCode; -00068 -00069 if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED) -00070 { -00071 MSG_ERR(0x1A01, "SDO error in consise DCF", abortCode); -00072 MSG_WAR(0x2A02, "server node : ", nodeId); -00073 } -00074 -00075 closeSDOtransfer(d, nodeId, SDO_CLIENT); -00076 decompo_dcf(d,nodeId); -00077 } -00078 -00087 UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId) -00088 { -00089 UNS32 errorCode; -00090 UNS16 target_Index; -00091 UNS8 target_Subindex; -00092 UNS32 target_Size; -00093 UNS32 res; -00094 ODCallback_t *Callback; -00095 -00096 ptrTable = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback); -00097 if (errorCode != OD_SUCCESSFUL) -00098 { -00099 return errorCode; -00100 } -00101 -00103 while (nodeId < ptrTable->bSubCount){ -00104 UNS32 nb_targets; -00105 -00106 UNS8 szData = ptrTable->pSubindex[nodeId].size; -00107 UNS8* dcfend; -00108 -00109 { -00110 UNS8* dcf = *((UNS8**)ptrTable->pSubindex[nodeId].pObject); -00111 dcfend = dcf + szData; -00112 if (!d->dcf_cursor){ -00113 d->dcf_cursor = (UNS8*)dcf + 4; -00114 d->dcf_count_targets = 0; -00115 } -00116 nb_targets = UNS32_LE(*((UNS32*)dcf)); -00117 } -00118 -00120 if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_count_targets < nb_targets) -00121 { -00123 target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2; -00124 target_Subindex = *((UNS8*)(((UNS8*)d->dcf_cursor)++)); -00125 target_Size = UNS32_LE(*((UNS32*)(d->dcf_cursor))); d->dcf_cursor += 4; -00126 -00127 /* printf("Master : ConfigureSlaveNode %2.2x (Concise -00128 DCF)\n",nodeId);*/ -00129 res = _writeNetworkDict(d, -00130 nodeId, -00131 target_Index, -00132 target_Subindex, -00133 target_Size, -00134 0, -00135 d->dcf_cursor, -00136 CheckSDOAndContinue, -00138 0); -00141 d->dcf_cursor += target_Size; -00142 d->dcf_count_targets++; -00143 -00144 return ; -00145 } -00146 nodeId++; -00147 d->dcf_cursor = NULL; -00148 } -00150 (*d->preOperational)(); -00151 -00152 } -
Generated on Tue Jun 5 18:32:05 2007 for CanFestival by +00057 if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED) +00058 { +00059 MSG_ERR(0x1A01, "SDO error in consise DCF", abortCode); +00060 MSG_WAR(0x2A02, "server node : ", nodeId); +00061 } +00062 +00063 closeSDOtransfer(d, nodeId, SDO_CLIENT); +00064 decompo_dcf(d,nodeId); +00065 } +00066 +00075 UNS32 decompo_dcf(CO_Data* d,UNS8 nodeId) +00076 { +00077 UNS32 errorCode; +00078 UNS16 target_Index; +00079 UNS8 target_Subindex; +00080 UNS32 target_Size; +00081 UNS32 res; +00082 ODCallback_t *Callback; +00083 +00084 ptrTable = (*d->scanIndexOD)(0x1F22, &errorCode, &Callback); +00085 if (errorCode != OD_SUCCESSFUL) +00086 { +00087 return errorCode; +00088 } +00089 +00090 /* Loop on all Nodes supported in DCF subindexes*/ +00091 while (nodeId < ptrTable->bSubCount){ +00092 UNS32 nb_targets; +00093 +00094 UNS8 szData = ptrTable->pSubindex[nodeId].size; +00095 UNS8* dcfend; +00096 +00097 { +00098 UNS8* dcf = *((UNS8**)ptrTable->pSubindex[nodeId].pObject); +00099 dcfend = dcf + szData; +00100 if (!d->dcf_cursor){ +00101 d->dcf_cursor = (UNS8*)dcf + 4; +00102 d->dcf_count_targets = 0; +00103 } +00104 nb_targets = UNS32_LE(*((UNS32*)dcf)); +00105 } +00106 +00107 /* condition on consise DCF string for NodeID, if big enough */ +00108 if((UNS8*)d->dcf_cursor + 7 < (UNS8*)dcfend && d->dcf_count_targets < nb_targets) +00109 { +00110 /* pointer to the DCF string for NodeID */ +00111 target_Index = UNS16_LE(*((UNS16*)(d->dcf_cursor))); d->dcf_cursor += 2; +00112 target_Subindex = *((UNS8*)(((UNS8*)d->dcf_cursor)++)); +00113 target_Size = UNS32_LE(*((UNS32*)(d->dcf_cursor))); d->dcf_cursor += 4; +00114 +00115 /* printf("Master : ConfigureSlaveNode %2.2x (Concise +00116 DCF)\n",nodeId);*/ +00117 res = _writeNetworkDict(d, /* CO_Data* d*/ +00118 nodeId, /* UNS8 nodeId*/ +00119 target_Index, /* UNS16 index*/ +00120 target_Subindex, /* UNS8 subindex*/ +00121 target_Size, /* UNS8 count*/ +00122 0, /* UNS8 dataType*/ +00123 d->dcf_cursor,/* void *data*/ +00124 CheckSDOAndContinue,/* SDOCallback_t +00125 Callback*/ +00126 0); /* no endianize*/ +00127 /* Push d->dcf_cursor to the end of data*/ +00128 +00129 d->dcf_cursor += target_Size; +00130 d->dcf_count_targets++; +00131 +00132 return ; +00133 } +00134 nodeId++; +00135 d->dcf_cursor = NULL; +00136 } +00137 /* Switch Master to preOperational state */ +00138 (*d->preOperational)(); +00139 +00140 } +
-#include "objacces.h"
-#include "sdo.h"
-#include "dcf.h"
-#include "sysdep.h"
-
-
-Include dependency graph for dcf.c:
+#include "objacces.h"
+#include "sdo.h"
+#include "dcf.h"
+#include "sysdep.h"
+
+
+Include dependency graph for dcf.c:
Go to the source code of this file.
Functions | |
UNS8 | _writeNetworkDict (CO_Data *d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize) |
UNS32 | decompo_dcf (CO_Data *d, UNS8 nodeId) |
UNS8 | _writeNetworkDict (CO_Data *d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize) |
UNS32 | decompo_dcf (CO_Data *d, UNS8 nodeId) |
Variables | |
const indextable * | ptrTable |
const indextable * | ptrTable |
-Verify that there is no SDO communication yet.
-Taking the line ...
-Check which SDO to use to communicate with the node
-looking for the nodeId server
-Copy data to transfers structure.
-Send the SDO to the server. Initiate download, cs=1.
-Expedited transfert
-Normal transfert
-nb of byte to transmit. Max = 255. (canfestival2 limitation).
-release the line +Normal transfert
Definition at line 1247 of file sdo.c.
-References getSDOfreeLine(), getSDOlineOnUse(), initSDOline(), resetSDOline(), and sendSDO(). -
-Referenced by decompo_dcf(), writeNetworkDict(), and writeNetworkDictCallBack(). +References struct_s_SDO::body, td_indextable::bSubCount, struct_s_transfer::Callback, CANOPEN_BIG_ENDIAN, struct_s_transfer::count, struct_s_timer_entry::d, BODY::data, struct_s_transfer::data, struct_s_transfer::dataType, struct_CO_Data::firstIndex, getSDOfreeLine(), getSDOlineOnUse(), initSDOline(), struct_CO_Data::lastIndex, MSG_ERR, MSG_WAR, struct_s_SDO::nodeId, struct_CO_Data::objdict, struct_s_transfer::offset, td_subindex::pObject, td_indextable::pSubindex, resetSDOline(), SDO_CLIENT, s_quick_index::SDO_CLT, SDO_DOWNLOAD_IN_PROGRESS, sendSDO(), struct_CO_Data::transfers, UNS16, UNS32, and UNS8. +
+Referenced by decompo_dcf(), writeNetworkDict(), and writeNetworkDictCallBack().
Here is the call graph for this function:
-Loop on all Nodes supported in DCF subindexes
-condition on consise DCF string for NodeID, if big enough
-pointer to the DCF string for NodeID
-CO_Data* d
-UNS8 nodeId
-UNS16 index
-UNS8 subindex
-UNS8 count
-UNS8 dataType
-void *data
-SDOCallback_t Callback
-no endianize
-Push d->dcf_cursor to the end of data
-Switch Master to preOperational state -
-Definition at line 87 of file dcf.c. -
-References _writeNetworkDict(), and ptrTable. +Definition at line 75 of file dcf.c. +
+References _writeNetworkDict(), struct_s_timer_entry::d, struct_CO_Data::dcf_count_targets, struct_CO_Data::dcf_cursor, OD_SUCCESSFUL, td_subindex::pObject, struct_CO_Data::preOperational, td_indextable::pSubindex, ptrTable, struct_CO_Data::scanIndexOD, td_subindex::size, UNS16, UNS16_LE, UNS32, UNS32_LE, and UNS8.
Referenced by setState().
@@ -221,6 +222,8 @@ + + @@ -231,7 +234,7 @@
const indextable* ptrTable | +const indextable* ptrTable |
-Definition at line 57 of file dcf.c. -
-Referenced by _getODentry(), _setODentry(), decompo_dcf(), and setState(). +Definition at line 45 of file dcf.c. +
+Referenced by _getODentry(), _setODentry(), decompo_dcf(), and setState().
-
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 +00024 UNS32 decompo_dcf(CO_Data* d, UNS8 nodeId); +
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Functions | |
UNS32 | decompo_dcf (CO_Data *d, UNS8 nodeId) |
UNS32 decompo_dcf | +( | +CO_Data * | +d, | +|
+ | + | UNS8 | +nodeId | + |
+ | ) | ++ |
+
d | ||
nodeId |
+Definition at line 75 of file dcf.c. +
+References _writeNetworkDict(), struct_s_timer_entry::d, struct_CO_Data::dcf_count_targets, struct_CO_Data::dcf_cursor, OD_SUCCESSFUL, td_subindex::pObject, struct_CO_Data::preOperational, td_indextable::pSubindex, ptrTable, struct_CO_Data::scanIndexOD, td_subindex::size, UNS16, UNS16_LE, UNS32, UNS32_LE, and UNS8. +
+Referenced by setState(). +
+Here is the call graph for this function:
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 +00024 #ifndef __def_h__ +00025 #define __def_h__ +00026 +00027 #include "config.h" +00028 +00031 #define OD_SUCCESSFUL 0x00000000 +00032 #define OD_READ_NOT_ALLOWED 0x06010001 +00033 #define OD_WRITE_NOT_ALLOWED 0x06010002 +00034 #define OD_NO_SUCH_OBJECT 0x06020000 +00035 #define OD_NOT_MAPPABLE 0x06040041 +00036 #define OD_LENGTH_DATA_INVALID 0x06070010 +00037 #define OD_NO_SUCH_SUBINDEX 0x06090011 +00038 #define OD_VALUE_TOO_LOW 0x06090031 /* Value range test result */ +00039 #define OD_VALUE_TOO_HIGH 0x06090032 /* Value range test result */ +00040 /* Others SDO abort codes +00041 */ +00042 #define SDOABT_TOGGLE_NOT_ALTERNED 0x05030000 +00043 #define SDOABT_TIMED_OUT 0x05040000 +00044 #define SDOABT_OUT_OF_MEMORY 0x05040005 /* Size data exceed SDO_MAX_LENGTH_TRANSFERT */ +00045 #define SDOABT_GENERAL_ERROR 0x08000000 /* Error size of SDO message */ +00046 #define SDOABT_LOCAL_CTRL_ERROR 0x08000021 +00047 +00048 /******************** CONSTANTS ****************/ +00049 +00053 /* Should not be modified */ +00054 #define REQUEST 1 +00055 #define NOT_A_REQUEST 0 +00056 +00057 /* Misc constants */ +00058 /* -------------- */ +00059 /* Should not be modified */ +00060 #define Rx 0 +00061 #define Tx 1 +00062 #define TRUE 1 +00063 #define FALSE 0 +00064 +00065 /* TODO: remove this limitation. do bit granularity mapping */ +00066 #define PDO_MAX_LEN 8 +00067 +00070 #define SDO_RESET 0x0 /* Transmission not started. Init state. */ +00071 #define SDO_FINISHED 0x1 /* data are available */ +00072 #define SDO_ABORTED_RCV 0x80 /* Received an abort message. Data not available */ +00073 #define SDO_ABORTED_INTERNAL 0x85 /* Aborted but not because of an abort message. */ +00074 #define SDO_DOWNLOAD_IN_PROGRESS 0x2 +00075 #define SDO_UPLOAD_IN_PROGRESS 0x3 +00076 +00077 /* Status of the node during the SDO transfert : */ +00078 #define SDO_SERVER 0x1 +00079 #define SDO_CLIENT 0x2 +00080 #define SDO_UNKNOWN 0x3 +00081 +00082 /* Function Codes +00083 --------------- +00084 defined in the canopen DS301 +00085 */ +00086 #define NMT 0x0 +00087 #define SYNC 0x1 +00088 #define TIME_STAMP 0x2 +00089 #define PDO1tx 0x3 +00090 #define PDO1rx 0x4 +00091 #define PDO2tx 0x5 +00092 #define PDO2rx 0x6 +00093 #define PDO3tx 0x7 +00094 #define PDO3rx 0x8 +00095 #define PDO4tx 0x9 +00096 #define PDO4rx 0xA +00097 #define SDOtx 0xB +00098 #define SDOrx 0xC +00099 #define NODE_GUARD 0xE +00100 +00101 /* NMT Command Specifier, sent by master to change a slave state */ +00102 /* ------------------------------------------------------------- */ +00103 /* Should not be modified */ +00104 #define NMT_Start_Node 0x01 +00105 #define NMT_Stop_Node 0x02 +00106 #define NMT_Enter_PreOperational 0x80 +00107 #define NMT_Reset_Node 0x81 +00108 #define NMT_Reset_Comunication 0x82 +00109 +00110 /* constantes used in the different state machines */ +00111 /* ----------------------------------------------- */ +00112 /* Must not be modified */ +00113 #define state1 0x01 +00114 #define state2 0x02 +00115 #define state3 0x03 +00116 #define state4 0x04 +00117 #define state5 0x05 +00118 #define state6 0x06 +00119 #define state7 0x07 +00120 #define state8 0x08 +00121 #define state9 0x09 +00122 #define state10 0x0A +00123 #define state11 0x0B +00124 +00125 #endif /* __def_h__ */ +00126 +
#include "config.h"
+Include dependency graph for def.h:
+This graph shows which files directly or indirectly include this file:
+Go to the source code of this file.
Defines | |
#define | OD_SUCCESSFUL 0x00000000 |
#define | OD_READ_NOT_ALLOWED 0x06010001 |
#define | OD_WRITE_NOT_ALLOWED 0x06010002 |
#define | OD_NO_SUCH_OBJECT 0x06020000 |
#define | OD_NOT_MAPPABLE 0x06040041 |
#define | OD_LENGTH_DATA_INVALID 0x06070010 |
#define | OD_NO_SUCH_SUBINDEX 0x06090011 |
#define | OD_VALUE_TOO_LOW 0x06090031 |
#define | OD_VALUE_TOO_HIGH 0x06090032 |
#define | SDOABT_TOGGLE_NOT_ALTERNED 0x05030000 |
#define | SDOABT_TIMED_OUT 0x05040000 |
#define | SDOABT_OUT_OF_MEMORY 0x05040005 |
#define | SDOABT_GENERAL_ERROR 0x08000000 |
#define | SDOABT_LOCAL_CTRL_ERROR 0x08000021 |
#define | REQUEST 1 |
#define | NOT_A_REQUEST 0 |
#define | Rx 0 |
#define | Tx 1 |
#define | TRUE 1 |
#define | FALSE 0 |
#define | PDO_MAX_LEN 8 |
#define | SDO_RESET 0x0 |
#define | SDO_FINISHED 0x1 |
#define | SDO_ABORTED_RCV 0x80 |
#define | SDO_ABORTED_INTERNAL 0x85 |
#define | SDO_DOWNLOAD_IN_PROGRESS 0x2 |
#define | SDO_UPLOAD_IN_PROGRESS 0x3 |
#define | SDO_SERVER 0x1 |
#define | SDO_CLIENT 0x2 |
#define | SDO_UNKNOWN 0x3 |
#define | NMT 0x0 |
#define | SYNC 0x1 |
#define | TIME_STAMP 0x2 |
#define | PDO1tx 0x3 |
#define | PDO1rx 0x4 |
#define | PDO2tx 0x5 |
#define | PDO2rx 0x6 |
#define | PDO3tx 0x7 |
#define | PDO3rx 0x8 |
#define | PDO4tx 0x9 |
#define | PDO4rx 0xA |
#define | SDOtx 0xB |
#define | SDOrx 0xC |
#define | NODE_GUARD 0xE |
#define | NMT_Start_Node 0x01 |
#define | NMT_Stop_Node 0x02 |
#define | NMT_Enter_PreOperational 0x80 |
#define | NMT_Reset_Node 0x81 |
#define | NMT_Reset_Comunication 0x82 |
#define | state1 0x01 |
#define | state2 0x02 |
#define | state3 0x03 |
#define | state4 0x04 |
#define | state5 0x05 |
#define | state6 0x06 |
#define | state7 0x07 |
#define | state8 0x08 |
#define | state9 0x09 |
#define | state10 0x0A |
#define | state11 0x0B |
#define FALSE 0 | +
+ +
+Definition at line 63 of file def.h. +
+Referenced by can_uvccm_win32::open_rs232(), can_uvccm_win32::receive(), and can_uvccm_win32::send(). +
#define NMT 0x0 | +
+ +
+Definition at line 86 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define NMT_Enter_PreOperational 0x80 | +
#define NMT_Reset_Comunication 0x82 | +
#define NMT_Reset_Node 0x81 | +
+ +
+Definition at line 107 of file def.h. +
+Referenced by main(), and proceedNMTstateChange(). +
#define NMT_Start_Node 0x01 | +
+ +
+Definition at line 104 of file def.h. +
+Referenced by main(), and proceedNMTstateChange(). +
#define NMT_Stop_Node 0x02 | +
+ +
+Definition at line 105 of file def.h. +
+Referenced by main(), and proceedNMTstateChange(). +
#define NODE_GUARD 0xE | +
+ +
+Definition at line 99 of file def.h. +
+Referenced by canDispatch(), masterSendNMTnodeguard(), print_message(), and slaveSendBootUp(). +
#define NOT_A_REQUEST 0 | +
+ +
+Definition at line 55 of file def.h. +
+Referenced by masterSendNMTstateChange(), PDOmGR(), proceedPDO(), sendPDO(), sendSDO(), sendSYNC(), and slaveSendBootUp(). +
#define OD_LENGTH_DATA_INVALID 0x06070010 | +
+ +
+Definition at line 36 of file def.h. +
+Referenced by _getODentry(), _setODentry(), and accessDictionaryError(). +
#define OD_NO_SUCH_OBJECT 0x06020000 | +
+ +
+Definition at line 34 of file def.h. +
+Referenced by accessDictionaryError(), gene_SYNC_scanIndexOD(), TestMaster_scanIndexOD(), TestSlave_scanIndexOD(), and win32test_scanIndexOD(). +
#define OD_NO_SUCH_SUBINDEX 0x06090011 | +
+ +
+Definition at line 37 of file def.h. +
+Referenced by _getODentry(), _setODentry(), and accessDictionaryError(). +
#define OD_NOT_MAPPABLE 0x06040041 | +
#define OD_READ_NOT_ALLOWED 0x06010001 | +
#define OD_SUCCESSFUL 0x00000000 | +
+definitions used for object dictionary access. ie SDO Abort codes . (See DS 301 v.4.02 p.48) +
+Definition at line 31 of file def.h. +
+Referenced by _getODentry(), _setODentry(), decompo_dcf(), gene_SYNC_scanIndexOD(), main(), objdictToSDOline(), proceedPDO(), proceedSYNC(), RegisterSetODentryCallBack(), SDOlineToObjdict(), setState(), TestMaster_scanIndexOD(), TestSlave_scanIndexOD(), and win32test_scanIndexOD(). +
#define OD_VALUE_TOO_HIGH 0x06090032 | +
#define OD_VALUE_TOO_LOW 0x06090031 | +
#define OD_WRITE_NOT_ALLOWED 0x06010002 | +
+ +
+Definition at line 33 of file def.h. +
+Referenced by _getODentry(), _setODentry(), and accessDictionaryError(). +
#define PDO1rx 0x4 | +
+ +
+Definition at line 90 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define PDO1tx 0x3 | +
+ +
+Definition at line 89 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define PDO2rx 0x6 | +
+ +
+Definition at line 92 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define PDO2tx 0x5 | +
+ +
+Definition at line 91 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define PDO3rx 0x8 | +
+ +
+Definition at line 94 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define PDO3tx 0x7 | +
+ +
+Definition at line 93 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define PDO4rx 0xA | +
+ +
+Definition at line 96 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define PDO4tx 0x9 | +
+ +
+Definition at line 95 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define REQUEST 1 | +
+Constantes which permit to define if a PDO frame is a request one or a data one +
+Definition at line 54 of file def.h. +
+Referenced by masterSendNMTnodeguard(), proceedPDO(), sendPDO(), and sendPDOrequest(). +
#define SDO_ABORTED_INTERNAL 0x85 | +
+ +
+Definition at line 73 of file def.h. +
+Referenced by failedSDO(), getReadResultNetworkDict(), getWriteResultNetworkDict(), SDOTimeoutAlarm(), and TestMaster_post_TPDO(). +
#define SDO_ABORTED_RCV 0x80 | +
+ +
+Definition at line 72 of file def.h. +
+Referenced by proceedSDO(), and TestMaster_post_TPDO(). +
#define SDO_CLIENT 0x2 | +
+ +
+Definition at line 79 of file def.h. +
+Referenced by _readNetworkDict(), _writeNetworkDict(), failedSDO(), getReadResultNetworkDict(), getWriteResultNetworkDict(), proceedSDO(), ReadSDO(), and TestMaster_post_TPDO(). +
#define SDO_DOWNLOAD_IN_PROGRESS 0x2 | +
+ +
+Definition at line 74 of file def.h. +
+Referenced by _writeNetworkDict(), initSDOline(), proceedSDO(), and TestMaster_post_TPDO(). +
#define SDO_FINISHED 0x1 | +
+ +
+Definition at line 71 of file def.h. +
+Referenced by getReadResultNetworkDict(), proceedSDO(), ReadSDO(), and TestMaster_post_TPDO(). +
#define SDO_RESET 0x0 | +
+Status of the SDO transmission +
+Definition at line 70 of file def.h. +
+Referenced by getSDOfreeLine(), getSDOlineOnUse(), resetSDOline(), and TestMaster_post_TPDO(). +
#define SDO_SERVER 0x1 | +
+ +
+Definition at line 78 of file def.h. +
+Referenced by failedSDO(), proceedSDO(), SDOTimeoutAlarm(), and sendSDO(). +
#define SDO_UNKNOWN 0x3 | +
#define SDO_UPLOAD_IN_PROGRESS 0x3 | +
+ +
+Definition at line 75 of file def.h. +
+Referenced by _readNetworkDict(), initSDOline(), proceedSDO(), ReadSDO(), and TestMaster_post_TPDO(). +
#define SDOABT_GENERAL_ERROR 0x08000000 | +
#define SDOABT_LOCAL_CTRL_ERROR 0x08000021 | +
#define SDOABT_OUT_OF_MEMORY 0x05040005 | +
#define SDOABT_TIMED_OUT 0x05040000 | +
#define SDOABT_TOGGLE_NOT_ALTERNED 0x05030000 | +
#define SDOrx 0xC | +
+ +
+Definition at line 98 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define SDOtx 0xB | +
+ +
+Definition at line 97 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define state1 0x01 | +
#define state10 0x0A | +
#define state11 0x0B | +
#define state2 0x02 | +
#define state3 0x03 | +
#define state4 0x04 | +
#define state5 0x05 | +
#define state7 0x07 | +
#define state8 0x08 | +
#define state9 0x09 | +
#define SYNC 0x1 | +
+ +
+Definition at line 87 of file def.h. +
+Referenced by canDispatch(), and print_message(). +
#define TIME_STAMP 0x2 | +
#define TRUE 1 | +
+
File in drivers » can_lincan | Includes file in include |
---|---|
can_lincan.c | can_driver.h |
File in drivers » can_peak_linux | Includes file in include |
---|---|
can_peak_linux.c | can_driver.h |
File in drivers » can_peak_win32 | Includes file in include |
---|---|
can_peak_win32.c | can_driver.h |
File in drivers » can_socket | Includes file in include |
---|---|
can_socket.c | can_driver.h |
can_socket.c | win32 / config.h |
File in drivers » can_uvccm_win32 | Includes file in include |
---|---|
can_uvccm_win32.cpp | can_driver.h |
File in drivers » can_virtual | Includes file in include |
---|---|
can_virtual.c | can_driver.h |
can_virtual.c | def.h |
File in drivers » timers_unix | Includes file in include |
---|---|
timers_unix.c | win32 / applicfg.h |
timers_unix.c | timer.h |
File in drivers » timers_xeno | Includes file in include |
---|---|
timers_xeno.c | win32 / applicfg.h |
timers_xeno.c | can_driver.h |
timers_xeno.c | timer.h |
File in drivers » unix | Includes file in include |
---|---|
unix.c | can_driver.h |
unix.c | win32 / canfestival.h |
unix.c | data.h |
unix.c | timers_driver.h |
File in examples » gene_SYNC_HCS12 | Includes file in include |
---|---|
appli.c | win32 / applicfg.h |
appli.c | hcs12 / interrupt.h |
appli.c | hcs12 / asm-m68hc12 / ports.h |
appli.c | hcs12 / asm-m68hc12 / ports_def.h |
appli.c | hcs12 / asm-m68hc12 / portsaccess.h |
objdict.h | data.h |
File in examples » TestMasterMicroMod | Includes file in include |
---|---|
TestMaster.h | data.h |
TestMasterMicroMod.c | win32 / canfestival.h |
TestMasterMicroMod.h | win32 / canfestival.h |
File in examples » TestMasterSlave | Includes file in include |
---|---|
TestMaster.h | data.h |
TestMasterSlave.c | win32 / canfestival.h |
TestMasterSlave.h | win32 / canfestival.h |
TestSlave.h | data.h |
File in examples » win32test | Includes file in include |
---|---|
main.c | win32 / canfestival.h |
win32test.h | data.h |
File in include » unix | Includes file in include » win32 |
---|---|
canfestival.h | timerscfg.h |
+
Files | |
file | applicfg.h [code] |
file | canfestival.h [code] |
+
Files | |
file | can_uvccm_win32.cpp [code] |
+
Files | |
file | ports.h [code] |
file | ports_def.h [code] |
file | portsaccess.h [code] |
file | regs.h [code] |
+
Directories | |
directory | hcs12 |
directory | timers_unix |
directory | timers_xeno |
directory | unix |
directory | win32 |
Files | |
file | can.h [code] |
file | can_driver.h [code] |
file | config.h [code] |
file | data.h [code] |
file | dcf.h [code] |
file | def.h [code] |
file | lifegrd.h [code] |
file | nmtMaster.h [code] |
file | nmtSlave.h [code] |
file | objacces.h [code] |
Responsible for accessing the object dictionary. | |
file | objdictdef.h [code] |
file | pdo.h [code] |
file | sdo.h [code] |
file | states.h [code] |
file | sync.h [code] |
file | sysdep.h [code] |
file | timer.h [code] |
file | timers_driver.h [code] |
+
Files | |
file | can_virtual.c [code] |
+
Files | |
file | appli.c [code] |
file | objdict.c [code] |
file | objdict.h [code] |
+
Files | |
file | timers_unix.c [code] |
+
Directories | |
directory | arch |
+
Files | |
file | timers_xeno.c [code] |
+
Files | |
file | can_socket.c [code] |
+
Files | |
file | timerscfg.h [code] |
+
Files | |
file | unix.c [code] |
+
Files | |
file | applicfg.h [code] |
file | canfestival.h [code] |
file | config.h [code] |
file | timerscfg.h [code] |
+
Files | |
file | exit.h [code] |
file | interrupts.h [code] |
file | param.h [code] |
+
Files | |
file | timerscfg.h [code] |
+
Files | |
file | can_lincan.c [code] |
file | canmsg.h [code] |
file | lincan.h [code] |
+
Files | |
file | can_peak_linux.c [code] |
+
Directories | |
directory | asm-m68hc12 |
directory | board |
Files | |
file | applicfg.h [code] |
file | candriver.h [code] |
file | canOpenDriver.h [code] |
file | error.h [code] |
file | interrupt.h [code] |
file | regbase.h [code] |
+
Files | |
file | main.c [code] |
file | win32test.c [code] |
file | win32test.h [code] |
+
Files | |
file | getopt.c [code] |
file | getopt.h [code] |
file | TestMaster.c [code] |
file | TestMaster.h [code] |
file | TestMasterMicroMod.c [code] |
file | TestMasterMicroMod.h [code] |
+
Files | |
file | resource.h [code] |
+
Directories | |
directory | win32 |
Files | |
file | dcf.c [code] |
EXEMPLE OF SOMMARY. | |
file | lifegrd.c [code] |
file | nmtMaster.c [code] |
file | nmtSlave.c [code] |
file | objacces.c [code] |
file | pdo.c [code] |
file | sdo.c [code] |
file | states.c [code] |
file | sync.c [code] |
file | timer.c [code] |
+
Files | |
file | getopt.c [code] |
file | getopt.h [code] |
file | Master.c [code] |
file | Master.h [code] |
file | Slave.c [code] |
file | Slave.h [code] |
file | TestMaster.c [code] |
file | TestMaster.h [code] |
file | TestMasterSlave.c [code] |
file | TestMasterSlave.h [code] |
file | TestSlave.c [code] |
file | TestSlave.h [code] |
+
Files | |
file | can_peak_win32.c [code] |
+
Directories | |
directory | can_lincan |
directory | can_peak_linux |
directory | can_peak_win32 |
directory | can_socket |
directory | can_uvccm_win32 |
directory | can_virtual |
directory | hcs12 |
directory | timers_unix |
directory | timers_xeno |
directory | unix |
directory | win32 |
+
Files | |
file | canOpenDriver.c [code] |
file | interrupt.c [code] |
+
Files | |
file | drivers_win32.cpp [code] |
file | timers_win32.cpp [code] |
+
Directories | |
directory | gene_SYNC_HCS12 |
directory | TestMasterMicroMod |
directory | TestMasterSlave |
directory | win32test |
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 Copyright (C) Win32 Port Leonid Tochinski +00006 +00007 See COPYING file for copyrights details. +00008 +00009 This library is free software; you can redistribute it and/or +00010 modify it under the terms of the GNU Lesser General Public +00011 License as published by the Free Software Foundation; either +00012 version 2.1 of the License, or (at your option) any later version. +00013 +00014 This library is distributed in the hope that it will be useful, +00015 but WITHOUT ANY WARRANTY; without even the implied warranty of +00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00017 Lesser General Public License for more details. +00018 +00019 You should have received a copy of the GNU Lesser General Public +00020 License along with this library; if not, write to the Free Software +00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00022 */ +00023 +00024 /* +00025 CAN driver interface. +00026 */ +00027 +00028 #include <windows.h> +00029 +00030 extern "C" +00031 { +00032 #define DLL_CALL(funcname) (*_##funcname) +00033 #define FCT_PTR_INIT =NULL +00034 #include "canfestival.h" +00035 #include "timer.h" +00036 +00037 #include "timers_driver.h" +00038 }; +00039 +00040 typedef UNS8 (*CANRECEIVE_DRIVER_PROC)(void* inst, Message *m); +00041 typedef UNS8 (*CANSEND_DRIVER_PROC)(void* inst, const Message *m); +00042 typedef void* (*CANOPEN_DRIVER_PROC)(s_BOARD *board); +00043 typedef int (*CANCLOSE_DRIVER_PROC)(void* inst); +00044 +00045 +00046 class driver_procs +00047 { +00048 public: +00049 driver_procs(); +00050 ~driver_procs(); +00051 +00052 HMODULE load_canfestival_driver(LPCTSTR driver_name); +00053 bool can_driver_valid() const; +00054 +00055 public: +00056 // can driver +00057 CANRECEIVE_DRIVER_PROC m_canReceive; +00058 CANSEND_DRIVER_PROC m_canSend; +00059 CANOPEN_DRIVER_PROC m_canOpen; +00060 CANCLOSE_DRIVER_PROC m_canClose; +00061 +00062 // driver module habndle +00063 HMODULE m_driver_handle; +00064 }; +00065 +00066 driver_procs::driver_procs() : m_canReceive(0), +00067 m_canSend(0), +00068 m_canOpen(0), +00069 m_canClose(0), +00070 m_driver_handle(0) +00071 {} +00072 +00073 driver_procs::~driver_procs() +00074 { +00075 if (m_driver_handle) +00076 ::FreeLibrary(m_driver_handle); +00077 } +00078 +00079 bool driver_procs::can_driver_valid() const +00080 { +00081 return ((m_canReceive != NULL) && +00082 (m_canSend != NULL) && +00083 (m_canOpen != NULL) && +00084 (m_canClose != NULL)); +00085 } +00086 +00087 // GetProcAddress doesn't have an UNICODE version for NT +00088 #ifdef UNDER_CE +00089 #define myTEXT(str) TEXT(str) +00090 #else +00091 #define myTEXT(str) str +00092 #endif +00093 +00094 HMODULE driver_procs::load_canfestival_driver(LPCTSTR driver_name) +00095 { +00096 if (can_driver_valid()) +00097 return m_driver_handle; +00098 m_driver_handle = ::LoadLibrary(driver_name); +00099 if (m_driver_handle == NULL) +00100 return NULL; +00101 +00102 m_canReceive = (CANRECEIVE_DRIVER_PROC)::GetProcAddress(m_driver_handle, myTEXT("canReceive_driver")); +00103 m_canSend = (CANSEND_DRIVER_PROC)::GetProcAddress(m_driver_handle, myTEXT("canSend_driver")); +00104 m_canOpen = (CANOPEN_DRIVER_PROC)::GetProcAddress(m_driver_handle, myTEXT("canOpen_driver")); +00105 m_canClose = (CANCLOSE_DRIVER_PROC)::GetProcAddress(m_driver_handle, myTEXT("canClose_driver")); +00106 return can_driver_valid()?m_driver_handle:NULL; +00107 } +00108 +00109 struct driver_data +00110 { +00111 CO_Data * d; +00112 HANDLE receive_thread; +00113 void* inst; +00114 volatile bool continue_receive_thread; +00115 }; +00116 +00117 driver_procs s_driver_procs; +00118 +00119 LIB_HANDLE LoadCanDriver(char* driver_name) +00120 { +00121 return s_driver_procs.load_canfestival_driver((LPCTSTR)driver_name); +00122 } +00123 +00124 UNS8 canReceive(CAN_PORT fd0, Message *m) +00125 { +00126 if (fd0 != NULL && s_driver_procs.m_canReceive != NULL) +00127 { +00128 driver_data* data = (driver_data*)fd0; +00129 return (*s_driver_procs.m_canReceive)(data->inst, m); +00130 } +00131 return 1; +00132 } +00133 +00134 void* canReceiveLoop(CAN_PORT fd0) +00135 { +00136 driver_data* data = (driver_data*)fd0; +00137 Message m; +00138 while (data->continue_receive_thread) +00139 { +00140 if (!canReceive(fd0, &m)) +00141 { +00142 EnterMutex(); +00143 canDispatch(data->d, &m); +00144 LeaveMutex(); +00145 } +00146 else +00147 { +00148 break; +00149 ::Sleep(1); +00150 } +00151 } +00152 return 0; +00153 } +00154 +00155 /***************************************************************************/ +00156 UNS8 canSend(CAN_PORT fd0, Message *m) +00157 { +00158 if (fd0 != NULL && s_driver_procs.m_canSend != NULL) +00159 { +00160 UNS8 res; +00161 driver_data* data = (driver_data*)fd0; +00162 LeaveMutex(); +00163 res = (*s_driver_procs.m_canSend)(data->inst, m); +00164 EnterMutex(); +00165 if (res) +00166 return 0; +00167 } +00168 return 1; +00169 } +00170 +00171 /***************************************************************************/ +00172 CAN_HANDLE canOpen(s_BOARD *board, CO_Data * d) +00173 { +00174 if (board != NULL && s_driver_procs.m_canOpen != NULL) +00175 { +00176 void* inst = (*s_driver_procs.m_canOpen)(board); +00177 if (inst != NULL) +00178 { +00179 driver_data* data = new driver_data; +00180 data->d = d; +00181 data->inst = inst; +00182 data->continue_receive_thread = true; +00183 CreateReceiveTask(data, &data->receive_thread, &canReceiveLoop); +00184 EnterMutex(); +00185 d->canHandle = data; +00186 LeaveMutex(); +00187 return data; +00188 } +00189 } +00190 return NULL; +00191 } +00192 +00193 /***************************************************************************/ +00194 int canClose(CO_Data * d) +00195 { +00196 if (s_driver_procs.m_canClose != NULL) +00197 { +00198 driver_data* data; +00199 EnterMutex(); +00200 if(d->canHandle != NULL){ +00201 data = (driver_data*)d->canHandle; +00202 d->canHandle = NULL; +00203 data->continue_receive_thread = false;} +00204 LeaveMutex(); +00205 WaitReceiveTaskEnd(&data->receive_thread); +00206 (*s_driver_procs.m_canClose)(data->inst); +00207 delete data; +00208 return 0; +00209 } +00210 return 0; +00211 } +00212 +00213 +
#include <windows.h>
#include "canfestival.h"
#include "timer.h"
#include "timers_driver.h"
+Include dependency graph for drivers_win32.cpp:
+Go to the source code of this file.
Data Structures | |
class | driver_procs |
struct | driver_data |
Defines | |
#define | DLL_CALL(funcname) (*_##funcname) |
#define | FCT_PTR_INIT =NULL |
#define | myTEXT(str) str |
Typedefs | |
typedef UNS8(*) | CANRECEIVE_DRIVER_PROC (void *inst, Message *m) |
typedef UNS8(*) | CANSEND_DRIVER_PROC (void *inst, const Message *m) |
typedef void *(*) | CANOPEN_DRIVER_PROC (s_BOARD *board) |
typedef int(*) | CANCLOSE_DRIVER_PROC (void *inst) |
Functions | |
LIB_HANDLE | LoadCanDriver (char *driver_name) |
UNS8 | canReceive (CAN_PORT fd0, Message *m) |
void * | canReceiveLoop (CAN_PORT fd0) |
UNS8 | canSend (CAN_PORT fd0, Message *m) |
CAN_HANDLE | canOpen (s_BOARD *board, CO_Data *d) |
int | canClose (CO_Data *d) |
Variables | |
driver_procs | s_driver_procs |
#define DLL_CALL | +( | +funcname | ++ | ) | +(*_##funcname) | +
+ +
+Definition at line 32 of file drivers_win32.cpp. +
#define FCT_PTR_INIT =NULL | +
+ +
+Definition at line 33 of file drivers_win32.cpp. +
#define myTEXT | +( | +str | ++ | ) | +str | +
+ +
+Definition at line 91 of file drivers_win32.cpp. +
+Referenced by driver_procs::load_canfestival_driver(). +
+
typedef int(*) CANCLOSE_DRIVER_PROC(void *inst) | +
+ +
+Definition at line 43 of file drivers_win32.cpp. +
typedef void*(*) CANOPEN_DRIVER_PROC(s_BOARD *board) | +
+ +
+Definition at line 42 of file drivers_win32.cpp. +
typedef UNS8(*) CANRECEIVE_DRIVER_PROC(void *inst, Message *m) | +
+ +
+Definition at line 40 of file drivers_win32.cpp. +
typedef UNS8(*) CANSEND_DRIVER_PROC(void *inst, const Message *m) | +
+ +
+Definition at line 41 of file drivers_win32.cpp. +
+
int canClose | +( | +CO_Data * | +d | +) | ++ |
+ +
+Definition at line 194 of file drivers_win32.cpp. +
+References canClose(), struct_CO_Data::canHandle, driver_data::continue_receive_thread, DLL_CALL, EnterMutex(), CANPort::fd, driver_data::inst, LeaveMutex(), driver_procs::m_canClose, driver_data::receive_thread, CANPort::receiveTask, s_driver_procs, and WaitReceiveTaskEnd(). +
+Here is the call graph for this function:
CAN_HANDLE canOpen | +( | +s_BOARD * | +board, | +|
+ | + | CO_Data * | +d | + |
+ | ) | ++ |
+ +
+Definition at line 172 of file drivers_win32.cpp. +
+References struct_s_BOARD::baudrate, struct_s_BOARD::busname, struct_CO_Data::canHandle, canOpen(), canports, canReceiveLoop(), driver_data::continue_receive_thread, CreateReceiveTask(), CANPort::d, driver_data::d, DLL_CALL, EnterMutex(), CANPort::fd, driver_data::inst, LeaveMutex(), driver_procs::m_canOpen, MAX_NB_CAN_PORTS, driver_data::receive_thread, s_driver_procs, and CANPort::used. +
+Here is the call graph for this function:
+ +
+Definition at line 124 of file drivers_win32.cpp. +
+References driver_data::inst, driver_procs::m_canReceive, and s_driver_procs. +
+Referenced by canReceiveLoop(), and LoadCanDriver(). +
void* canReceiveLoop | +( | +CAN_PORT | +fd0 | +) | ++ |
+ +
+Definition at line 134 of file drivers_win32.cpp. +
+References canDispatch(), canReceive(), driver_data::continue_receive_thread, driver_data::d, EnterMutex(), and LeaveMutex(). +
+Here is the call graph for this function:
+ +
+Definition at line 156 of file drivers_win32.cpp. +
+References canSend(), DLL_CALL, EnterMutex(), driver_data::inst, LeaveMutex(), driver_procs::m_canSend, s_driver_procs, and UNS8. +
+Here is the call graph for this function:
LIB_HANDLE LoadCanDriver | +( | +char * | +driver_name | +) | ++ |
+ +
+Definition at line 119 of file drivers_win32.cpp. +
+References canClose(), canOpen(), canReceive(), canSend(), DLSYM, driver_procs::load_canfestival_driver(), and s_driver_procs. +
+Here is the call graph for this function:
+
driver_procs s_driver_procs | +
+ +
+Definition at line 117 of file drivers_win32.cpp. +
+Referenced by canClose(), canOpen(), canReceive(), canSend(), and LoadCanDriver(). +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 #ifndef __ERROR__ +00024 #define __ERROR__ +00025 +00026 +00027 #define ERR_CAN_ADD_ID_TO_FILTER "1 Not in init mode" +00028 #define ERR_CAN_INIT_CLOCK "4 Not in init mode" +00029 #define ERR_CAN_INIT_1_FILTER "5 Not in init mode" +00030 #define ERR_CAN_INIT_FILTER "6 Not in init mode" +00031 #define ERR_CAN_MSG_TRANSMIT "7 No buffer free " +00032 #define ERR_CAN_SLEEP_MODE "8 Is in init mode" +00033 #define ERR_CAN_SLEEP_MODE_Q "9 Is in init mode" +00034 #define ERR_CAN_SLEEP_WUP_MODE "10 Is in init mode" +00035 #define ERR_CAN0HDLRCV_STACK_FULL "11 Stack R full" +00036 +00037 #endif /* __ERROR__ */ +
+Go to the source code of this file.
Defines | |
#define | ERR_CAN_ADD_ID_TO_FILTER "1 Not in init mode" |
#define | ERR_CAN_INIT_CLOCK "4 Not in init mode" |
#define | ERR_CAN_INIT_1_FILTER "5 Not in init mode" |
#define | ERR_CAN_INIT_FILTER "6 Not in init mode" |
#define | ERR_CAN_MSG_TRANSMIT "7 No buffer free " |
#define | ERR_CAN_SLEEP_MODE "8 Is in init mode" |
#define | ERR_CAN_SLEEP_MODE_Q "9 Is in init mode" |
#define | ERR_CAN_SLEEP_WUP_MODE "10 Is in init mode" |
#define | ERR_CAN0HDLRCV_STACK_FULL "11 Stack R full" |
#define ERR_CAN0HDLRCV_STACK_FULL "11 Stack R full" | +
#define ERR_CAN_ADD_ID_TO_FILTER "1 Not in init mode" | +
#define ERR_CAN_INIT_1_FILTER "5 Not in init mode" | +
#define ERR_CAN_INIT_CLOCK "4 Not in init mode" | +
#define ERR_CAN_INIT_FILTER "6 Not in init mode" | +
#define ERR_CAN_MSG_TRANSMIT "7 No buffer free " | +
#define ERR_CAN_SLEEP_MODE "8 Is in init mode" | +
#define ERR_CAN_SLEEP_MODE_Q "9 Is in init mode" | +
#define ERR_CAN_SLEEP_WUP_MODE "10 Is in init mode" | +
+
00001 /* +00002 This file is part of CanFestival, a library implementing CanOpen Stack. +00003 +00004 Copyright (C): Edouard TISSERANT and Francis DUPIN +00005 +00006 See COPYING file for copyrights details. +00007 +00008 This library is free software; you can redistribute it and/or +00009 modify it under the terms of the GNU Lesser General Public +00010 License as published by the Free Software Foundation; either +00011 version 2.1 of the License, or (at your option) any later version. +00012 +00013 This library is distributed in the hope that it will be useful, +00014 but WITHOUT ANY WARRANTY; without even the implied warranty of +00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00016 Lesser General Public License for more details. +00017 +00018 You should have received a copy of the GNU Lesser General Public +00019 License along with this library; if not, write to the Free Software +00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +00021 */ +00022 +00023 /* exit.h - 32K Board specific parameters +00024 Copyright (C) 2002 Free Software Foundation, Inc. +00025 Written by Stephane Carrez (stcarrez@nerim.fr) +00026 +00027 This file is free software; you can redistribute it and/or modify it +00028 under the terms of the GNU General Public License as published by the +00029 Free Software Foundation; either version 2, or (at your option) any +00030 later version. +00031 +00032 In addition to the permissions in the GNU General Public License, the +00033 Free Software Foundation gives you unlimited permission to link the +00034 compiled version of this file with other programs, and to distribute +00035 those programs without any restriction coming from the use of this +00036 file. (The General Public License restrictions do apply in other +00037 respects; for example, they cover modification of the file, and +00038 distribution when not linked into another program.) +00039 +00040 This file is distributed in the hope that it will be useful, but +00041 WITHOUT ANY WARRANTY; without even the implied warranty of +00042 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +00043 General Public License for more details. +00044 +00045 You should have received a copy of the GNU General Public License +00046 along with this program; see the file COPYING. If not, write to +00047 the Free Software Foundation, 59 Temple Place - Suite 330, +00048 Boston, MA 02111-1307, USA. */ +00049 +00050 #ifndef _M68HC11_ARCH_32K_EXIT_H +00051 #define _M68HC11_ARCH_32K_EXIT_H +00052 +00053 extern void _exit (short status) __attribute__((noreturn)); +00054 +00055 /* For the simulator, the wai stops everything and exits with the +00056 error code stored in register d. +00057 +00058 For a real 68HC11, enable interrupts and wait forever. */ +00059 extern inline void +00060 _exit (short status) +00061 { +00062 /* Use 'd' constraint to force the status to be in the D +00063 register before execution of the asm. */ +00064 while (1) +00065 { +00066 __asm__ __volatile__ ("cli\n" +00067 "wai" : : "d"(status)); +00068 } +00069 } +00070 +00071 #endif +
+Go to the source code of this file.
Functions | |
void | _exit (short status) __attribute__((noreturn)) |
void _exit | +( | +short | +status | +) | + [inline] |
+
+
/home/epimerde/documents/tc11/CanFestival-3/src/dcf.c [code] | EXEMPLE OF SOMMARY |
/home/epimerde/documents/tc11/CanFestival-3/src/lifegrd.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/nmtMaster.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/nmtSlave.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/objacces.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/pdo.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/sdo.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/states.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/sync.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/timer.c [code] | |
/home/epimerde/documents/tc11/CanFestival-3/src/win32/resource.h [code] | |
drivers/can_lincan/can_lincan.c [code] | |
drivers/can_lincan/canmsg.h [code] | |
drivers/can_lincan/lincan.h [code] | |
drivers/can_peak_linux/can_peak_linux.c [code] | |
drivers/can_peak_win32/can_peak_win32.c [code] | |
drivers/can_socket/can_socket.c [code] | |
drivers/can_uvccm_win32/can_uvccm_win32.cpp [code] | |
drivers/can_virtual/can_virtual.c [code] | |
drivers/hcs12/canOpenDriver.c [code] | |
drivers/hcs12/interrupt.c [code] | |
drivers/timers_unix/timers_unix.c [code] | |
drivers/timers_xeno/timers_xeno.c [code] | |
drivers/unix/unix.c [code] | |
drivers/win32/drivers_win32.cpp [code] | |
drivers/win32/timers_win32.cpp [code] | |
examples/gene_SYNC_HCS12/appli.c [code] | |
examples/gene_SYNC_HCS12/objdict.c [code] | |
examples/gene_SYNC_HCS12/objdict.h [code] | |
examples/TestMasterMicroMod/getopt.c [code] | |
examples/TestMasterMicroMod/getopt.h [code] | |
examples/TestMasterMicroMod/TestMaster.c [code] | |
examples/TestMasterMicroMod/TestMaster.h [code] | |
examples/TestMasterMicroMod/TestMasterMicroMod.c [code] | |
examples/TestMasterMicroMod/TestMasterMicroMod.h [code] | |
examples/TestMasterSlave/getopt.c [code] | |
examples/TestMasterSlave/getopt.h [code] | |
examples/TestMasterSlave/Master.c [code] | |
examples/TestMasterSlave/Master.h [code] | |
examples/TestMasterSlave/Slave.c [code] | |
examples/TestMasterSlave/Slave.h [code] | |
examples/TestMasterSlave/TestMaster.c [code] | |
examples/TestMasterSlave/TestMaster.h [code] | |
examples/TestMasterSlave/TestMasterSlave.c [code] | |
examples/TestMasterSlave/TestMasterSlave.h [code] | |
examples/TestMasterSlave/TestSlave.c [code] | |
examples/TestMasterSlave/TestSlave.h [code] | |
examples/win32test/main.c [code] | |
examples/win32test/win32test.c [code] | |
examples/win32test/win32test.h [code] | |
include/can.h [code] | |
include/can_driver.h [code] | |
include/config.h [code] | |
include/data.h [code] | |
include/dcf.h [code] | |
include/def.h [code] | |
include/lifegrd.h [code] | |
include/nmtMaster.h [code] | |
include/nmtSlave.h [code] | |
include/objacces.h [code] | Responsible for accessing the object dictionary |
include/objdictdef.h [code] | |
include/pdo.h [code] | |
include/sdo.h [code] | |
include/states.h [code] | |
include/sync.h [code] | |
include/sysdep.h [code] | |
include/timer.h [code] | |
include/timers_driver.h [code] | |
include/hcs12/applicfg.h [code] | |
include/hcs12/candriver.h [code] | |
include/hcs12/canOpenDriver.h [code] | |
include/hcs12/error.h [code] | |
include/hcs12/interrupt.h [code] | |
include/hcs12/regbase.h [code] | |
include/hcs12/asm-m68hc12/ports.h [code] | |
include/hcs12/asm-m68hc12/ports_def.h [code] | |
include/hcs12/asm-m68hc12/portsaccess.h [code] | |
include/hcs12/asm-m68hc12/regs.h [code] | |
include/hcs12/board/arch/exit.h [code] | |
include/hcs12/board/arch/interrupts.h [code] | |
include/hcs12/board/arch/param.h [code] | |
include/timers_unix/timerscfg.h [code] | |
include/timers_xeno/timerscfg.h [code] | |
include/unix/applicfg.h [code] | |
include/unix/canfestival.h [code] | |
include/win32/applicfg.h [code] | |
include/win32/canfestival.h [code] | |
include/win32/config.h [code] | |
include/win32/timerscfg.h [code] | |
src/dcf.c [code] | EXEMPLE OF SOMMARY |
src/lifegrd.c [code] | |
src/nmtMaster.c [code] | |
src/nmtSlave.c [code] | |
src/objacces.c [code] | |
src/pdo.c [code] | |
src/sdo.c [code] | |
src/states.c [code] | |
src/sync.c [code] | |
src/timer.c [code] | |
src/win32/resource.h [code] |
+Here is a list of all struct and union fields with links to the structures/unions they belong to: +
+
+
+ +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
+Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to: +
+
-
+ +
+
diff -r 003cc3c63855 -r f49e5a6b7804 doc/doxygen/html/globals_defs_0x61.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/doxygen/html/globals_defs_0x61.html Fri Jun 08 09:23:56 2007 +0200 @@ -0,0 +1,177 @@ + +
+
+ + +
+