Currently, I am working on sending the CAN signals of type QCanBusFrame and receiving the signals accordingly. But, I am facing difficulty to send multiple signals at the same time since once a signal is sent, it repeats until its cycle length. So if I send another signal, it stays in the loop until the other signal is completed (cycle number of times)


I want to send the signal simultaneously and see the received signals in GUI. Can I have any suggestions? is multithreading a solution for this problem?

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

This is my code for writing the frame and sending is done as shown below

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