Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]: Two different handler for same ready read signal in serial communication.
Forum Updated to NodeBB v4.3 + New Features

[Solved]: Two different handler for same ready read signal in serial communication.

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nasit.bhavin
    wrote on 22 Jan 2013, 06:19 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wspilot
      wrote on 22 Jan 2013, 09:10 last edited by
      #2

      I just started working on it (Linux), and I am using "QtSerialPort":http://qt-project.org/wiki/QtSerialPort.
      also "getting it to work":http://qt-project.org/forums/viewthread/23839/

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nasit.bhavin
        wrote on 22 Jan 2013, 09:50 last edited by
        #3

        I am using qextserialport (third party library) for serial communication.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on 22 Jan 2013, 09:54 last edited by
          #4

          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?

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nasit.bhavin
            wrote on 22 Jan 2013, 10:06 last edited by
            #5

            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.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on 22 Jan 2013, 10:26 last edited by
              #6

              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:-)

              1 Reply Last reply
              0
              • N Offline
                N Offline
                nasit.bhavin
                wrote on 22 Jan 2013, 11:27 last edited by
                #7

                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..!!!
                e.g
                @
                qint64 SerialPort::WriteData(QString message)
                {
                if(port->isOpen())
                {
                QByteArray msg_ascii = message.toAscii();
                qint64 total=port->write(msg_ascii,msg_ascii.length());
                port->flush();
                }
                else
                return 0;
                }
                @
                [edit, code tags added, koahnig]

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on 22 Jan 2013, 12:26 last edited by
                  #8

                  I guess you are confusing class and object in your posting.
                  [quote]
                  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
                  {
                  public slots:
                  void sltReadyReadHandling (...);
                  };
                  @

                  In your application you may have then:
                  @
                  MySerialClass UsbPort;
                  MySerialClass DSubPort;

                  ....
                  @

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    nasit.bhavin
                    wrote on 23 Jan 2013, 08:10 last edited by
                    #9

                    Thanks kohnig,

                    I solved the problem as well as confusion..!!!

                    1 Reply Last reply
                    0

                    1/9

                    22 Jan 2013, 06:19

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved