Skip to content

Buffer overflow for certain SDO writes #81

@408b7f8b

Description

@408b7f8b

I am currently trying to get EtherCAT.NET to configure EtherCAT slaves via their SDO. Right now I am confronted with an error for which I cannot find a reason when trying to send SDO to a EL7031 stepper interface.

I use the Master example. I iterate through the slaves and when I hit the correct ProductCode, I add SdoWriteRequests like this:

if (slave.ProductCode == 0x1b773052) {
    var requests = new List<SdoWriteRequest>();

    foreach (var sdoParameter__ in sdoParameter)
    {
        var dataset = new List<object>();

        foreach (var entry in sdoParameter__.Dataset)
        {
            if (entry.Type == "UINT16")
            {
                var conv = Convert.ToUInt16(entry.Value);
                dataset.Add(conv);
            }
        }

        requests.Add(new SdoWriteRequest(sdoParameter__.Index, sdoParameter__.SubIndex, dataset));
    }
    
    slave.Extensions.Add(new EtherCAT.NET.Extension.InitialSettingsExtension(requests));
}

I use a JSON file for the instructions:

{
  "sdoParameter": [
    {
      "Slave": 2,
      "Index": 32784,
      "SubIndex": 3,
      "Dataset": [
        {
          "Type": "UINT16",
          "Value": 3500
        }
      ]
    },
    {
      "Slave": 2,
      "Index": 32784,
      "SubIndex": 4,
      "Dataset": [
        {
          "Type": "UINT16",
          "Value": 300
        }
      ]
    },
    {
      "Slave": 2,
      "Index": 32784,
      "SubIndex": 6,
      "Dataset": [
        {
          "Type": "UINT16",
          "Value": 200
        }
      ]
    },
    {
      "Slave": 2,
      "Index": 32784,
      "SubIndex": 2,
      "Dataset": [
        {
          "Type": "UINT16",
          "Value": 500
        }
      ]
    },
    {
      "Slave": 2,
      "Index": 32784,
      "SubIndex": 1,
      "Dataset": [
        {
          "Type": "UINT16",
          "Value": 600
        }
      ]
    }
  ]
}

The Master does execute the SdoWriteRequests when connecting. All SdoWriteRequests are executed correctly, besides this one:

{
  "Slave": 2,
  "Index": 32784,
  "SubIndex": 1,
  "Dataset": [
    {
      "Type": "UINT16",
      "Value": 600
    }
  ]
}

Whenever this instruction is part of my overall instruction set, the Master.Configure(rootSlave) fails with

*** buffer overflow detected ***: terminated

So far I was unable to get more output and to figure out any reason. When I exclude this certain instruction while keeping the others, the Configure step is executed flawlessly. According to the Beckhoff manual for the slave, the SDO entry is defined exactly like all others (RW, UINT16).

If anybody could give me a hint about my probable misuse or misconfiguration of the library, I would be very thankful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions