Comments (2)
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.
Improve documentation to cover this behavior for users who write custom types.
from canopen-stack.
Related Issues (20)
- website is moved to separate repository
- generate source package with release v4.4.0
- quickstart is moved to own repository
- Not able to find object dictionary file in the stack and no idea which tool need to use to generate the EDS file HOT 4
- Implementation on TI C2000 MCU with 16-bit bytes HOT 6
- Variable Block Download block sizes HOT 3
- Failed to link files HOT 2
- DSP: Integer16 is not read as expected HOT 7
- reentering an abandoned segmented SDO session
- protocol boot-up spec possibly followed incorrectly HOT 1
- EMCY Service Err Index Size
- Bugfix for COSDO Segmented Download
- Size of buffer during NVM read
- Problems with RPDO dummy mapping - potential array out of bounds write HOT 2
- Linux port of the stack HOT 1
- COTPdoMapWrite: Add error checking to prevent uninitialized variable access.
- SDO timeout message after SDO request was successful
- How to tailor the lib to run on small-size MCU
- COTmrService stops all timers on failed CO_IF_CAN_DRV.Send?
- CAN communication stopped after creating CANOpen node.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from canopen-stack.