Giter Site home page Giter Site logo

Comments (4)

CANopenNode avatar CANopenNode commented on May 20, 2024

The standard says:
"The data of synchronous RPDOs received after the occurrence of the SYNC is passed to the
application with the occurrence of the following SYNC, independent of the transmission rate
specified by the transmission type. The data of event-driven RPDOs is passed directly to the
application."

Synchronous PDOs shall be transmitted inside sync window, otherwise they are ignored. They are passed to application immediately after the next SYNC message.
You can set RPDO to event driven (transmission type is 254 or 255), even if TPDO in transmitting device is set to synchronous. Or you can set synchronous windows.

However, this part is quite new and is not deeply tested.

from canopennode.

amacintyre avatar amacintyre commented on May 20, 2024

For this application, the sync window is disabled (OD_synchronousWindowLength=0), so I would expect a synchronous RPDO received a few milliseconds after a sync message to be processed on the following sync for any time interval, assuming no other RPDO arrives before the sync. (In this case, the sync interval is 30ms) However, CO_process_SYNC_RPDO calls CO_RPDO_process once per millisecond between syncs with syncWas=0. This clears the RPDO CANrxNew flag before the next sync, and the RPDO does not get passed to the application. If the RPDO happens to arrive in the millisecond before the sync, it does get passed to the application. RPDOs configured as event driven are always processed.

from canopennode.

amacintyre avatar amacintyre commented on May 20, 2024

The following code change in CO_PDO.c fixed the problem for me.

void CO_RPDO_process(CO_RPDO_t *RPDO, bool_t syncWas){
if(!RPDO->valid || !(*RPDO->operatingState == CO_NMT_OPERATIONAL))
{
RPDO->CANrxNew[0] = RPDO->CANrxNew[1] = false;
}
else if(!RPDO->synchronous || syncWas)
{
...
}
}

from canopennode.

CANopenNode avatar CANopenNode commented on May 20, 2024

I checked it and there was a bug (race conditions):
function CO_process_SYNC_RPDO() (from CANopen.c) calls CO_SYNC_process() and then calls CO_RPDO_process() for each RPDO. CAN messages are received from interrupt, which has higher priority than CO_process_SYNC_RPDO().

Following situation was problematic:

  • CO_SYNC_process() was called, no SYNC detected.
  • From CAN bus comes the train with SYNC and PDOs, which was immediately processed by CAN receive interrupt.
  • CO_process_SYNC_RPDO() was interrupted in the middle and now continues with CO_RPDO_process() calls. In that case RPDOs were deleted.

Stack is now updated with the change from above. Operational RPDOs are not supposed to be deleted in any case. (CO_CANclearPendingSyncPDOs() only clears TPDOs outside window.)

Thank you.

from canopennode.

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.