examples/TestMasterSlave/TestMasterSlave.c
changeset 343 118c1cabd0b0
parent 331 da55aa2f9e64
child 381 854c43cdc24a
equal deleted inserted replaced
342:66f007300c10 343:118c1cabd0b0
    92 /***************************  INIT  *****************************************/
    92 /***************************  INIT  *****************************************/
    93 void InitNodes(CO_Data* d, UNS32 id)
    93 void InitNodes(CO_Data* d, UNS32 id)
    94 {
    94 {
    95 	/****************************** INITIALISATION SLAVE *******************************/
    95 	/****************************** INITIALISATION SLAVE *******************************/
    96 	if(strcmp(SlaveBoard.baudrate, "none")) {
    96 	if(strcmp(SlaveBoard.baudrate, "none")) {
    97 		/* Defining the node Id */
    97 
       
    98 #ifdef CO_ENABLE_LSS
       
    99 		/* Set an invalid nodeID */
       
   100 		setNodeId(&TestSlave_Data, 0xFF);
       
   101 #else
    98 		setNodeId(&TestSlave_Data, 0x02);
   102 		setNodeId(&TestSlave_Data, 0x02);
       
   103 #endif
       
   104 
    99 		/* init */
   105 		/* init */
   100 		setState(&TestSlave_Data, Initialisation);
   106 		setState(&TestSlave_Data, Initialisation);
   101 	}
   107 	}
   102 
   108 
   103 	/****************************** INITIALISATION MASTER *******************************/
   109 	/****************************** INITIALISATION MASTER *******************************/
   119 int main(int argc,char **argv)
   125 int main(int argc,char **argv)
   120 {
   126 {
   121 
   127 
   122   int c;
   128   int c;
   123   extern char *optarg;
   129   extern char *optarg;
   124   char* LibraryPath="libcanfestival_can_virtual.so";
   130   char* LibraryPath="../../drivers/can_virtual/libcanfestival_can_virtual.so";
   125 
   131 
   126   while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF)
   132   while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF)
   127   {
   133   {
   128     switch(c)
   134     switch(c)
   129     {
   135     {
   194 		TestSlave_Data.stopped = TestSlave_stopped;
   200 		TestSlave_Data.stopped = TestSlave_stopped;
   195 		TestSlave_Data.post_sync = TestSlave_post_sync;
   201 		TestSlave_Data.post_sync = TestSlave_post_sync;
   196 		TestSlave_Data.post_TPDO = TestSlave_post_TPDO;
   202 		TestSlave_Data.post_TPDO = TestSlave_post_TPDO;
   197 		TestSlave_Data.storeODSubIndex = TestSlave_storeODSubIndex;
   203 		TestSlave_Data.storeODSubIndex = TestSlave_storeODSubIndex;
   198 		TestSlave_Data.post_emcy = TestSlave_post_emcy;
   204 		TestSlave_Data.post_emcy = TestSlave_post_emcy;
       
   205 #ifdef CO_ENABLE_LSS
       
   206 		/* in this example the slave doesn't support Store configuration*/
       
   207 		//TestSlave_Data.lss_StoreConfiguration = TestSlave_StoreConfiguration;
       
   208 		TestSlave_Data.lss_ChangeBaudRate=TestSlave_ChangeBaudRate;
       
   209 #endif
   199 
   210 
   200 		if(!canOpen(&SlaveBoard,&TestSlave_Data)){
   211 		if(!canOpen(&SlaveBoard,&TestSlave_Data)){
   201 			eprintf("Cannot open Slave Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate);
   212 			eprintf("Cannot open Slave Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate);
   202 			goto fail_slave;
   213 			goto fail_slave;
   203 		}
   214 		}
   210 		TestMaster_Data.operational = TestMaster_operational;
   221 		TestMaster_Data.operational = TestMaster_operational;
   211 		TestMaster_Data.stopped = TestMaster_stopped;
   222 		TestMaster_Data.stopped = TestMaster_stopped;
   212 		TestMaster_Data.post_sync = TestMaster_post_sync;
   223 		TestMaster_Data.post_sync = TestMaster_post_sync;
   213 		TestMaster_Data.post_TPDO = TestMaster_post_TPDO;
   224 		TestMaster_Data.post_TPDO = TestMaster_post_TPDO;
   214 		TestMaster_Data.post_emcy = TestMaster_post_emcy;
   225 		TestMaster_Data.post_emcy = TestMaster_post_emcy;
       
   226 		TestMaster_Data.post_SlaveBootup=TestMaster_post_SlaveBootup;
   215 		
   227 		
   216 		if(!canOpen(&MasterBoard,&TestMaster_Data)){
   228 		if(!canOpen(&MasterBoard,&TestMaster_Data)){
   217 			eprintf("Cannot open Master Board (%s,%s)\n",MasterBoard.busname, MasterBoard.baudrate);
   229 			eprintf("Cannot open Master Board (%s,%s)\n",MasterBoard.busname, MasterBoard.baudrate);
   218 			goto fail_master;
   230 			goto fail_master;
   219 		}
   231 		}