Results 1 to 2 of 2

Thread: Sending multiple Canframes and processing it at the same time

  1. #1
    Join Date
    Apr 2021
    Posts
    3
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Question Sending multiple Canframes and processing it at the same time

    I want to send multiple CAN signals of type QCanBusFrame. Currently, I can send one signal at a time and it can run till the signal cycle length. I want to send multiple signals at the same time and receive their output. Currently, if I send a second signal, it goes into a loop and I have to wait until the first signal end to get the output of the second signal. Can anyone help me with this problem?

    Should I use multithreading to get output in GUI?

    This is an excerpt of sending signals :

    Qt Code:
    1. foreach(QString payload_id, payload_send_final) {
    2. const QByteArray payload = QByteArray::fromHex(payload_id.remove(QLatin1Char(' ')).toLatin1());
    3. frame = QCanBusFrame(frameId, payload);
    4.  
    5. if(m_ui->cycle_check->isChecked())
    6. emit sendFrame(frame,cycle_len.at(i));
    7. else
    8. emit sendFrame(frame,"1");
    9.  
    10. i = i + 1;
    11. }
    To copy to clipboard, switch view to plain text mode 


    and receiving part is connected with the "connect" statement to the below slot:

    Qt Code:
    1. void MainWindow::sendFrame(const QCanBusFrame &frame,QString cycle)
    2. {
    3.  
    4. if (!m_canDevice)
    5. return;
    6.  
    7. m_frame_list.enqueue(frame);
    8. send_frame_str = frame.toString();
    9. int i = 1;
    10.  
    11. while (!m_frame_list.isEmpty()) {
    12. QCanBusFrame m_frame = m_frame_list.dequeue();
    13. while ( i <= cycle.toInt()) {
    14. m_canDevice->writeFrame(frame);
    15. delay(5500);
    16. i = i+1;
    17. }
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

    Please help me with suggestions?
    Thanks in advance

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Sending multiple Canframes and processing it at the same time

    Do not post the same thing in two forums. See your thread in the Newbie forum.

Similar Threads

  1. Replies: 2
    Last Post: 17th May 2021, 09:11
  2. Real time audio processing
    By Bangalaman in forum Qt Programming
    Replies: 0
    Last Post: 17th June 2014, 13:17
  3. Real time audio processing
    By Andrea993 in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2011, 10:20
  4. Processing multiple checkboxes
    By -Kyr0s- in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2011, 13:28
  5. sending localsystem time through port
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2007, 08:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.