C++ (Qt) , m_currentMask(0) , m_desiredMask(0)
WinSerialPortEngine::WinSerialPortEngine(SerialPortPrivate *parent) : m_descriptor(INVALID_HANDLE_VALUE) , m_flagErrorFromCommEvent(false) , m_currentMask(0) , m_desiredMask(0) , m_setMask(EV_ERR) #if defined (Q_OS_WINCE) , m_running(true) #endif{ Q_ASSERT(parent); m_parent = parent;
C++ (Qt)m_setMask(0)
void MyMainWindow::receiveLetter(){ uint8_t num = myPortCom->bytesAvailable(); qDebug() << "Bytes_Available:" << num; myPortCom->readAll(); }void MyMainWindow::serialDataReady(){ timer.singleShot(2000,this,SLOT(receiveLetter()));}
Bytes_Available: 10 Bytes_Available: 0 Bytes_Available: 0 Bytes_Available: 0 Bytes_Available: 0 Bytes_Available: 0 Bytes_Available: 0 Bytes_Available: 0 Bytes_Available: 0 Bytes_Available: 0
dn=ui->PortSelect->currentText(); port1.setDeviceName(dn); if(!port1.open(AbstractSerial::ReadWrite | AbstractSerial::Unbuffered)) ui->portmsglabel->setText("Error opening port !"); else { port1.setBaudRate(AbstractSerial::BaudRate115200); port1.setDataBits(AbstractSerial::DataBits8); port1.setParity(AbstractSerial::ParityNone); port1.setStopBits(AbstractSerial::StopBits1); port1.setFlowControl(AbstractSerial::FlowControlOff); //port1.setTotalReadConstantTimeout(500); //port1.setCharIntervalTimeout(50000); ui->portmsglabel->setText("Port successfully opened"); }
if(port1.waitForReadyRead(25)) { buff_q=port1.read(port1.bytesAvailable()); receivedBytesCount=buff_q.size(); } else{ ....}
connect(&port1,SIGNAL(readyRead()),this,SLOT(checkAvailable()));