examples/TestMasterMicroMod/TestMasterMicroMod.c
changeset 169 90c0a676e631
parent 166 b6fbc1c59a44
child 172 0248c2b148bb
equal deleted inserted replaced
168:f379cdef1f8e 169:90c0a676e631
    26 void pause(void)
    26 void pause(void)
    27 {
    27 {
    28 	system("PAUSE");
    28 	system("PAUSE");
    29 }
    29 }
    30 #else
    30 #else
       
    31 #include <unistd.h>
    31 #include <stdio.h>
    32 #include <stdio.h>
    32 #include <string.h>
    33 #include <string.h>
    33 #include <stdlib.h>
    34 #include <stdlib.h>
    34 #include <signal.h>
    35 #include <signal.h>
    35 #endif
    36 #endif
   239   printf("**************************************************************\n");
   240   printf("**************************************************************\n");
   240   printf("*  TestMasterMicroMod                                        *\n");
   241   printf("*  TestMasterMicroMod                                        *\n");
   241   printf("*                                                            *\n");
   242   printf("*                                                            *\n");
   242   printf("*  A simple example for PC.                                  *\n");
   243   printf("*  A simple example for PC.                                  *\n");
   243   printf("*  A CanOpen master that control a MicroMod module:          *\n");
   244   printf("*  A CanOpen master that control a MicroMod module:          *\n");
   244   printf("*  - setup module TPDO 1 transmit type (ignored ???)         *\n");
   245   printf("*  - setup module TPDO 1 transmit type (ignored ?)           *\n");
   245   printf("*  - setup module RPDO 1 transmit type (ignored ???)         *\n");
   246   printf("*  - setup module RPDO 1 transmit type (ignored ?)           *\n");
   246   printf("*  - setup module hearbeatbeat period                        *\n");
   247   printf("*  - setup module hearbeatbeat period                        *\n");
   247   printf("*  - set state to operational                                *\n");
   248   printf("*  - set state to operational                                *\n");
   248   printf("*  - send periodic SYNC (ignored ???)                        *\n");
   249   printf("*  - send periodic SYNC (ignored ?)                          *\n");
   249   printf("*  - send periodic RPDO 1 to Micromod (digital output)       *\n");
   250   printf("*  - send periodic RPDO 1 to Micromod (digital output)       *\n");
   250   printf("*  - listen Micromod's TPDO 1 (digital input)                *\n");
   251   printf("*  - listen Micromod's TPDO 1 (digital input)                *\n");
   251   printf("*                                                            *\n");
   252   printf("*                                                            *\n");
   252   printf("*   Usage:                                                   *\n");
   253   printf("*   Usage:                                                   *\n");
   253   printf("*   ./TestMasterMicroMod  [OPTIONS]                          *\n");
   254   printf("*   ./TestMasterMicroMod  [OPTIONS]                          *\n");
   258   printf("*    Slave:                                                  *\n");
   259   printf("*    Slave:                                                  *\n");
   259   printf("*     -i : Slave Node id format [0x01 , 0x7F]                *\n");
   260   printf("*     -i : Slave Node id format [0x01 , 0x7F]                *\n");
   260   printf("*                                                            *\n");
   261   printf("*                                                            *\n");
   261   printf("*    Master:                                                 *\n");
   262   printf("*    Master:                                                 *\n");
   262   printf("*     -m : bus name [\"1\"]                                    *\n");
   263   printf("*     -m : bus name [\"1\"]                                    *\n");
   263   printf("*     -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable)  *\n");
   264   printf("*     -M : 1M,500K,250K,125K,100K,50K,20K,10K                *\n");
   264   printf("*                                                            *\n");
   265   printf("*                                                            *\n");
   265   printf("**************************************************************\n");
   266   printf("**************************************************************\n");
   266 }
   267 }
   267 
   268 
   268 /***************************  INIT  *****************************************/
   269 /***************************  INIT  *****************************************/
   339 
   340 
   340 #ifndef NOT_USE_DYNAMIC_LOADING
   341 #ifndef NOT_USE_DYNAMIC_LOADING
   341 	LoadCanDriver(LibraryPath);
   342 	LoadCanDriver(LibraryPath);
   342 #endif		
   343 #endif		
   343 
   344 
   344 	if(MasterBoard.baudrate){
   345 	TestMaster_Data.heartbeatError = TestMaster_heartbeatError;
   345 		
   346 	TestMaster_Data.SDOtimeoutError = TestMaster_SDOtimeoutError;
   346 		TestMaster_Data.heartbeatError = TestMaster_heartbeatError;
   347 	TestMaster_Data.initialisation = TestMaster_initialisation;
   347 		TestMaster_Data.SDOtimeoutError = TestMaster_SDOtimeoutError;
   348 	TestMaster_Data.preOperational = TestMaster_preOperational;
   348 		TestMaster_Data.initialisation = TestMaster_initialisation;
   349 	TestMaster_Data.operational = TestMaster_operational;
   349 		TestMaster_Data.preOperational = TestMaster_preOperational;
   350 	TestMaster_Data.stopped = TestMaster_stopped;
   350 		TestMaster_Data.operational = TestMaster_operational;
   351 	TestMaster_Data.post_sync = TestMaster_post_sync;
   351 		TestMaster_Data.stopped = TestMaster_stopped;
   352 	TestMaster_Data.post_TPDO = TestMaster_post_TPDO;
   352 		TestMaster_Data.post_sync = TestMaster_post_sync;
   353 	
   353 		TestMaster_Data.post_TPDO = TestMaster_post_TPDO;
   354 	if(!canOpen(&MasterBoard,&TestMaster_Data)){
   354 		
   355 		eprintf("Cannot open Master Board\n");
   355 		if(!canOpen(&MasterBoard,&TestMaster_Data)){
   356 		goto fail_master;
   356 			eprintf("Cannot open Master Board\n");
       
   357 			goto fail_master;
       
   358 		}
       
   359 	}
   357 	}
   360 	
   358 	
   361 	// Start timer thread
   359 	// Start timer thread
   362 	StartTimerLoop(&InitNodes);
   360 	StartTimerLoop(&InitNodes);
   363 
   361