Device information

Device information lets you know the details of hardware, such as the model name, encoder resolution, and input and output length. Before you configure hardware settings, it's better to display the device information so that you know which device you are working with and how its specification affects your settings.

To get device information, declare an instance of the SlaveStatus structure and apply it to GetAxisByIndex.

In AxisConfiguration.cpp, add the following code:

Copy
VOID PrintDeviceInformation(int Index)
{
    int Resolution = 0;
    KsError nRet = errNoError;
    SlaveStatus Sts = { 0 };

    nRet = GetAxisByIndex(Index, &Sts, &Resolution, NULL, NULL);
    if (nRet != errNoError)
        RtPrintf("GetAxisByIndex failed: %x\n", nRet);

    RtPrintf("Device Index: %d, Device Name: %s, Vendor ID: 0x%x, Product Code: 0x%x, Revision Number: 0x%x, Serial Number: 0x%x\n",
        Index, Sts.Name, Sts.VendorId, Sts.ProductCode, Sts.RevisionNumber, Sts.SerialNumber);
    RtPrintf("Slave ID: %d, Physical Address: %d, Alias Address: %d\n", Sts.SlaveId, Sts.PhysAddress, Sts.AliasAddress);
    RtPrintf("Input Length: %d, Output Length: %d, Variable Index Offset: 0x%x\n", Sts.InputLength, Sts.OutputLength, Sts.VariableIndexOffset);
    RtPrintf("EtherCAT State: %d, Cycle Time: %d\n", Sts.State, Sts.CycleTime);
    RtPrintf("Resolution: %d\n", Resolution);

    RtPrintf("\n");
}