}
#endif
-void help()
+void help(void)
{
printf("**************************************************************\n");
printf("* TestMasterSlave *\n");
{
/****************************** INITIALISATION SLAVE *******************************/
if(strcmp(SlaveBoard.baudrate, "none")) {
- /* Defining the node Id */
setNodeId(&TestSlave_Data, 0x02);
+
/* init */
setState(&TestSlave_Data, Initialisation);
}
}
}
+/*************************** EXIT *****************************************/
+void Exit(CO_Data* d, UNS32 id)
+{
+ masterSendNMTstateChange(&TestMaster_Data, 0x02, NMT_Reset_Node);
+
+ //Stop master
+ setState(&TestMaster_Data, Stopped);
+}
+
/****************************************************************************/
/*************************** MAIN *****************************************/
/****************************************************************************/
int c;
extern char *optarg;
- char* LibraryPath="libcanfestival_can_virtual.so";
+ char* LibraryPath="../../drivers/can_virtual/libcanfestival_can_virtual.so";
while ((c = getopt(argc, argv, "-m:s:M:S:l:")) != EOF)
{
/* install signal handler for manual break */
signal(SIGTERM, catch_signal);
signal(SIGINT, catch_signal);
+ TimerInit();
#endif
#ifndef NOT_USE_DYNAMIC_LOADING
- LoadCanDriver(LibraryPath);
+ if (LoadCanDriver(LibraryPath) == NULL)
+ printf("Unable to load library: %s\n",LibraryPath);
#endif
// Open CAN devices
TestSlave_Data.stopped = TestSlave_stopped;
TestSlave_Data.post_sync = TestSlave_post_sync;
TestSlave_Data.post_TPDO = TestSlave_post_TPDO;
- TestSlave_Data.storeODSubIndex = TestSlave_storeODSubIndex;
+ TestSlave_Data.storeODSubIndex = TestSlave_storeODSubIndex;
+ TestSlave_Data.post_emcy = TestSlave_post_emcy;
if(!canOpen(&SlaveBoard,&TestSlave_Data)){
eprintf("Cannot open Slave Board (%s,%s)\n",SlaveBoard.busname, SlaveBoard.baudrate);
TestMaster_Data.stopped = TestMaster_stopped;
TestMaster_Data.post_sync = TestMaster_post_sync;
TestMaster_Data.post_TPDO = TestMaster_post_TPDO;
+ TestMaster_Data.post_emcy = TestMaster_post_emcy;
+ TestMaster_Data.post_SlaveBootup=TestMaster_post_SlaveBootup;
if(!canOpen(&MasterBoard,&TestMaster_Data)){
eprintf("Cannot open Master Board (%s,%s)\n",MasterBoard.busname, MasterBoard.baudrate);
goto fail_master;
}
}
- sleep(2);
+
// Start timer thread
StartTimerLoop(&InitNodes);
// wait Ctrl-C
-
pause();
- eprintf("Finishing.\n");
-
- masterSendNMTstateChange (&TestMaster_Data, 0x02, NMT_Reset_Node);
- eprintf("reset\n");
- // Stop master
- setState(&TestMaster_Data, Stopped);
-
+
// Stop timer thread
- StopTimerLoop();
+ StopTimerLoop(&Exit);
// Close CAN devices (and can threads)
- if(strcmp(SlaveBoard.baudrate, "none")) canClose(&TestSlave_Data);
-fail_master:
if(strcmp(MasterBoard.baudrate, "none")) canClose(&TestMaster_Data);
+fail_master:
+ if(strcmp(SlaveBoard.baudrate, "none")) canClose(&TestSlave_Data);
fail_slave:
+ TimerCleanup();
return 0;
}