examples/DS401_Slave_Gui/TestSlaveGui.cpp
changeset 454 bc000083297a
parent 382 860e858685d3
child 458 a3906286b09b
equal deleted inserted replaced
453:c74a73474cce 454:bc000083297a
    58   setNodeId (&ObjDict_Data, node_id_ext);
    58   setNodeId (&ObjDict_Data, node_id_ext);
    59   /* init */
    59   /* init */
    60   setState (&ObjDict_Data, Initialisation);
    60   setState (&ObjDict_Data, Initialisation);
    61 }
    61 }
    62 
    62 
       
    63 /***************************  EXIT  *****************************************/
       
    64 void Exit(CO_Data* d, UNS32 id)
       
    65 {
       
    66   	setState (&ObjDict_Data, Stopped);
       
    67 	canClose (&ObjDict_Data);
       
    68 }
    63 //****************************************************************************
    69 //****************************************************************************
    64 //***************************  MAIN  *****************************************
    70 //***************************  MAIN  *****************************************
    65 //****************************************************************************
    71 //****************************************************************************
    66 int
    72 int
    67 main_can (s_BOARD SlaveBoard, char *LibraryPath)
    73 main_can (s_BOARD SlaveBoard, char *LibraryPath)
    68 {
    74 {
    69   printf ("Bus name: %s        Freq: %s       Driver: %s\n",
    75   printf ("Bus name: %s        Freq: %s       Driver: %s\n",
    70 	  SlaveBoard.busname, SlaveBoard.baudrate, LibraryPath);
    76 	  SlaveBoard.busname, SlaveBoard.baudrate, LibraryPath);
    71 
    77 
       
    78   TimerInit();
    72 #ifndef NOT_USE_DYNAMIC_LOADING
    79 #ifndef NOT_USE_DYNAMIC_LOADING
    73   if (LoadCanDriver (LibraryPath) == NULL)
    80   if (LoadCanDriver (LibraryPath) == NULL)
    74     *textLog << wxT ("Unable to load library\n");
    81     *textLog << wxT ("Unable to load library\n");
    75 #endif
    82 #endif
    76   // Open CAN devices
    83   // Open CAN devices
    97 }
   104 }
    98 
   105 
    99 void
   106 void
   100 stop_slave ()
   107 stop_slave ()
   101 {
   108 {
   102   EnterMutex ();
   109   StopTimerLoop (&Exit);
   103   setState (&ObjDict_Data, Stopped);
   110   TimerCleanup();
   104   LeaveMutex ();
       
   105 
       
   106   StopTimerLoop ();
       
   107   canClose (&ObjDict_Data);
       
   108 
       
   109   return;
   111   return;
   110 }
   112 }