Code Monkey home page Code Monkey logo

Comments (2)

michael-hillmann avatar michael-hillmann commented on July 24, 2024

Good question; this behavior was introduced to handle the data correctly on DSP microcontrollers. Some (or all?) of the DSP cores doesn't allow byte-oriented pointers. Therefore the CO_LONG data, which was given to the COObjWrValue() contains the whole 4-byte value out of the expedited transfers (which is always 4 bytes - independent of the size indication).

To handle the sizes correctly, the COObjWrDirect() will convert the given 4-byte value out of the expedited transfer to the size of the addressed object dictionary entry. This is possible without side effects because the given size indication and the object size are compared before the write operation takes place.

I guess you want to write a custom type and want to handle different sizes with your write function. In this case, the method I would recommend is:

CO_ERR myCustomWrite (struct CO_OBJ_T *obj, struct CO_NODE_T *node, void *buf, uint32_t size)
{
    uint8_t width = CO_GET_SIZE(obj->Key);

    /* now you can handle your data with:
    *  - size (number of valid buffer data)
    *  - width (number of object entry data)
    *  Note: you can trust, that the indicated transfer size (if given) is equal to the width (checked by the SDO server)
    */
}

from canopen-stack.

michael-hillmann avatar michael-hillmann commented on July 24, 2024

Improve documentation to cover this behavior for users who write custom types.

from canopen-stack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.