How to emit Dbus signal in C - qt

I am having a method and signal. From one process which is developed in Qt Creator 5.2.1, has 1 method and 1 signal.
The method is called using QDbusConnection and QDbusMessage.
The signal is connected with one slot.
A remote application which is to be developed in C should call the method remotely and should emit signal.
I need to know the sequence to remotely run the method and the sequence to emit signal.
Please help me the sequence in C program. No clear picture I found while surfing in internet.

Related

Moving window blocks Qt SerialPort data reception

I am currently developing a Qt application which has a window and a serial port module.
My problem is that when I press on the window or move it, the reception of the QSerialPort module (with the readyRead() signal) is blocked. The reception only resumes when I stop acting on the window.
It seems that this is a known problem: https://bugreports.qt.io/browse/QTBUG-34946
However, I am currently in version 5.15.2.
Where do you think the problem can come from and what could be the solution?

Parallel Processing in QT

How is parallel processing achieved in Qt. Suppose i need to call two functions which performs serial communication with multiple serial devices connected.
Func_A() handles serial communication with Device 1 and Func_B() handles serial communication with Device 2 and so on, but both needs to be communicated in parallel and not sequential .
The motive is to communicate with multiple devices connected through serial/Ethernet at the same time.
If you use non-blocking functions for communication, you can handle all your serial communication within the same thread with no issue.
Each device (QSerialPort) will emit a signal (i.e. call a function) when data is received. From there you can decode this data in the corresponding slots. Sending data can be triggered either by UI events, by timers, and by any other event.
This is the simplest.
If you really do heavy computations when encoding/decoding communication, you can create several QThread, one to handle each device. And then, you can connect signals between your different threads with Qt::QueuedConnection (automatic) to avoid the need for mutex or other inter-thread synchronization logic.

can Qt signal wakeup sleeping thread

I'm working on some application using Qt framework, it uses serial port and need to receive some data, problem is that data is organized with some protocol, which i parse in readyRead() signal handler(slot), at the same time, i need to wait for parsed message with some timeout. So, to wait, i use QThread::msleep() after sending, but i've noticed, that when thread goes to sleep in msleep(), readyRead will be emitted only after msleep() will be finished. My question is, why readyRead can't wake up thread? Qt signal is not working like real Unix signals?
If you have single thread application readyRead slot not executes immediatly you got data on port. Read about Qt::QueuedConnection in QObject::connect(). When readyRead signal emits in serial port class it just added to queue of events (in global event loop). All events will be executed later by QEventLoop (inside QApplication instance).
Looks like you sleep your main thread so QEventLoop cant execute anything while sleeping. In this case you need to read your port from another thread to avoid main thread sleeping.

Sending information from Simulink to Arduino over Serial

Hope everyone had a great start to the new year! I am writing in this group to seek some help with sending PWM signal to Arudino over serial via Simulink
Problem description :
I am working on a personal project which involves building closed loop PID control loop, where I need to send PWM signals to fan, in order to control the position of a ball at a fixed height. The feedback signal is generated via a USB camera, which detects the position of the ball.
Since Arduino can't process the image, I am running my model in Simulink and sending the signal via serial to Arduino. But, the signal somehow doesn't reach or gets processed by the board.
Here is a step by step information on the process I followed to test debug
I upload a serial recieve model on the Arduino. It probes the serial port for the data. Once data is found, it is routed to the pin 9 as shown in the image
In the simulink environment, to debug, I configured a serial send port (from instrument control toolbox) to transfer the desired PWM signal. However, this does not work. I tried debugging the pin 9, but no Voltage signal was recieved.
In the model above, I added a serial recieve block from the instrument control toolbox. This somehow slowed down the simulation. Each time step was being executed with some delay, but the PWM signals were getting transferred. The blower speed could be changed in accordance with the PWM signal. However this method is too slow for my control loop to work with
Can someone please help me point out the possible error that I am making. I am very curious to find a workaround!
Looking forward to hearing from the group
Cheers!
Masoom

Qt5: how to connect to D-Bus signals

I'm trying to connect a D-Bus signal to a Qt slot. For example, I'm interested to catch the CallAdded signal:
http://git.kernel.org/cgit/network/ofono/ofono.git/tree/doc/voicecallmanager-api.txt
I did the folloging:
QDBusConnection::systemBus().connect(OFONO_SERVICE, m_modem.path(), OFONO_VOICECALLMANAGER_INTERFACE, "CallAdded", this, SLOT(callAdded(QString,QMap<QString,QVariant>)));
where:
OFONO_SERVICE = "org.ofono"
m_modem.path() = /hfp/org/bluez/hci0/dev_xx_xx_x_xx_xx_xx
OFONO_VOICECALLMANAGER_INTERFACE = "org.ofono.VoiceCallManager"
but nothing happens when I make or receive a call. Of course I'm connected and I've enabled and set online the modem.
Perhaps my "translated" signature is wrong?

Resources