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. Send multiple Can signals at the same time
Forum Updated to NodeBB v4.3 + New Features

Send multiple Can signals at the same time

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 4 Posters 1.6k 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.
  • P PriyankaM96

    @jsulm said in Send multiple Can signals at the same time:

    QTimer

    The delay function is as follows. It uses Qtimer.

    void MainWindow::delay( int millisecondsToWait )
    {
        QTime dieTime = QTime::currentTime().addMSecs( millisecondsToWait );
        while( QTime::currentTime() < dieTime )
        {
            QCoreApplication::processEvents( QEventLoop::AllEvents, 100 );
        }
    }
    
    
    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #6

    @PriyankaM96 said in Send multiple Can signals at the same time:

    It uses Qtimer

    Then why do you use local event loop? Simply use timout from QTimer to send the data after given time...

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • P Offline
      P Offline
      PriyankaM96
      wrote on last edited by
      #7

      Okay. Thank you

      But still, I have a problem with sending two signals simultaneously.

      1 Reply Last reply
      0
      • nageshN Offline
        nageshN Offline
        nagesh
        wrote on last edited by
        #8

        @PriyankaM96 Problem statement not understood correctly.
        At current implementation m_canDevice->writeFrame(frame); is delayed for 5.5sec
        significance of 5500msec delay?
        These 5.5sec delay will be there for each framewrite...

        1 Reply Last reply
        0
        • P Offline
          P Offline
          PriyankaM96
          wrote on last edited by PriyankaM96
          #9

          Yes, but each frame write takes that much time to avoid overwrite. As far as I tested.

          This is to send signals for a cycle number of times (cycle length is extracted for each signal from DBC file).

          I want to send two similar signals and keep it running simulataneously

          1 Reply Last reply
          0
          • nageshN Offline
            nageshN Offline
            nagesh
            wrote on last edited by
            #10

            @PriyankaM96 One approach would be as follows

            the signal is repeatedly transmitted till its cycle length
            

            signals which are having cycle length to be handled separately using QTimer
            In QTimer keep track of number of times to send it & for each timeout emit as if it needs to send 1 frame.
            emit sendFrame(frame,"1");

            P 1 Reply Last reply
            1
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #11

              Looks like your answers are not good enough, but so has the same answers so the next forum is on the road with the same outcoming I would guess :)

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              P 1 Reply Last reply
              0
              • nageshN nagesh

                @PriyankaM96 One approach would be as follows

                the signal is repeatedly transmitted till its cycle length
                

                signals which are having cycle length to be handled separately using QTimer
                In QTimer keep track of number of times to send it & for each timeout emit as if it needs to send 1 frame.
                emit sendFrame(frame,"1");

                P Offline
                P Offline
                PriyankaM96
                wrote on last edited by
                #12

                @nagesh Yes, This can be one approach. Thanks

                Is multithreading good for this problem?

                1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  Looks like your answers are not good enough, but so has the same answers so the next forum is on the road with the same outcoming I would guess :)

                  P Offline
                  P Offline
                  PriyankaM96
                  wrote on last edited by
                  #13

                  @Christian-Ehrlicher Yes, I have been looking for answers in different mediums, and posting in a forum was my last option. But hoping more answers :)

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    We told you what to do - the first and important message is: don't block the event loop and use a QTimer.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      PriyankaM96
                      wrote on last edited by
                      #15

                      I am sorry, being a beginner. I have tried doing it for last 2 days and I am not able to find solution. When I put Qtimer, like

                          connect(timer, &QTimer::timeout,[=]() {
                              m_canDevice->writeFrame(frame);
                          });
                      
                          timer->setInterval(2000);
                          timer->start(5000);
                      

                      the UI doesnt respond or not able to write the frame.

                      jsulmJ 1 Reply Last reply
                      0
                      • P PriyankaM96

                        I am sorry, being a beginner. I have tried doing it for last 2 days and I am not able to find solution. When I put Qtimer, like

                            connect(timer, &QTimer::timeout,[=]() {
                                m_canDevice->writeFrame(frame);
                            });
                        
                            timer->setInterval(2000);
                            timer->start(5000);
                        

                        the UI doesnt respond or not able to write the frame.

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        @PriyankaM96 said in Send multiple Can signals at the same time:

                        the UI doesnt respond

                        Then you still block the event loop somewhere. Please show all relevant code.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        P 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @PriyankaM96 said in Send multiple Can signals at the same time:

                          the UI doesnt respond

                          Then you still block the event loop somewhere. Please show all relevant code.

                          P Offline
                          P Offline
                          PriyankaM96
                          wrote on last edited by
                          #17

                          @jsulm Sorry for the delay in reply. Had a blocking function from another class. Problem solved.

                          1 Reply Last reply
                          0

                          • Login

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