The state of an EtherCAT network and the state of the KINGSTAR Subsystem

The details of an EtherCAT network and the state of the KINGSTAR Subsystem can be gotten through the GetStatus function.

GetStatus

GetStatus gets the details of an EtherCAT network. To use this function, you need to create an instance of the SubsystemStatus and SubsystemDiagnostics structure, and then pass the address of the instance to the function.

In the following example, we declare the instance Subsystem of the SubsystemStatus structure, which is passed to GetStatus to get the details of the network. We didn't declare the instance of the SubsystemDiagnostics structure because we don't need to use it.

SubsystemStatus contains the information of EtherCAT network. EthercatState describes the state of an EtherCAT connection.

Copy
SubsystemStatus Subsystem = { ecatOffline, ecatOffline, 0, 0, 0, {ecatOffline}, {ecatOffline}, {axisOffline} };
   GetStatus(&Subsystem, NULL);
   if (Subsystem.State == ecatOP)
   {
      RtPrintf("Subsystem already started: %x\n", nRet);
      return TRUE;
   }
   else if (Subsystem.State != ecatOffline)
   {
      RtPrintf("Subsystem in unexpected state: %d\n", Subsystem.State);
      return FALSE;
   }