canopen
canopen copied to clipboard
Need exemple on how to code SDO , PDO , NMT , EMCY callback
Hi, Do you have some example of code that use callback to capture SDO , PDO , NMT , EMCY. We can use can listener to capture can messages but is there any way to capture object instaed?
Do you mean that you want to passively monitor a CANopen bus and decode the messages? That's not supported unfortunately.
I see that callback has been implemented for PDO and EMCY messages but not for SDO and NMT messages
Hi @blairfancy, that is by design. PDO and EMCY are broadcast type messages, or UDP like if you prefer, therefore the callbacks are use to listen when a new message as arrived. On the other hand SDO, are TCP like, we send the request and stay waiting (with timeout) the response arrival. NMT are internal state machine states that are handle internally by the API managing for the devices. There are other mechanism available to listen to the CANBus network, such one is the candump in linux that can be use to log the communications in realtime on the console or dump to a file for latter analysis (I have done this many time to make sure i was sending and reading the right stuff). Using the library to do this job i don't think is the best approach, but if you have a specific use case please share it for discussion and if you want you also can implement and submit a PR. @christiansandberg understands better than I the core implementation of the library. This is only my opinion.
If i can help please drop a message/comment here.
Thanks.
Hello Christian,
When using your library, do you only use it whithin CLI scripts ? or do you use a graphical UI ?
suggestions on UI based tools that uses you library ?
Thanks for sharing your CANopen knowledge with this lib. I might be able to Submit some PR if I knew it would add value to the 'development Path' you envision for the library.
CANopen can quickly become overwhelming when looking at it 'Low-Level' when using high-level production tools in work environment. The high-level Software ( CodeSYS per example ) handles a lot of initialisation stuff and if we use your library, it most likely mean we do not have access to 'Vector' software suite. :-) Your library helped me a few times by comparing canbus message patterns with your code to better graps what the hell the PLC was doing.
I do have a 'Python-Flask' Web-Server that I use with python-can /cantools that does decoding but is not 'structured' right as of now. It does decode J1939 and CANopen but I do not always have the devices 'DBC' or 'EDS'.
- I often simulate CANopen Slave devices to test my main PLC program
- I am prototyping CANopen Slave 'Models' but not yet with your library
Let me know if CANopen Slave is something you'd use or what other tool you would recommend to emulate Device so I don't reinvent the wheel. It might convince my to structure my project a bit and put it on Github. Maybe your comments may show me a different approach to my 'Model' prototype that would bring an awesome PR.
let's see how it can go... throwing a message in a bottle !