nico@215: nico@215: nico@215: CanFestival: examples/TestMasterMicroMod/TestMasterMicroMod.c Source File nico@215: nico@215: nico@215: nico@215: nico@215:
nico@215:
nico@215:
nico@215:
nico@215: nico@215:

TestMasterMicroMod.c

Go to the documentation of this file.
00001 /*
nico@215: 00002 This file is part of CanFestival, a library implementing CanOpen Stack. 
nico@215: 00003 
nico@215: 00004 Copyright (C): Edouard TISSERANT and Francis DUPIN
nico@215: 00005 
nico@215: 00006 See COPYING file for copyrights details.
nico@215: 00007 
nico@215: 00008 This library is free software; you can redistribute it and/or
nico@215: 00009 modify it under the terms of the GNU Lesser General Public
nico@215: 00010 License as published by the Free Software Foundation; either
nico@215: 00011 version 2.1 of the License, or (at your option) any later version.
nico@215: 00012 
nico@215: 00013 This library is distributed in the hope that it will be useful,
nico@215: 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
nico@215: 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
nico@215: 00016 Lesser General Public License for more details.
nico@215: 00017 
nico@215: 00018 You should have received a copy of the GNU Lesser General Public
nico@215: 00019 License along with this library; if not, write to the Free Software
nico@215: 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
nico@215: 00021 */
nico@215: 00022 
nico@215: 00023 #if defined(WIN32) && !defined(__CYGWIN__)
nico@215: 00024 #include <windows.h>
nico@215: 00025 #include "getopt.h"
nico@215: 00026 void pause(void)
nico@215: 00027 {
nico@215: 00028         system("PAUSE");
nico@215: 00029 }
nico@215: 00030 #else
nico@215: 00031 #include <unistd.h>
nico@215: 00032 #include <stdio.h>
nico@215: 00033 #include <string.h>
nico@215: 00034 #include <stdlib.h>
nico@215: 00035 #include <signal.h>
nico@215: 00036 #endif
nico@215: 00037 
nico@215: 00038 #include "canfestival.h"
nico@215: 00039 #include "TestMasterMicroMod.h"
nico@215: 00040 #include "TestMaster.h"
etisserant@240: 00041 UNS8 slavenodeid;
nico@215: 00042 
nico@215: 00043 
nico@215: 00044 /*****************************************************************************/
etisserant@240: 00045 void TestMaster_heartbeatError(UNS8 heartbeatID)
nico@215: 00046 {
etisserant@240: 00047         eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
nico@215: 00048 }
nico@215: 00049 
nico@215: 00050 /********************************************************
nico@215: 00051  * ConfigureSlaveNode is responsible to
nico@215: 00052  *  - setup master RPDO 1 to receive TPDO 1 from id 0x40
nico@215: 00053  *  - setup master TPDO 1 to send RPDO 1 to id 0x40
nico@215: 00054  ********************************************************/
etisserant@240: 00055 void TestMaster_initialisation()
nico@215: 00056 {
etisserant@240: 00057         UNS32 PDO1_COBID = 0x0180 + slavenodeid; 
etisserant@240: 00058         UNS32 PDO2_COBID = 0x0200 + slavenodeid;
etisserant@240: 00059         UNS8 size = sizeof(UNS32); 
nico@215: 00060 
etisserant@240: 00061         eprintf("TestMaster_initialisation\n");
nico@215: 00062 
nico@215: 00063         /*****************************************
nico@215: 00064          * Define RPDOs to match slave ID=0x40 TPDOs*
nico@215: 00065          *****************************************/
etisserant@240: 00066         writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
nico@215: 00067                         0x1400, /*UNS16 index*/
nico@215: 00068                         0x01, /*UNS8 subind*/ 
nico@215: 00069                         &PDO1_COBID, /*void * pSourceData,*/ 
nico@215: 00070                         &size, /* UNS8 * pExpectedSize*/
etisserant@240: 00071                         RW);  /* UNS8 checkAccess */
nico@215: 00072                         
nico@215: 00073 
nico@215: 00074         /*****************************************
nico@215: 00075          * Define TPDOs to match slave ID=0x40 RPDOs*
nico@215: 00076          *****************************************/
etisserant@240: 00077         writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
nico@215: 00078                         0x1800, /*UNS16 index*/
nico@215: 00079                         0x01, /*UNS8 subind*/ 
nico@215: 00080                         &PDO2_COBID, /*void * pSourceData,*/ 
nico@215: 00081                         &size, /* UNS8 * pExpectedSize*/
etisserant@240: 00082                         RW);  /* UNS8 checkAccess */
nico@215: 00083 }
nico@215: 00084 
nico@215: 00085 static init_step = 0;
nico@215: 00086 
nico@215: 00087 /*Froward declaration*/
etisserant@240: 00088 static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId);
nico@215: 00089 
nico@215: 00090 
etisserant@240: 00091 static void CheckSDOAndContinue(CO_Data* d, UNS8 nodeId)
nico@215: 00092 {
etisserant@240: 00093         UNS32 abortCode;
nico@215: 00094 
etisserant@240: 00095         if(getWriteResultNetworkDict (d, nodeId, &abortCode) != SDO_FINISHED)
etisserant@240: 00096                 eprintf("Master : Failed in initializing slave %2.2x, step %d, AbortCode :%4.4x \n", nodeId, init_step, abortCode);
nico@215: 00097 
nico@215: 00098         /* Finalise last SDO transfer with this node */
etisserant@240: 00099         closeSDOtransfer(&TestMaster_Data, nodeId, SDO_CLIENT);
nico@215: 00100 
nico@215: 00101         ConfigureSlaveNode(d, nodeId);
nico@215: 00102 }
nico@215: 00103 
nico@215: 00104 /********************************************************
nico@215: 00105  * ConfigureSlaveNode is responsible to
nico@215: 00106  *  - setup slave TPDO 1 transmit time
nico@215: 00107  *  - setup slave TPDO 2 transmit time
nico@215: 00108  *  - setup slave Heartbeat Producer time
nico@215: 00109  *  - switch to operational mode
nico@215: 00110  *  - send NMT to slave
nico@215: 00111  ********************************************************
nico@215: 00112  * This an example of :
nico@215: 00113  * Network Dictionary Access (SDO) with Callback 
nico@215: 00114  * Slave node state change request (NMT) 
nico@215: 00115  ********************************************************
nico@215: 00116  * This is called first by TestMaster_preOperational
nico@215: 00117  * then it called again each time a SDO exchange is
nico@215: 00118  * finished.
nico@215: 00119  ********************************************************/
etisserant@240: 00120 static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId)
nico@215: 00121 {
etisserant@240: 00122         UNS8 res;
etisserant@240: 00123         eprintf("Master : ConfigureSlaveNode %2.2x\n", nodeId);
nico@215: 00124         switch(++init_step){
nico@215: 00125                 case 1: 
nico@215: 00126                 {       /*disable Slave's TPDO 1 */
etisserant@240: 00127                         UNS32 TPDO_COBId = 0x80000180 + nodeId;
nico@215: 00128                         
etisserant@240: 00129                         eprintf("Master : disable slave %2.2x TPDO 1 \n", nodeId);
etisserant@240: 00130                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00132                                         nodeId, /*UNS8 nodeId*/
nico@215: 00133                                         0x1800, /*UNS16 index*/
nico@215: 00134                                         0x01, /*UNS8 subindex*/
nico@215: 00135                                         4, /*UNS8 count*/
nico@215: 00136                                         0, /*UNS8 dataType*/
nico@215: 00137                                         &TPDO_COBId,/*void *data*/
nico@215: 00138                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00139                 }                       
nico@215: 00140                 break;
nico@215: 00141 
nico@215: 00142                 case 2: 
nico@215: 00143                 {       /*setup Slave's TPDO 1 to be transmitted on SYNC*/
etisserant@240: 00144                         UNS8 Transmission_Type = 0x01;
nico@215: 00145                         
etisserant@240: 00146                         eprintf("Master : set slave %2.2x TPDO 1 transmit type\n", nodeId);
etisserant@240: 00147                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00149                                         nodeId, /*UNS8 nodeId*/
nico@215: 00150                                         0x1800, /*UNS16 index*/
nico@215: 00151                                         0x02, /*UNS8 subindex*/
nico@215: 00152                                         1, /*UNS8 count*/
nico@215: 00153                                         0, /*UNS8 dataType*/
nico@215: 00154                                         &Transmission_Type,/*void *data*/
nico@215: 00155                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00156                 }                       
nico@215: 00157                 break;
nico@215: 00158 
nico@215: 00159                 case 3: 
nico@215: 00160                 {       /*re-enable Slave's TPDO 1 */
etisserant@240: 00161                         UNS32 TPDO_COBId = 0x00000180 + nodeId;
nico@215: 00162                         
etisserant@240: 00163                         eprintf("Master : re-enable slave %2.2x TPDO 1\n", nodeId);
etisserant@240: 00164                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00166                                         nodeId, /*UNS8 nodeId*/
nico@215: 00167                                         0x1800, /*UNS16 index*/
nico@215: 00168                                         0x01, /*UNS8 subindex*/
nico@215: 00169                                         4, /*UNS8 count*/
nico@215: 00170                                         0, /*UNS8 dataType*/
nico@215: 00171                                         &TPDO_COBId,/*void *data*/
nico@215: 00172                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00173                 }                       
nico@215: 00174                 break;
nico@215: 00175                                         
nico@215: 00176                 case 4: 
nico@215: 00177                 {       /*disable Slave's TPDO 2 */
etisserant@240: 00178                         UNS32 TPDO_COBId = 0x80000200 + nodeId;
nico@215: 00179                         
etisserant@240: 00180                         eprintf("Master : disable slave %2.2x RPDO 1\n", nodeId);
etisserant@240: 00181                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00183                                         nodeId, /*UNS8 nodeId*/
nico@215: 00184                                         0x1400, /*UNS16 index*/
nico@215: 00185                                         0x01, /*UNS8 subindex*/
nico@215: 00186                                         4, /*UNS8 count*/
nico@215: 00187                                         0, /*UNS8 dataType*/
nico@215: 00188                                         &TPDO_COBId,/*void *data*/
nico@215: 00189                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00190                 }                       
nico@215: 00191                 break;
nico@215: 00192 
nico@215: 00193                                         
nico@215: 00194                 case 5:
nico@215: 00195                 {       
etisserant@240: 00196                         UNS8 Transmission_Type = 0x01;
nico@215: 00197                         
etisserant@240: 00198                         eprintf("Master : set slave %2.2x RPDO 1 receive type\n", nodeId);
etisserant@240: 00199                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00201                                         nodeId, /*UNS8 nodeId*/
nico@215: 00202                                         0x1400, /*UNS16 index*/
nico@215: 00203                                         0x02, /*UNS8 subindex*/
nico@215: 00204                                         1, /*UNS8 count*/
nico@215: 00205                                         0, /*UNS8 dataType*/
nico@215: 00206                                         &Transmission_Type,/*void *data*/
nico@215: 00207                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00208                 }       
nico@215: 00209                 break;
nico@215: 00210 
nico@215: 00211                 case 6: 
nico@215: 00212                 {       /*re-enable Slave's TPDO 1 */
etisserant@240: 00213                         UNS32 TPDO_COBId = 0x00000200 + nodeId;
nico@215: 00214                         
etisserant@240: 00215                         eprintf("Master : re-enable %2.2x RPDO 1\n", nodeId);
etisserant@240: 00216                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00218                                         nodeId, /*UNS8 nodeId*/
nico@215: 00219                                         0x1400, /*UNS16 index*/
nico@215: 00220                                         0x01, /*UNS8 subindex*/
nico@215: 00221                                         4, /*UNS8 count*/
nico@215: 00222                                         0, /*UNS8 dataType*/
nico@215: 00223                                         &TPDO_COBId,/*void *data*/
nico@215: 00224                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00225                 }                       
nico@215: 00226                 break;
nico@215: 00227                 
nico@215: 00228                 case 7: 
nico@215: 00229                 {
etisserant@240: 00230                         UNS16 Heartbeat_Producer_Time = 0x03E8; 
etisserant@240: 00231                         eprintf("Master : set slave %2.2x heartbeat producer time \n", nodeId);
etisserant@240: 00232                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00234                                         nodeId, /*UNS8 nodeId*/
nico@215: 00235                                         0x1017, /*UNS16 index*/
nico@215: 00236                                         0x00, /*UNS8 subindex*/
nico@215: 00237                                         2, /*UNS8 count*/
nico@215: 00238                                         0, /*UNS8 dataType*/
nico@215: 00239                                         &Heartbeat_Producer_Time,/*void *data*/
nico@215: 00240                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00241                 }                       
nico@215: 00242                 break;
nico@215: 00243 
nico@215: 00244                 case 8: 
nico@215: 00245                 {       /*disable Slave's TPDO 2 */
etisserant@240: 00246                         UNS32 TPDO_COBId = 0x80000280 + nodeId;
nico@215: 00247                         
etisserant@240: 00248                         eprintf("Master : disable slave %2.2x TPDO 2 \n", nodeId);
etisserant@240: 00249                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00251                                         nodeId, /*UNS8 nodeId*/
nico@215: 00252                                         0x1801, /*UNS16 index*/
nico@215: 00253                                         0x01, /*UNS8 subindex*/
nico@215: 00254                                         4, /*UNS8 count*/
nico@215: 00255                                         0, /*UNS8 dataType*/
nico@215: 00256                                         &TPDO_COBId,/*void *data*/
nico@215: 00257                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00258                 }                       
nico@215: 00259                 break;
nico@215: 00260 
nico@215: 00261                 case 9: 
nico@215: 00262                 {       /*disable Slave's TPDO 3 */
etisserant@240: 00263                         UNS32 TPDO_COBId = 0x80000380 + nodeId;
nico@215: 00264                         
etisserant@240: 00265                         eprintf("Master : disable slave %2.2x TPDO 3 \n", nodeId);
etisserant@240: 00266                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00268                                         nodeId, /*UNS8 nodeId*/
nico@215: 00269                                         0x1802, /*UNS16 index*/
nico@215: 00270                                         0x01, /*UNS8 subindex*/
nico@215: 00271                                         4, /*UNS8 count*/
nico@215: 00272                                         0, /*UNS8 dataType*/
nico@215: 00273                                         &TPDO_COBId,/*void *data*/
nico@215: 00274                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00275                 }
nico@215: 00276                 break;                  
nico@215: 00277 
nico@215: 00278                 case 10: 
nico@215: 00279                 {       /*disable Slave's TPDO 2 */
etisserant@240: 00280                         UNS32 TPDO_COBId = 0x80000480 + nodeId;
nico@215: 00281                         
etisserant@240: 00282                         eprintf("Master : disable slave %2.2x TPDO 4 \n", nodeId);
etisserant@240: 00283                         res = writeNetworkDictCallBack (d, /*CO_Data* d*/
nico@215: 00285                                         nodeId, /*UNS8 nodeId*/
nico@215: 00286                                         0x1803, /*UNS16 index*/
nico@215: 00287                                         0x01, /*UNS8 subindex*/
nico@215: 00288                                         4, /*UNS8 count*/
nico@215: 00289                                         0, /*UNS8 dataType*/
nico@215: 00290                                         &TPDO_COBId,/*void *data*/
nico@215: 00291                                         CheckSDOAndContinue); /*SDOCallback_t Callback*/
nico@215: 00292                 }                       
nico@215: 00293                 break;                  
nico@215: 00294                 
nico@215: 00295                 case 11:
nico@215: 00296                         /* Put the master in operational mode */
etisserant@240: 00297                         setState(d, Operational);
nico@215: 00298                           
nico@215: 00299                         /* Ask slave node to go in operational mode */
etisserant@240: 00300                         masterSendNMTstateChange (d, nodeId, NMT_Start_Node);
nico@215: 00301         }
nico@215: 00302                         
nico@215: 00303 }
nico@215: 00304 
etisserant@240: 00305 void TestMaster_preOperational()
nico@215: 00306 {
nico@215: 00307 
etisserant@240: 00308         eprintf("TestMaster_preOperational\n");
etisserant@240: 00309         ConfigureSlaveNode(&TestMaster_Data, slavenodeid);
nico@215: 00310         
nico@215: 00311 }
nico@215: 00312 
etisserant@240: 00313 void TestMaster_operational()
nico@215: 00314 {
etisserant@240: 00315         eprintf("TestMaster_operational\n");
nico@215: 00316 }
nico@215: 00317 
etisserant@240: 00318 void TestMaster_stopped()
nico@215: 00319 {
etisserant@240: 00320         eprintf("TestMaster_stopped\n");
nico@215: 00321 }
nico@215: 00322 
etisserant@240: 00323 void TestMaster_post_sync()
nico@215: 00324 {
etisserant@240: 00325         DO++;
etisserant@240: 00326         eprintf("MicroMod Digital Out: %2.2x\n",DO);
etisserant@240: 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);
nico@215: 00328 }
nico@215: 00329 
etisserant@240: 00330 void TestMaster_post_TPDO()
nico@215: 00331 {
nico@215: 00332 //      eprintf("TestMaster_post_TPDO\n");      
nico@215: 00333 }
nico@215: 00334 
nico@215: 00335 //s_BOARD SlaveBoard = {"0", "500K"};
etisserant@240: 00336 s_BOARD MasterBoard = {"32", "125K"};
nico@215: 00337 
nico@215: 00338 #if !defined(WIN32) || defined(__CYGWIN__)
etisserant@240: 00339 void catch_signal(int sig)
nico@215: 00340 {
etisserant@240: 00341   signal(SIGTERM, catch_signal);
etisserant@240: 00342   signal(SIGINT, catch_signal);
nico@215: 00343   
etisserant@240: 00344   eprintf("Got Signal %d\n",sig);
nico@215: 00345 }
nico@215: 00346 #endif
nico@215: 00347 
etisserant@240: 00348 void help()
nico@215: 00349 {
nico@215: 00350   printf("**************************************************************\n");
nico@215: 00351   printf("*  TestMasterMicroMod                                        *\n");
nico@215: 00352   printf("*                                                            *\n");
nico@215: 00353   printf("*  A simple example for PC.                                  *\n");
nico@215: 00354   printf("*  A CanOpen master that control a MicroMod module:          *\n");
nico@215: 00355   printf("*  - setup module TPDO 1 transmit type                       *\n");
nico@215: 00356   printf("*  - setup module RPDO 1 transmit type                       *\n");
nico@215: 00357   printf("*  - setup module hearbeatbeat period                        *\n");
nico@215: 00358   printf("*  - disable others TPDOs                                    *\n");
nico@215: 00359   printf("*  - set state to operational                                *\n");
nico@215: 00360   printf("*  - send periodic SYNC                                      *\n");
nico@215: 00361   printf("*  - send periodic RPDO 1 to Micromod (digital output)       *\n");
nico@215: 00362   printf("*  - listen Micromod's TPDO 1 (digital input)                *\n");
nico@215: 00363   printf("*  - Mapping RPDO 1 bit per bit (digital input)              *\n");
nico@215: 00364   printf("*                                                            *\n");
nico@215: 00365   printf("*   Usage:                                                   *\n");
nico@215: 00366   printf("*   ./TestMasterMicroMod  [OPTIONS]                          *\n");
nico@215: 00367   printf("*                                                            *\n");
nico@215: 00368   printf("*   OPTIONS:                                                 *\n");
nico@215: 00369   printf("*     -l : Can library [\"libcanfestival_can_virtual.so\"]     *\n");
nico@215: 00370   printf("*                                                            *\n");
nico@215: 00371   printf("*    Slave:                                                  *\n");
nico@215: 00372   printf("*     -i : Slave Node id format [0x01 , 0x7F]                *\n");
nico@215: 00373   printf("*                                                            *\n");
nico@215: 00374   printf("*    Master:                                                 *\n");
nico@215: 00375   printf("*     -m : bus name [\"1\"]                                    *\n");
nico@215: 00376   printf("*     -M : 1M,500K,250K,125K,100K,50K,20K,10K                *\n");
nico@215: 00377   printf("*                                                            *\n");
nico@215: 00378   printf("**************************************************************\n");
nico@215: 00379 }
nico@215: 00380 
nico@215: 00381 /***************************  INIT  *****************************************/
etisserant@240: 00382 void InitNodes(CO_Data* d, UNS32 id)
nico@215: 00383 {
nico@215: 00384         /****************************** INITIALISATION MASTER *******************************/
etisserant@240: 00385         if(MasterBoard.baudrate){
nico@215: 00386                 /* Defining the node Id */
etisserant@240: 00387                 setNodeId(&TestMaster_Data, 0x01);
nico@215: 00388 
nico@215: 00389                 /* init */
etisserant@240: 00390                 setState(&TestMaster_Data, Initialisation);
nico@215: 00391         }
nico@215: 00392 }
nico@215: 00393 
nico@215: 00394 /****************************************************************************/
nico@215: 00395 /***************************  MAIN  *****************************************/
nico@215: 00396 /****************************************************************************/
etisserant@240: 00397 int main(int argc,char **argv)
nico@215: 00398 {
nico@215: 00399 
nico@215: 00400   int c;
etisserant@240: 00401   extern char *optarg;
nico@215: 00402   char* LibraryPath="libcanfestival_can_virtual.so";
nico@215: 00403   char *snodeid;
etisserant@240: 00404   while ((c = getopt(argc, argv, "-m:s:M:S:l:i:")) != EOF)
nico@215: 00405   {
nico@215: 00406     switch(c)
nico@215: 00407     {
nico@215: 00408       case 'm' :
nico@215: 00409         if (optarg[0] == 0)
nico@215: 00410         {
etisserant@240: 00411           help();
nico@215: 00412           exit(1);
nico@215: 00413         }
etisserant@240: 00414         MasterBoard.busname = optarg;
nico@215: 00415         break;
nico@215: 00416       case 'M' :
nico@215: 00417         if (optarg[0] == 0)
nico@215: 00418         {
etisserant@240: 00419           help();
nico@215: 00420           exit(1);
nico@215: 00421         }
etisserant@240: 00422         MasterBoard.baudrate = optarg;
nico@215: 00423         break;
nico@215: 00424       case 'l' :
nico@215: 00425         if (optarg[0] == 0)
nico@215: 00426         {
etisserant@240: 00427           help();
nico@215: 00428           exit(1);
nico@215: 00429         }
nico@215: 00430         LibraryPath = optarg;
nico@215: 00431         break;
nico@215: 00432       case 'i' :
nico@215: 00433         if (optarg[0] == 0)
nico@215: 00434         {
etisserant@240: 00435           help();
nico@215: 00436           exit(1);
nico@215: 00437         }
nico@215: 00438         snodeid = optarg;
etisserant@240: 00439                 sscanf(snodeid,"%x",&slavenodeid);
nico@215: 00440         break;
nico@215: 00441       default:
etisserant@240: 00442         help();
nico@215: 00443         exit(1);
nico@215: 00444     }
nico@215: 00445   }
nico@215: 00446 
nico@215: 00447 #if !defined(WIN32) || defined(__CYGWIN__)
nico@215: 00448   /* install signal handler for manual break */
etisserant@240: 00449         signal(SIGTERM, catch_signal);
etisserant@240: 00450         signal(SIGINT, catch_signal);
nico@215: 00451 #endif
nico@215: 00452 
nico@215: 00453 #ifndef NOT_USE_DYNAMIC_LOADING
etisserant@240: 00454         LoadCanDriver(LibraryPath);
nico@215: 00455 #endif          
nico@215: 00456 
etisserant@240: 00457         TestMaster_Data.heartbeatError = TestMaster_heartbeatError;
etisserant@240: 00458         TestMaster_Data.initialisation = TestMaster_initialisation;
etisserant@240: 00459         TestMaster_Data.preOperational = TestMaster_preOperational;
etisserant@240: 00460         TestMaster_Data.operational = TestMaster_operational;
etisserant@240: 00461         TestMaster_Data.stopped = TestMaster_stopped;
etisserant@240: 00462         TestMaster_Data.post_sync = TestMaster_post_sync;
etisserant@240: 00463         TestMaster_Data.post_TPDO = TestMaster_post_TPDO;
nico@215: 00464         
etisserant@240: 00465         if(!canOpen(&MasterBoard,&TestMaster_Data)){
etisserant@240: 00466                 eprintf("Cannot open Master Board\n");
nico@215: 00467                 goto fail_master;
nico@215: 00468         }
nico@215: 00469         
nico@215: 00470         // Start timer thread
etisserant@240: 00471         StartTimerLoop(&InitNodes);
nico@215: 00472 
nico@215: 00473         // wait Ctrl-C
nico@215: 00474         pause();
etisserant@240: 00475         eprintf("Finishing.\n");
nico@215: 00476         
nico@215: 00477         // Reset the slave node for next use (will stop emitting heartbeat)
etisserant@240: 00478         masterSendNMTstateChange (&TestMaster_Data, slavenodeid, NMT_Reset_Node);
nico@215: 00479         
nico@215: 00480         // Stop master
etisserant@240: 00481         setState(&TestMaster_Data, Stopped);
nico@215: 00482         
nico@215: 00483         // Stop timer thread
etisserant@240: 00484         StopTimerLoop();
nico@215: 00485         
nico@215: 00486 fail_master:
etisserant@240: 00487         if(MasterBoard.baudrate) canClose(&TestMaster_Data);    
nico@215: 00488 
nico@215: 00489   return 0;
nico@215: 00490 }
nico@215: 00491 
nico@215: 00492 
etisserant@240: 

Generated on Mon Jul 2 19:10:16 2007 for CanFestival by  nico@215: nico@215: doxygen 1.5.1
nico@215: nico@215: