⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.ui.h~

📁 linux下用QT 做的串口编程工具,在linux下做串口调试有一定的参考价值
💻 H~
字号:
/****************************************************************************** ui.h extension file, included from the uic-generated form implementation.**** If you wish to add, delete or rename functions or slots use** Qt Designer which will update this file, preserving your code. Create an** init() function in place of a constructor, and a destroy() function in** place of a destructor.*****************************************************************************/#include "serial.h"#include <iostream.h>#include <qtimer.h>#include <qmessagebox.h>Serial comm;QTimer *recTimer;using namespace std;void mainFrm::OpenPort(){  int baud,databit;  if (!comm.readyTTY(comPort->currentItem()))  {    QMessageBox::information(this,"serial commucation","Can't Open Serial Port!");    return;   }  comm.lockTTY();  baud = atoi(comBaud->currentText());  comm.setTTYSpeed(baud);  databit = atoi(comData->currentText());  comm.setTTYParity(databit,'N',1);    recTimer = new QTimer( this,"timer" );  connect( recTimer, SIGNAL(timeout()), this, SLOT(showData()));  recTimer->start(10,FALSE); //if TRUE, timer execute one  closeBtn->setEnabled(true);  openBtn->setEnabled(false);}void mainFrm::closeComm(){  comm.cleanTTY();  openBtn->setEnabled(true);  closeBtn->setEnabled(false);  delete recTimer;}void mainFrm::sendData(){  const char *str = txt->text();  char buf[] = "\n\r";  comm.sendnTTY((char*)str,strlen(str));  comm.sendnTTY(buf,2);}void mainFrm::showData(){   char buf[100];    memset(buf,'\0',sizeof(buf));   cout << "yangsen" << endl;   if (comm.recvnTTY(buf,sizeof(buf))>0)    show_content->setText(show_content->text()+QString(buf));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -