bnjmnp / pysoem

Cython wrapper for the Simple Open EtherCAT Master Library
MIT License
97 stars 38 forks source link

Add emergency message callback #132

Closed MartinALL91 closed 6 months ago

MartinALL91 commented 7 months ago

I think that it would be useful that instead of raising an exception when emergency messages are received, we could consume them via a callback function (similarly as it is done in the CANopen library). By doing so we don't interrupt the flow of the SDO read and SDO write operations.

bnjmnp commented 7 months ago

This is really nice, I'm also not happy with my current solution but was not clever enough to come up with an idea like yours. Though at some point I was also pondering on adapting the CANopen libraries way of SDO read and write. I just need to further think this through, test it and think about how to introduce this API change.

bnjmnp commented 6 months ago

I do have another idea, in order to maintain backward compatibility, as long as there was no call to add_emergency_callback() the SDO read/write functions and mbx_receive() will trow an Emergency exception as it was before. I will make this change myself after I merged your PR.

bnjmnp commented 6 months ago

Thank you again for your contirbution. This is good stuff!

MartinALL91 commented 6 months ago

Thank you again for your contirbution. This is good stuff!

You are welcome. Thank you for making this amazing library.

MartinALL91 commented 6 months ago

I do have another idea, in order to maintain backward compatibility, as long as there was no call to add_emergency_callback() the SDO read/write functions and mbx_receive() will trow an Emergency exception as it was before. I will make this change myself after I merged your PR.

That's a good idea!