examples/win32test/main.c
changeset 149 fe50ada8020b
parent 145 e747d2e26af0
child 175 e255529b6f7d
equal deleted inserted replaced
148:ad3de8730172 149:fe50ada8020b
    31 #else
    31 #else
    32 #include <time.h> 
    32 #include <time.h> 
    33 #define sleep_proc(ms)
    33 #define sleep_proc(ms)
    34 #define uptime_ms_proc (1000*(time()%86400))  // TOD
    34 #define uptime_ms_proc (1000*(time()%86400))  // TOD
    35 #endif
    35 #endif
    36 
       
    37 /* required canfestival callbacks. */
       
    38 void win32test_SDOtimeoutError(UNS8 line)
       
    39   {
       
    40   }
       
    41   
       
    42 void win32test_heartbeatError(UNS8 node_id)
       
    43   {
       
    44   }
       
    45 
       
    46 void win32test_initialisation(void)
       
    47   {
       
    48   }
       
    49 
       
    50 void win32test_preOperational(void)
       
    51   {
       
    52   }
       
    53 
       
    54 void win32test_operational(void)
       
    55   {
       
    56   }
       
    57 
       
    58 void win32test_stopped(void)
       
    59   {
       
    60   }
       
    61 
       
    62 void win32test_post_sync(void)
       
    63   {
       
    64   }
       
    65 
       
    66 void win32test_post_TPDO(void)
       
    67   {
       
    68   }
       
    69 
       
    70 static CAN_HANDLE g_MasterCanHandle = NULL;
       
    71 
       
    72 UNS8 win32test_canSend(Message *m)
       
    73   {
       
    74   if (g_MasterCanHandle != NULL)
       
    75      return canSend(g_MasterCanHandle, m);
       
    76   return 1;
       
    77   }
       
    78 
    36 
    79 UNS8 GetChangeStateResults(UNS8 node_id, UNS8 expected_state, unsigned long timeout_ms)
    37 UNS8 GetChangeStateResults(UNS8 node_id, UNS8 expected_state, unsigned long timeout_ms)
    80    {
    38    {
    81    unsigned long start_time = 0;
    39    unsigned long start_time = 0;
    82    
    40    
   148       {
   106       {
   149       printf("ERROR: could not load diver %s\n", dll_file_name);
   107       printf("ERROR: could not load diver %s\n", dll_file_name);
   150       return 1;
   108       return 1;
   151       }
   109       }
   152    
   110    
   153    g_MasterCanHandle = canOpen(&MasterBoard,&win32test_Data);
   111    if (canOpen(&MasterBoard,&win32test_Data))
   154    
       
   155    if (g_MasterCanHandle)
       
   156       {
   112       {
   157       /* Defining the node Id */
   113       /* Defining the node Id */
   158       setNodeId(&win32test_Data, 0x01);
   114       setNodeId(&win32test_Data, 0x01);
   159 
   115 
   160       /* init */
   116       /* init */
   237          
   193          
   238       masterSendNMTstateChange (&win32test_Data, 0x02, NMT_Stop_Node);
   194       masterSendNMTstateChange (&win32test_Data, 0x02, NMT_Stop_Node);
   239 
   195 
   240       setState(&win32test_Data, Stopped);
   196       setState(&win32test_Data, Stopped);
   241       
   197       
   242       canClose(g_MasterCanHandle);
   198       canClose(&win32test_Data);
   243       }
   199       }
   244    return 0;
   200    return 0;
   245   }
   201   }
   246   
   202   
   247   
   203