diff -r f45fd4cd3832 -r 34654679f262 doc/doxygen/html/main_8c-source.html --- a/doc/doxygen/html/main_8c-source.html Fri Jul 06 10:53:15 2007 +0200 +++ b/doc/doxygen/html/main_8c-source.html Mon Jul 16 08:56:03 2007 +0200 @@ -18,7 +18,7 @@
00001 /************************************************************************** 00002 CanFestival3 win32 port example 00003 @@ -51,56 +51,56 @@ 00030 #define uptime_ms_proc() GetTickCount() 00031 #else 00032 #include <time.h> -00033 #define sleep_proc(ms) -00034 #define uptime_ms_proc (1000*(time()%86400)) // TOD +00033 #define sleep_proc(ms) +00034 #define uptime_ms_proc (1000*(time()%86400)) // TOD 00035 #endif 00036 -00037 UNS8 GetChangeStateResults(UNS8 node_id, UNS8 expected_state, unsigned long timeout_ms) +00037 UNS8 GetChangeStateResults(UNS8 node_id, UNS8 expected_state, unsigned long timeout_ms) 00038 { 00039 unsigned long start_time = 0; 00040 00041 // reset nodes state -00042 win32test_Data.NMTable[node_id] = Unknown_state; +00042 win32test_Data.NMTable[node_id] = Unknown_state; 00043 00044 // request node state -00045 masterRequestNodeState(&win32test_Data, node_id); +00045 masterRequestNodeState(&win32test_Data, node_id); 00046 -00047 start_time = uptime_ms_proc(); -00048 while(uptime_ms_proc() - start_time < timeout_ms) +00047 start_time = uptime_ms_proc(); +00048 while(uptime_ms_proc() - start_time < timeout_ms) 00049 { -00050 if (getNodeState(&win32test_Data, node_id) == expected_state) +00050 if (getNodeState(&win32test_Data, node_id) == expected_state) 00051 return 0; -00052 sleep_proc(1); +00052 sleep_proc(1); 00053 } 00054 return 0xFF; 00055 } 00056 -00057 UNS8 ReadSDO(UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, void* data, UNS8* size) +00057 UNS8 ReadSDO(UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, void* data, UNS8* size) 00058 { -00059 UNS32 abortCode = 0; -00060 UNS8 res = SDO_UPLOAD_IN_PROGRESS; +00059 UNS32 abortCode = 0; +00060 UNS8 res = SDO_UPLOAD_IN_PROGRESS; 00061 // Read SDO -00062 UNS8 err = readNetworkDict (&win32test_Data, nodeId, index, subIndex, dataType); +00062 UNS8 err = readNetworkDict (&win32test_Data, nodeId, index, subIndex, dataType); 00063 if (err) 00064 return 0xFF; 00065 for(;;) 00066 { -00067 res = getReadResultNetworkDict (&win32test_Data, nodeId, data, size, &abortCode); -00068 if (res != SDO_UPLOAD_IN_PROGRESS) +00067 res = getReadResultNetworkDict (&win32test_Data, nodeId, data, size, &abortCode); +00068 if (res != SDO_UPLOAD_IN_PROGRESS) 00069 break; -00070 sleep_proc(1); +00070 sleep_proc(1); 00071 continue; 00072 } -00073 closeSDOtransfer(&win32test_Data, nodeId, SDO_CLIENT); -00074 if (res == SDO_FINISHED) +00073 closeSDOtransfer(&win32test_Data, nodeId, SDO_CLIENT); +00074 if (res == SDO_FINISHED) 00075 return 0; 00076 return 0xFF; 00077 } 00078 -00079 int main(int argc, char *argv[]) +00079 int main(int argc, char *argv[]) 00080 { -00081 UNS8 node_id = 0; -00082 s_BOARD MasterBoard = {"1", "125K"}; +00081 UNS8 node_id = 0; +00082 s_BOARD MasterBoard = {"1", "125K"}; 00083 char* dll_file_name; 00084 00085 /* process command line arguments */ @@ -123,81 +123,81 @@ 00102 dll_file_name = "can_uvccm_win32.dll"; 00103 00104 // load can driver -00105 if (!LoadCanDriver(dll_file_name)) +00105 if (!LoadCanDriver(dll_file_name)) 00106 { 00107 printf("ERROR: could not load diver %s\n", dll_file_name); 00108 return 1; 00109 } 00110 -00111 if (canOpen(&MasterBoard,&win32test_Data)) +00111 if (canOpen(&MasterBoard,&win32test_Data)) 00112 { 00113 /* Defining the node Id */ -00114 setNodeId(&win32test_Data, 0x01); +00114 setNodeId(&win32test_Data, 0x01); 00115 00116 /* init */ -00117 setState(&win32test_Data, Initialisation); +00117 setState(&win32test_Data, Initialisation); 00118 00119 /****************************** START *******************************/ 00120 /* Put the master in operational mode */ -00121 setState(&win32test_Data, Operational); +00121 setState(&win32test_Data, Operational); 00122 00123 /* Ask slave node to go in operational mode */ -00124 masterSendNMTstateChange (&win32test_Data, 0, NMT_Start_Node); +00124 masterSendNMTstateChange (&win32test_Data, 0, NMT_Start_Node); 00125 00126 printf("\nStarting node %d (%xh) ...\n",(int)node_id,(int)node_id); 00127 00128 /* wait untill mode will switch to operational state*/ -00129 if (GetChangeStateResults(node_id, Operational, 3000) != 0xFF) +00129 if (GetChangeStateResults(node_id, Operational, 3000) != 0xFF) 00130 { 00131 /* modify Client SDO 1 Parameter */ -00132 UNS32 COB_ID_Client_to_Server_Transmit_SDO = 0x600 + node_id; -00133 UNS32 COB_ID_Server_to_Client_Receive_SDO = 0x580 + node_id; -00134 UNS32 Node_ID_of_the_SDO_Server = node_id; -00135 UNS8 ExpectedSize = sizeof (UNS32); +00132 UNS32 COB_ID_Client_to_Server_Transmit_SDO = 0x600 + node_id; +00133 UNS32 COB_ID_Server_to_Client_Receive_SDO = 0x580 + node_id; +00134 UNS32 Node_ID_of_the_SDO_Server = node_id; +00135 UNS8 ExpectedSize = sizeof (UNS32); 00136 -00137 if (OD_SUCCESSFUL == writeLocalDict(&win32test_Data, 0x1280, 1, &COB_ID_Client_to_Server_Transmit_SDO, &ExpectedSize, RW) -00138 && OD_SUCCESSFUL == writeLocalDict(&win32test_Data, 0x1280, 2, &COB_ID_Server_to_Client_Receive_SDO, &ExpectedSize, RW) -00139 && OD_SUCCESSFUL == writeLocalDict(&win32test_Data, 0x1280, 3, &Node_ID_of_the_SDO_Server, &ExpectedSize, RW)) +00137 if (OD_SUCCESSFUL == writeLocalDict(&win32test_Data, 0x1280, 1, &COB_ID_Client_to_Server_Transmit_SDO, &ExpectedSize, RW) +00138 && OD_SUCCESSFUL == writeLocalDict(&win32test_Data, 0x1280, 2, &COB_ID_Server_to_Client_Receive_SDO, &ExpectedSize, RW) +00139 && OD_SUCCESSFUL == writeLocalDict(&win32test_Data, 0x1280, 3, &Node_ID_of_the_SDO_Server, &ExpectedSize, RW)) 00140 { -00141 UNS32 dev_type = 0; +00141 UNS32 dev_type = 0; 00142 char device_name[64]=""; 00143 char hw_ver[64]=""; 00144 char sw_ver[64]=""; -00145 UNS32 vendor_id = 0; -00146 UNS32 prod_code = 0; -00147 UNS32 ser_num = 0; -00148 UNS8 size; -00149 UNS8 res; +00145 UNS32 vendor_id = 0; +00146 UNS32 prod_code = 0; +00147 UNS32 ser_num = 0; +00148 UNS8 size; +00149 UNS8 res; 00150 00151 printf("\nnode_id: %d (%xh) info\n",(int)node_id,(int)node_id); 00152 printf("********************************************\n"); 00153 00154 size = sizeof (dev_type); -00155 res = ReadSDO(node_id, 0x1000, 0, uint32, &dev_type, &size); +00155 res = ReadSDO(node_id, 0x1000, 0, uint32, &dev_type, &size); 00156 printf("device type: %d\n",dev_type & 0xFFFF); 00157 00158 size = sizeof (device_name); -00159 res = ReadSDO(node_id, 0x1008, 0, visible_string, device_name, &size); +00159 res = ReadSDO(node_id, 0x1008, 0, visible_string, device_name, &size); 00160 printf("device name: %s\n",device_name); 00161 00162 size = sizeof (hw_ver); -00163 res = ReadSDO(node_id, 0x1009, 0, visible_string, hw_ver, &size); +00163 res = ReadSDO(node_id, 0x1009, 0, visible_string, hw_ver, &size); 00164 printf("HW version: %s\n",hw_ver); 00165 00166 size = sizeof (sw_ver); -00167 res = ReadSDO(node_id, 0x100A, 0, visible_string, sw_ver, &size); +00167 res = ReadSDO(node_id, 0x100A, 0, visible_string, sw_ver, &size); 00168 printf("SW version: %s\n",sw_ver); 00169 00170 size = sizeof (vendor_id); -00171 res = ReadSDO(node_id, 0x1018, 1, uint32, &vendor_id, &size); +00171 res = ReadSDO(node_id, 0x1018, 1, uint32, &vendor_id, &size); 00172 printf("vendor id: %d\n",vendor_id); 00173 00174 size = sizeof (prod_code); -00175 res = ReadSDO(node_id, 0x1018, 2, uint32, &prod_code, &size); +00175 res = ReadSDO(node_id, 0x1018, 2, uint32, &prod_code, &size); 00176 printf("product code: %d\n",prod_code); 00177 00178 size = sizeof (ser_num); -00179 res = ReadSDO(node_id, 0x1018, 4, uint32, &ser_num, &size); +00179 res = ReadSDO(node_id, 0x1018, 4, uint32, &ser_num, &size); 00180 printf("serial number: %d\n",ser_num); 00181 00182 printf("********************************************\n"); @@ -212,17 +212,17 @@ 00191 printf("ERROR: node_id %d (%xh) is not responding\n",(int)node_id,(int)node_id); 00192 } 00193 -00194 masterSendNMTstateChange (&win32test_Data, 0x02, NMT_Stop_Node); +00194 masterSendNMTstateChange (&win32test_Data, 0x02, NMT_Stop_Node); 00195 -00196 setState(&win32test_Data, Stopped); +00196 setState(&win32test_Data, Stopped); 00197 -00198 canClose(&win32test_Data); +00198 canClose(&win32test_Data); 00199 } 00200 return 0; 00201 } 00202 00203 -