Problem with running timer in another thread
-
@Christian-Ehrlicher I expected such answers: "simply use QSerialPort and proper signals & slots." . I have project realized in this way.
But as part of learning (main goal of the project) programming and uing threads I would like to use threads this time to serial communication, and run example considered in this topic.@Damian7546
Then by choosing to use threads where they are probably not needed you (or the original author) have ended up with a problem using threads, possibly because the original code was not well written for threads. Which tells you a lot... ! Just saying. -
@Christian-Ehrlicher I expected such answers: "simply use QSerialPort and proper signals & slots." . I have project realized in this way.
But as part of learning (main goal of the project) programming and uing threads I would like to use threads this time to serial communication, and run example considered in this topic.@Damian7546 said in Problem with running timer in another thread:
But as part of learning (main goal of the project) programming and uing threads I would like to use threads this time to serial communication, and run example considered in this topic.
Then you can look, for example, at Qt's Blocking Serial Port Examples:
(Sender)
(Receiver)
Or you use some non-Qt implementation of serial port communication, such as
serial_portfromBoost.ASIOlibrary.
(makes little sense, since you are already using Qt which provides all that stuff... but for learning purposes it's fine to look at different techniques) -
@Christian-Ehrlicher I expected such answers: "simply use QSerialPort and proper signals & slots." . I have project realized in this way.
But as part of learning (main goal of the project) programming and uing threads I would like to use threads this time to serial communication, and run example considered in this topic.@Damian7546 said in Problem with running timer in another thread:
But as part of learning (main goal of the project) programming and uing threads I would like to use threads this time to serial
Then look at the Qt documentation for Qt threads and it's examples instead some obscure git projects.
-
Problem with QObject::startTimer: Timers cannot be started from another thread Solved!
I changed:
-All entries of the connect function, from:
connect(this, &CctalkLinkController::openPortInWorker, serial_worker_.data(), &SerialWorker::openPort, Qt::QueuedConnection);to:
connect(this, &CctalkLinkController::openPortInWorker, serial_worker_, &SerialWorker::openPort, Qt::QueuedConnection);Because I don't have any idea what is data() ?
And like suggested @J.Hilk in CctalkLinkController I changed:
CctalkLinkController::CctalkLinkController() { serial_worker_ = new SerialWorker();to
CctalkLinkController::CctalkLinkController(QObject *parent) : QObject(parent), serial_worker_{new SerialWorker(this)} { -
D Damian7546 has marked this topic as solved on
-
D Damian7546 has marked this topic as solved on
-
D Damian7546 has marked this topic as solved on