collin80 / SavvyCAN

QT based cross platform canbus tool
MIT License
1.02k stars 280 forks source link

Switch scripting interface to python? #252

Open collin80 opened 4 years ago

collin80 commented 4 years ago

Currently scripting does work but it essentially uses JavaScript since QT has built-in support for that. Nobody loves Javascript. Sad for JS but Python rules the roost. It's not actually all that easy to cleanly support an embedded python interpreter in a QT application that will be compiled cross platform. But, PythonQT seems to be the best approach. The big kink there is that the same compiler should be used to compile Python and the QT application. So, that might require some work even to support that in the pre-built binaries. On Linux and MacOS it might be easier but how to install python development headers would have to be covered in the readme.

Another approach would be to support a way for python scripts on the system at large to interact with SavvyCAN to essentially remote control it. For instance, a network socket could be used to tunnel CAN traffic back and forth from SavvyCAN to a python program. Then the system python interpreter could be used for the scripts. They'd run outside of SavvyCAN and just communicate over the network socket. That lets one use any scripting language they want with few restrictions. In fact, I suppose this could already be possible since SavvyCAN has built-in support for a special MQTT transport for CAN traffic. A python script, even one on a different machine, could use MQTT to talk to SavvyCAN. But, something more lightweight and local would probably be more appropriate.

These are all just ideas. I'm not sure of the best way forward. Leaning slightly toward an external solution where the system python interpreter is used to talk to SavvyCAN over some local interface but I'm not 100% sure of the best way to do that.

KostyaSha commented 4 years ago

Just to keep track, initial question come from https://github.com/collin80/SavvyCAN/issues/251