Shared Header between Arduino and Qt
-
Hi everybody,
Lately I´ve been thinking about the best way to create for example a robot with a Qt Interface. For this you need a way to trigger a function call from your Qt-side on the Arduino-side and vice-versa. That is actually no problem (and I´ve already done projects that do "it":http://coolrobotprojects.blogspot.co.at/2013/06/the-spherebot.html ). But I don´t like that you actually have to define your communication protocol twice, one time in the Arduino code and one time in the Qt code.
So I thought it would be much more convenient to define it in one header and use this header on both sides.
My conecept now looks like this:
http://www.flickr.com/photos/103346694@N04/9952263073/lightbox/The best way would probably be to use a Qt-plugin that changes the files on both sides if the shared header is changed.
The Information flow would look like this:
http://www.flickr.com/photos/103346694@N04/9952050544/lightbox/
If Arduino::setLed1() is called on the Qt side it gets translated to something G-code like ( for example "S1") and this string is sent to the SerialConnectionManager. The SerialConnectionManager sends it to the arduino.
This modularity would be nice because then you are able to use different channels/CommunicationManagers (e.g. bluetooth or serial) to talk to the arduino.
And finally on the arduino side it gets re-translated to setLed1(); and is executed.
If I want to give an answer from the arduino side I simply call emit_signalXX(); and trigger the same just in the opposite direction and if you want to transmit any data you can do it as a function parameter.This would be my idea of how to elegantly abstract the whole communication away but the problem is that I don´t really know how to realize the Qt-plugin to do so. Has anybody an idea how to implement it?