I’m just getting into cyphal, which I want to use with can bus to work with some devices. So, there’s pycyphal and pycyphal2, with the latter being simpler. To get more familiar with it I tried to reimplement thermostat demo from pycyphal1, but failed on multiple occasions. So there are a few questions:
Should I really choose pycyphal2 right now for writing new software, or v1 might be preferable
If I should, there’s a couple of things:
2.1. I might serialize\deserialize dsdl types using nunavut support, but serialization returns list of memoryviews - how would I publish it?
2.2 What about heartbeat?
2.3. I understand, that cynic is preferable and not yakut, but may I still use it to be sure about backward compatibility? So far I wasn’t able to either subscribe or publish from/to running pycyphal2 demo using yakut.
Help will be very appreciated
I would go with Cyphal v1.1. It is not yet stable, but I think that the radical usability improvements realized in the new version should offset the risk of instability for many real projects. This means that yes, you should choose pycyphal2.
Cyphal v1.1 no longer requires the heartbeat or any other application-layer behaviors. Obviously it doesn’t mean that you can’t use it – do it if you need it. Or don’t use DSDL at all and choose MsgPack or JSON. Cyphal v1.1 does not attempt to anticipate the requirements of the application. That said, in my honest biased opinion, DSDL is a very good format and in embedded applications it doesn’t have many strong competitors.
You might already know that DSDL will not be part of the future Cyphal specifications; they will evolve as separate projects from now on.
Sure. To enable backward compatibility you should name your topics like 1234#1234, where 1234 is the subject-ID. Yakut should see them on Cyphal/CAN.
You might have noticed that PyCyphal2 ships some usage examples, those might be a better starting point than trying to port the old PyCyphal demo.
I have seen the examples provided with pycyphal 2 and they’re great, I just wish there was an example with dsdl, because I think it will be a common use case.
One more question: you pointed out that yakut would see devices on pycyphal/CAN, is UDP not an option for debugging, or should it work as well?
DSDL is just a serialization format so the only change would be that you add a serialize/deserialize call, that’s it. If you have a specific question about DSDL integration, share it here. I think it should be straightforward, you just need to invoke Nunavut manually to generate Python serialization code. Or if you don’t want to generate any code, you can just use PyDSDL directly, it can serialize/deserialize dynamically, see PyDSDL usage — PyDSDL 1.25.0.rc1 documentation
UDP works perfectly but is not compatible with Cyphal/UDP v1.0 because it hasn’t been stabilized yet. Cyphal/CAN v1.0 is the only stable transport hence it is the only one that we maintain backward compatibility with.