examples/TestMasterSlave/TestSlave.c
changeset 307 230d55cb75a4
parent 287 fa4df65d0683
child 314 68e83c3ffbb5
equal deleted inserted replaced
306:3586cfa84705 307:230d55cb75a4
    27 #define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */
    27 #define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */
    28 UNS32 TestSlave_valueRangeTest (UNS8 typeValue, void * value)
    28 UNS32 TestSlave_valueRangeTest (UNS8 typeValue, void * value)
    29 {
    29 {
    30   switch (typeValue) {
    30   switch (typeValue) {
    31     case valueRange_EMC:
    31     case valueRange_EMC:
    32       if (*(UNS8*)value < (UNS8)0) return OD_VALUE_TOO_LOW;
    32       if (*(UNS8*)value != (UNS8)0) return OD_VALUE_RANGE_EXCEEDED;
    33       if (*(UNS8*)value > (UNS8)0) return OD_VALUE_TOO_HIGH;
       
    34       break;
    33       break;
    35   }
    34   }
    36   return 0;
    35   return 0;
    37 }
    36 }
    38 
    37 
    39 /**************************************************************************/
    38 /**************************************************************************/
    40 /* The node id                                                            */
    39 /* The node id                                                            */
    41 /**************************************************************************/
    40 /**************************************************************************/
    42 /* node_id default value.*/
    41 /* node_id default value.*/
    43 UNS8 TestSlave_bDeviceNodeId = 0x02;
    42 UNS8 TestSlave_bDeviceNodeId = 0x00;
    44 
    43 
    45 /**************************************************************************/
    44 /**************************************************************************/
    46 /* Array of message processing information */
    45 /* Array of message processing information */
    47 
    46 
    48 const UNS8 TestSlave_iam_a_slave = 1;
    47 const UNS8 TestSlave_iam_a_slave = 1;
   207                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Serial_Number }
   206                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1018_Serial_Number }
   208                      };
   207                      };
   209 
   208 
   210 /* index 0x1200 :   Server SDO Parameter. */
   209 /* index 0x1200 :   Server SDO Parameter. */
   211                     UNS8 TestSlave_highestSubIndex_obj1200 = 2; /* number of subindex - 1*/
   210                     UNS8 TestSlave_highestSubIndex_obj1200 = 2; /* number of subindex - 1*/
   212                     UNS32 TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO = 0x601;	/* 1537 */
   211                     UNS32 TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO = 0x600;	/* 1536 */
   213                     UNS32 TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO = 0x581;	/* 1409 */
   212                     UNS32 TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO = 0x580;	/* 1408 */
   214                     subindex TestSlave_Index1200[] = 
   213                     subindex TestSlave_Index1200[] = 
   215                      {
   214                      {
   216                        { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1200 },
   215                        { RO, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1200 },
   217                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO },
   216                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Client_to_Server_Receive_SDO },
   218                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO }
   217                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1200_COB_ID_Server_to_Client_Transmit_SDO }
   219                      };
   218                      };
   220 
   219 
   221 /* index 0x1800 :   Transmit PDO 1 Parameter. */
   220 /* index 0x1800 :   Transmit PDO 1 Parameter. */
   222                     UNS8 TestSlave_highestSubIndex_obj1800 = 5; /* number of subindex - 1*/
   221                     UNS8 TestSlave_highestSubIndex_obj1800 = 5; /* number of subindex - 1*/
   223                     UNS32 TestSlave_obj1800_COB_ID_used_by_PDO = 0x182;	/* 386 */
   222                     UNS32 TestSlave_obj1800_COB_ID_used_by_PDO = 0x180;	/* 384 */
   224                     UNS8 TestSlave_obj1800_Transmission_Type = 0x0;	/* 0 */
   223                     UNS8 TestSlave_obj1800_Transmission_Type = 0x0;	/* 0 */
   225                     UNS16 TestSlave_obj1800_Inhibit_Time = 0x0;	/* 0 */
   224                     UNS16 TestSlave_obj1800_Inhibit_Time = 0x0;	/* 0 */
   226                     UNS8 TestSlave_obj1800_Compatibility_Entry = 0x0;	/* 0 */
   225                     UNS8 TestSlave_obj1800_Compatibility_Entry = 0x0;	/* 0 */
   227                     UNS16 TestSlave_obj1800_Event_Timer = 0x0;	/* 0 */
   226                     UNS16 TestSlave_obj1800_Event_Timer = 0x0;	/* 0 */
   228                     ODCallback_t TestSlave_Index1800_callbacks[] = 
   227                     ODCallback_t TestSlave_Index1800_callbacks[] = 
   244                        { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Event_Timer }
   243                        { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1800_Event_Timer }
   245                      };
   244                      };
   246 
   245 
   247 /* index 0x1801 :   Transmit PDO 2 Parameter. */
   246 /* index 0x1801 :   Transmit PDO 2 Parameter. */
   248                     UNS8 TestSlave_highestSubIndex_obj1801 = 5; /* number of subindex - 1*/
   247                     UNS8 TestSlave_highestSubIndex_obj1801 = 5; /* number of subindex - 1*/
   249                     UNS32 TestSlave_obj1801_COB_ID_used_by_PDO = 0x282;	/* 642 */
   248                     UNS32 TestSlave_obj1801_COB_ID_used_by_PDO = 0x280;	/* 640 */
   250                     UNS8 TestSlave_obj1801_Transmission_Type = 0x0;	/* 0 */
   249                     UNS8 TestSlave_obj1801_Transmission_Type = 0x0;	/* 0 */
   251                     UNS16 TestSlave_obj1801_Inhibit_Time = 0x0;	/* 0 */
   250                     UNS16 TestSlave_obj1801_Inhibit_Time = 0x0;	/* 0 */
   252                     UNS8 TestSlave_obj1801_Compatibility_Entry = 0x0;	/* 0 */
   251                     UNS8 TestSlave_obj1801_Compatibility_Entry = 0x0;	/* 0 */
   253                     UNS16 TestSlave_obj1801_Event_Timer = 0x0;	/* 0 */
   252                     UNS16 TestSlave_obj1801_Event_Timer = 0x0;	/* 0 */
   254                     ODCallback_t TestSlave_Index1801_callbacks[] = 
   253                     ODCallback_t TestSlave_Index1801_callbacks[] = 
   270                        { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Event_Timer }
   269                        { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1801_Event_Timer }
   271                      };
   270                      };
   272 
   271 
   273 /* index 0x1802 :   Transmit PDO 3 Parameter. */
   272 /* index 0x1802 :   Transmit PDO 3 Parameter. */
   274                     UNS8 TestSlave_highestSubIndex_obj1802 = 5; /* number of subindex - 1*/
   273                     UNS8 TestSlave_highestSubIndex_obj1802 = 5; /* number of subindex - 1*/
   275                     UNS32 TestSlave_obj1802_COB_ID_used_by_PDO = 0x382;	/* 898 */
   274                     UNS32 TestSlave_obj1802_COB_ID_used_by_PDO = 0x380;	/* 896 */
   276                     UNS8 TestSlave_obj1802_Transmission_Type = 0xFF;	/* 255 */
   275                     UNS8 TestSlave_obj1802_Transmission_Type = 0xFF;	/* 255 */
   277                     UNS16 TestSlave_obj1802_Inhibit_Time = 0x1388;	/* 5000 */
   276                     UNS16 TestSlave_obj1802_Inhibit_Time = 0x1388;	/* 5000 */
   278                     UNS8 TestSlave_obj1802_Compatibility_Entry = 0x0;	/* 0 */
   277                     UNS8 TestSlave_obj1802_Compatibility_Entry = 0x0;	/* 0 */
   279                     UNS16 TestSlave_obj1802_Event_Timer = 0x3E8;	/* 1000 */
   278                     UNS16 TestSlave_obj1802_Event_Timer = 0x3E8;	/* 1000 */
   280                     ODCallback_t TestSlave_Index1802_callbacks[] = 
   279                     ODCallback_t TestSlave_Index1802_callbacks[] = 
   296                        { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1802_Event_Timer }
   295                        { RW, uint16, sizeof (UNS16), (void*)&TestSlave_obj1802_Event_Timer }
   297                      };
   296                      };
   298 
   297 
   299 /* index 0x1803 :   Transmit PDO 4 Parameter. */
   298 /* index 0x1803 :   Transmit PDO 4 Parameter. */
   300                     UNS8 TestSlave_highestSubIndex_obj1803 = 5; /* number of subindex - 1*/
   299                     UNS8 TestSlave_highestSubIndex_obj1803 = 5; /* number of subindex - 1*/
   301                     UNS32 TestSlave_obj1803_COB_ID_used_by_PDO = 0x482;	/* 1154 */
   300                     UNS32 TestSlave_obj1803_COB_ID_used_by_PDO = 0x480;	/* 1152 */
   302                     UNS8 TestSlave_obj1803_Transmission_Type = 0xFC;	/* 252 */
   301                     UNS8 TestSlave_obj1803_Transmission_Type = 0xFC;	/* 252 */
   303                     UNS16 TestSlave_obj1803_Inhibit_Time = 0x0;	/* 0 */
   302                     UNS16 TestSlave_obj1803_Inhibit_Time = 0x0;	/* 0 */
   304                     UNS8 TestSlave_obj1803_Compatibility_Entry = 0x0;	/* 0 */
   303                     UNS8 TestSlave_obj1803_Compatibility_Entry = 0x0;	/* 0 */
   305                     UNS16 TestSlave_obj1803_Event_Timer = 0x0;	/* 0 */
   304                     UNS16 TestSlave_obj1803_Event_Timer = 0x0;	/* 0 */
   306                     ODCallback_t TestSlave_Index1803_callbacks[] = 
   305                     ODCallback_t TestSlave_Index1803_callbacks[] =