Get name of EthercatTree device

plc11
2022-03-22
2022-03-30
  • plc11 - 2022-03-22

    Hello everybody,
    I need to get the name of each device in the EtherCAT device tree and save it to a string in case it goes wrong. Is there any method? I actually can access to the ETCSlave_Diag of each device but with this seems there is no way to get the name.
    Any suggestion?

    Thank you!

     
  • TimvH

    TimvH - 2022-03-30

    An option is to add the "application composer - device diagnosis". This will generate code including a textlist containing the names of the devices.

    See:
    https://help.codesys.com/webapp/ac_device_diagnose_overview;product=core_Application_Composer;version=3.5.17.0

    After configuring this module and generating the code, you can then get the name of all devices:

    IF DeviceDiagnosis.uiNumDDIs > 0 THEN
        FOR i := 0 TO DeviceDiagnosis.uiNumDDIs - 1 DO
            IF g_DDGInfos[i].pName <> 0 THEN
                sName := g_DDGInfos[i].pName^;
            END_IF
        END_FOR
    END_IF
    
     

Log in to post a comment.