本文整理汇总了C++中QSerialPort::bytesAvailable方法的典型用法代码示例。如果您正苦于以下问题:C++ QSerialPort::bytesAvailable方法的具体用法?C++ QSerialPort::bytesAvailable怎么用?C++ QSerialPort::bytesAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSerialPort
的用法示例。
在下文中一共展示了QSerialPort::bytesAvailable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_RegisterButton_clicked
void MainWindow::on_RegisterButton_clicked()
{
int bytes_available;
int i;
for(i = 0; i < FINGERS && positions[i] == false; i++){
if((i == (FINGERS - 1)) && positions[i] == false){
QMessageBox::warning(this, tr("Bio-guised"),
tr("Please register at least 1 fingerprint"),
QMessageBox::Ok);
return;
}
}
MainWindow::hide();
QSerialPort serial;
serial.setPortName("COM6");
serial.open(QIODevice::ReadWrite);
serial.setBaudRate(QSerialPort::Baud9600);
serial.setDataBits(QSerialPort::Data8);
serial.setParity(QSerialPort::NoParity);
serial.setStopBits(QSerialPort::OneStop);
serial.setFlowControl(QSerialPort::NoFlowControl);
qDebug() << "connected";
while(!serial.isWritable());
QByteArray index("v");
serial.write(index);
do{
serial.waitForReadyRead(1000);
bytes_available = serial.bytesAvailable();
}while(bytes_available <= 0);
QByteArray byte_array = serial.read(bytes_available);
qDebug() << byte_array;
char *rawData = byte_array.data();
int data = (int)*rawData;
delay(2000);
while(!serial.isWritable());
QByteArray index2("k");
serial.write(index2);
serial.waitForReadyRead(2000);
bytes_available = serial.bytesAvailable();
QByteArray byte_array2 = serial.read(bytes_available);
qDebug() << byte_array2;
std::string key = byte_array2.toStdString();
biomodel->encryptKey(key);
if(data > 0 )
bioGuised->show();
}
示例2: onRxData
void onRxData() {
if (m_port.bytesAvailable() < 9) return;
if (m_port.error() != QSerialPort::NoError)
return;
if (! check(m_port.peek(9)))
return setIoStatus(ChecksumError);
uint8_t dummy;
m_str >> m_address >> dummy >> m_status >> dummy >> m_value;
setIoStatus(Ok);
}
示例3: gatherInfo
void MainWindow::gatherInfo(){
int i, bytes_available;
// ConnectionThread connection;
fingerprints = new FingerprintScanPopup[10];
bioGuised = new BioGuised;
biomodel = new BioModel;
// Initialize Serial
QSerialPort serial;
serial.setPortName("COM6");
serial.open(QIODevice::ReadWrite);
serial.setBaudRate(QSerialPort::Baud9600);
serial.setDataBits(QSerialPort::Data8);
serial.setParity(QSerialPort::NoParity);
serial.setStopBits(QSerialPort::OneStop);
serial.setFlowControl(QSerialPort::NoFlowControl);
qDebug() << "connected";
//delay(500);
while(!serial.isWritable());
QByteArray index("n");
serial.write(index);
for(int i = 0; i < FINGERS; i++){
do{
serial.waitForReadyRead(1000);
bytes_available = serial.bytesAvailable();
}while(bytes_available <= 0);
QByteArray byte_array = serial.read(bytes_available);
// qDebug() << byte_array;
char *rawData = byte_array.data();
int data = (int)*rawData;
qDebug() << data;
if(data == 1){
positions[i] = true;
}
else{
positions[i] = false;
}
if(serial.flush())
{
qDebug() << "flushed ok" << endl;
}
}
serial.close();
//std::thread first();
// connection.start();
i = 0;
int flag = 0;
do{
if(positions[i] == true){
on_RegisterButton_clicked();
flag = 1;
}
}while( i < FINGERS && positions[i++] == false && flag == 0);
// run();
}