qtserialport

Qt serial port: write and read data

廉价感情. 提交于 2019-12-11 14:26:44
问题 I'm able to connect to my serial port, but I need to read data from it all the time. It's working for about 39 minutes, but after it stops at line serial.flush() . When I stop Qt and start it again it also stops at serial.flush() . I need to restart my modem to let it work again... I'm not sure I'm executing this properly... // Open Serial connexion QSerialPort serial; serial.setPortName("usbserial-26214A"); serial.open(QIODevice::ReadWrite); serial.setBaudRate(QSerialPort::Baud115200);

Choose databits from combobox

佐手、 提交于 2019-12-11 07:33:13
问题 I have a simple GUI for serial communication with an Arduino UNO. First I list all databit in an OrderedDict , then I put them in a combobox: self.databits = OrderedDict([ ('5', QtSerialPort.QSerialPort.Data5), ('6', QtSerialPort.QSerialPort.Data6), ('7', QtSerialPort.QSerialPort.Data7), ('8', QtSerialPort.QSerialPort.Data8) ]) self.databit_comboBox.addItems(list(self.databits)) Then I run the code, I select an option from databits combobox (this is how I get data from combobox) self.serial

Qt - serial port name in ubuntu

风格不统一 提交于 2019-12-10 20:19:51
问题 I have a problem with finding the serial port name on Ubuntu. As you know, for reading serial port on Windows, we can use this code for example: serial->setPortName("com3"); but when I compile this code on Ubuntu, I can't use this code: serial->setPortName("/dev/ttyACM0"); I know that my serial port name is ttyACM0 and I can read data on it by issuing this command: cat /dev/ttyACM0 but why cannot I use this name in my code? What should I do? 回答1: In order to get permission for your regular

QSerialPort effect on `/dev/ttyS*` after process end?

元气小坏坏 提交于 2019-12-10 13:45:43
问题 When a Qt app using QSerialPort experiences a non-clean shutdown (e.g. due to receiving and not handling SIGINT ), how is the file descriptor of the serial port affected? After running an app that opens a QSerialPort on /dev/ttyS0 , then quitting with Ctl-C , I am finding that cat < /dev/ttyS0 returns instantly (without printing anything) rather than waiting for data (as it usually does). I would expect that if this is due to an open file handle left hanging around, it would show up in the

qt-updating ui by thread

空扰寡人 提交于 2019-12-09 01:06:59
问题 hi I have a problem with updating ui by a thread. code works correctly but the problem is when I want to move my window as you know in that moment ui thread will stop updating. and my thread sends values to stopped thread that causes error. I don't know how to fix this. here is my thread code header: #ifndef READERTHREAD_H #define READERTHREAD_H #include <QtSerialPort/QSerialPort> #include <QtSerialPort/QSerialPortInfo> #include <QThread> class readerThread : public QThread { Q_OBJECT public:

Driver CH341 USB Adapter Serial Port or QSerialPort not Works in Linux

心不动则不痛 提交于 2019-12-06 01:18:07
问题 The following code works for me correctly in Windows, but Linux does not work. I am using the same PC, both operating systems are installed native. I do not use virtual machine. I need to work on Linux. I have tried in different linux distributions and does not work anywhere. // In the main class: QSerialPortInfo info = XXXX; // Generally in Linux: /dev/ttyUSB0, in win: COM1 QSerialPort serial; QObject::connect(&serial, SIGNAL(readyRead()), this, SLOT(onReadyRead()), Qt::DirectConnection);

Cleanly closing a QSerialPort in Qt

瘦欲@ 提交于 2019-12-04 06:32:12
问题 I am trying to close a serial port opened using the QSerialPort library but it hangs more than half the time. I am developing a multi-threaded app, with one thread responsible for UI and the other for serial communication. I am using the QThread wrapper class. void CommThread::run() { serial = new QSerialPort(); serial->setPortName(portname); serial->setBaudRate(QSerialPort::Baud115200); if(!serial->open(QIODevice::ReadWrite)){ qDebug() << "Error opening Serial port within thread"; quit =

how does readyRead() work in Qt?

倾然丶 夕夏残阳落幕 提交于 2019-12-03 15:16:38
问题 It's my first question on this website ! I have some trouble reading datas from a COM port, I send a complete message from another COM port, and when I receive it with Qt, it's always cut in multiple submessages. void SerialPortReader::init() { connect(m_serialPort, SIGNAL(readyRead()), this, SLOT(readData())); } void SerialPortReader::readData() { // m_serialPort->waitForReadyRead(200); QByteArray byteArray = m_serialPort->readAll(); qDebug() << byteArray; if(byteArray.startsWith(SOF) &&

Qt and serial port programming [closed]

时间秒杀一切 提交于 2019-12-02 20:52:39
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Is there any serial port facilities in Qt ? If not, which crossplatform (desirable) libraries (for working with serial port and, maybe, with other I/O ports), do you recommend ? Take a look at the Project QextSerialPort . Well, there's always Boost . In

QSerialPort is causing a program stop (endless loop?) if opening device

Deadly 提交于 2019-12-01 09:05:16
I want to write on a serial device. Unfortunately I have the feeling the QSerialPort is not properly implemented under linux. In contrast to other methods (python) I get !sometimes! a hang of the program when I try to call: serial.open(QIODevice::ReadWrite) I am using the example from http://qt-project.org/wiki/QtSerialPort (see below). The QSerialPortInfo is working properly so that I can search for my device before I open it. The problem appeared in all Qt 5.* series. I am currently using 5.3 beta from the OpenSuse repository. Other tools or methods proof, that the device is working (Windows