cancel
Showing results for 
Search instead for 
Did you mean: 

Read EtherCAT CoE SDO via Datalayer (Golang)

Read EtherCAT CoE SDO via Datalayer (Golang)

SaDiego
Member

Hi,

I'm trying to read a CoE object from SAFEX-C.15 via Golang application. When using the Datalayer UI directly I can read successfuly:

SaDiego_0-1687450823955.png

The schema used for the flatbuffers is as per below:

include "addresstype.fbs";

namespace schema;

enum SDOFlags: uint32 (bit_flags)
{
  noFlags        = 0,
  completeAccess = 1,
}

table SDORequest
{
  addressType: Addresstype;
  address: uint16;
  objectIndex: uint16;
  subIndex: uint8;
  flags: SDOFlags;
  data: [uint8];
  maxLength: uint32;
}

table SDOResponse
{
  data: [uint8];
}

table SDO
{
  request: SDORequest;
  response: SDOResponse;
}

root_type SDO;
 
 

The Golang code that implements the CoE request is as follows:

 

func (c *CallDatalayerClient) RequestCoE(node string) (w string){
    var atype schema.Addresstype = schema.Addresstypefixedphysical
    var sFlag schema.SDOFlags = schema.SDOFlagsnoFlags

    builder := flatbuffers.NewBuilder(1)
    schema.SDORequestStartDataVector(builder, 2)
    for i := 1; i >= 0; i-- {
        builder.PrependUint8(0)
    }
    dataRequest := builder.EndVector(0)

    schema.SDOResponseStartDataVector(builder, 2)
    for i := 1; i >= 0; i-- {
        builder.PrependUint8(0)
    }
    dataResponse := builder.EndVector(0)

    schema.SDORequestStart(builder)
    schema.SDORequestAddAddressType(builder, atype)
    schema.SDORequestAddAddress(builder, 1001)
    schema.SDORequestAddObjectIndex(builder, 4104)
    schema.SDORequestAddSubIndex(builder, 0)
    schema.SDORequestAddFlags(builder, sFlag)
    schema.SDORequestAddData(builder, dataRequest)
    schema.SDORequestAddMaxLength(builder, 1024)
    request := schema.SDORequestEnd(builder)
    builder.Finish(request)

    schema.SDOResponseStart(builder)
    schema.SDOResponseAddData(builder, dataResponse)
    response := schema.SDOResponseEnd(builder)
    builder.Finish(response)

    schema.SDOStart(builder)
    schema.SDOAddRequest(builder, request)
    schema.SDOAddResponse(builder, response)
    requestObject := schema.SDOEnd(builder)

    builder.Finish(requestObject)

    v := datalayer.NewVariant()
    v.SetFlatbuffers(builder.FinishedBytes())
    //defer datalayer.DeleteVariant(v)

    res := c.client.ReadSyncArgs(node, v)
    fmt.Println("CoE request: %s", res)

    if res != datalayer.ResultOk {
        w = "Error!"
        return
    }

    w = fmt.Sprintf("CoE request OK: %s", res)
    return
}

 

The node is "fieldbuses/ethercat/master/instances/ethercatmaster/device_access/coe/sdo"

After the ReadSyncArgs function call the result reports DL_TYPE_MISMATCH.

SaDiego_3-1687451276642.png

Can you please help in understanding what is the problem? I believe the flatbuffer implementation is correct and there is no reason for the type mismatch error.

Thanks in advance.

 

2 REPLIES 2

nickH
Community Moderator
Community Moderator

Bug was found and we are currently working on it. 

CodeShepherd
Community Moderator
Community Moderator

Is this still an issue or can this topic be closed?

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist