Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved]: Two different handler for same ready read signal in serial communication.
I am working with USB port as well as D-sub port(both are serial ports) at a time.
Does anybody knows how to make two handler for same ready read signal in serial communication? May be identifying the ports which generates ready read signals..!!!
Thanks in advance.
wspilot last edited by
I am using qextserialport (third party library) for serial communication.
Why don't you have one slots per port (connected to one read-ready signa)l. Those extract the data from the port and put it into a QByteArray which is then handed over to another method that does the actual processing?
That's exactly my point. How will I come to know that which port has generated the ready read signal?
Actually, I am using USB port for some modules and D-sub port for to connect another industrial PC (same as normal computer) and I have to use both at a time. Now to work with both serial ports at a time, How to differentiate both? so that I can identify port which has generated ready read signal and can use appropriate handler.
Thanks for you reply.
You connect the one object's readReady signal to one slot and the other object's readReady signal to another one. I am afraid I do not understand the question:-)
Mine agenda was to use only one object for serial communication as I have developed few common functions like OpenPort(), WriteData()...
If I use more objects then there is no use of my common functions as I have to check weather perticular port is opened or not..!!!
qint64 SerialPort::WriteData(QString message)
QByteArray msg_ascii = message.toAscii();
[edit, code tags added, koahnig]
koahnig last edited by
I guess you are confusing class and object in your posting.
A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions.
An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable.[/quote] This is copied from "here":http://www.cplusplus.com/doc/tutorial/classes/
What you want to do is having a common class definition with a method handling in both cases the readyRead signal.
You could have something similar to this:
class MySerialClass : public QExtSerialPort
void sltReadyReadHandling (...);
In your application you may have then:
I solved the problem as well as confusion..!!!