Qt RPC with gRPC over USB
-
Hi, I'd like to try Qt's RPC classes but I struggle to understand how to use it (using Qt 6.5.3).
Basically we have a MCU connected to USB which has RPC capabilities with Pigweed RPC and we are able to communicate with it over USB with a simple CLI program. The device is the RPC server and is used to configure and control the device.
Now I have to make a GUI version of the client and I saw that Qt has a RPC and protobuf capabilities. I am able to compile the proto files of the server in C++ and generate the client gRPc class.
However I do not understand how to add a channel to enable the communication with the device over USB. Notably I seems I have to use a class that inherits QAbstractGrpcChannel but I can't find examples of how to make yours.
I see that there exists HTTP 2 channel and a native channel, but the first one I think is not what I need and the second one simply does not exists in my Qt installation, even though a fileqgrpcchannel.h
with the class exists in Qt's sources.#include <QGrpcChannel> // 'QGrpcChannel' file not found
Do you have example of how I could make that work or is it not made for that usage ?
Thank you for your help !
-
Hi, I'd like to try Qt's RPC classes but I struggle to understand how to use it (using Qt 6.5.3).
Basically we have a MCU connected to USB which has RPC capabilities with Pigweed RPC and we are able to communicate with it over USB with a simple CLI program. The device is the RPC server and is used to configure and control the device.
Now I have to make a GUI version of the client and I saw that Qt has a RPC and protobuf capabilities. I am able to compile the proto files of the server in C++ and generate the client gRPc class.
However I do not understand how to add a channel to enable the communication with the device over USB. Notably I seems I have to use a class that inherits QAbstractGrpcChannel but I can't find examples of how to make yours.
I see that there exists HTTP 2 channel and a native channel, but the first one I think is not what I need and the second one simply does not exists in my Qt installation, even though a fileqgrpcchannel.h
with the class exists in Qt's sources.#include <QGrpcChannel> // 'QGrpcChannel' file not found
Do you have example of how I could make that work or is it not made for that usage ?
Thank you for your help !
-
@Elian Did you add
find_package(Qt6 REQUIRED COMPONENTS Grpc) target_link_libraries(mytarget PRIVATE Qt6::Grpc)
to your CMake file?
@jsulm Yes these are in my CMakeLists.
And when I go to my Qt install
Qt/6.5.3/gcc_64/include/QtGrpc
(on Linux Mint 20.04) I do not see a header file named QGrpcChannel, even though the doc says it should exist https://doc.qt.io/qt-6.5/qgrpcchannel.htmlAm I doing it wrong ? What I'd like is to send RPC commands over a USB serial device using HDLC. But the more I look and it looks like this module is not appropriate for it.
-
@jsulm Yes these are in my CMakeLists.
And when I go to my Qt install
Qt/6.5.3/gcc_64/include/QtGrpc
(on Linux Mint 20.04) I do not see a header file named QGrpcChannel, even though the doc says it should exist https://doc.qt.io/qt-6.5/qgrpcchannel.htmlAm I doing it wrong ? What I'd like is to send RPC commands over a USB serial device using HDLC. But the more I look and it looks like this module is not appropriate for it.
-
@jsulm Yes these are in my CMakeLists.
And when I go to my Qt install
Qt/6.5.3/gcc_64/include/QtGrpc
(on Linux Mint 20.04) I do not see a header file named QGrpcChannel, even though the doc says it should exist https://doc.qt.io/qt-6.5/qgrpcchannel.htmlAm I doing it wrong ? What I'd like is to send RPC commands over a USB serial device using HDLC. But the more I look and it looks like this module is not appropriate for it.
-
Ah right we excluded native gRPC channel from packaging, also note that we discontinue its support in 6.7 already. Please use QGrpcHttp2Channel instead.
You need to build QtGRPC with native gRPC feature enabled to make QGrpcChannel available.