📄 mydialog.cpp
字号:
#include "mydialog.h"#include <qpushbutton.h>#include <qmessagebox.h>MyDialog::MyDialog(QWidget * parent, const char * name, bool modal, WFlags f) :MyDialogUi(parent,name,modal,f){ connect(buttonSend,SIGNAL(clicked()),this,SLOT(senddata_slot())); connect(buttonStop,SIGNAL(clicked()),this,SLOT(stopsend_slot())); devfd = -1; memset((void *)buff,0,sizeof(char)*160);}MyDialog::~MyDialog(){}void MyDialog::senddata_slot(){ devfd = open(DEVSTR, O_RDWR); if (devfd == -1) { printf("open serial error:%s\n", DEVSTR); QMessageBox::information(this,tr("error"),tr("open serial error")); return ;//return fd; } struct termios options; bzero(&options, sizeof(options)); options.c_cflag |= B9600; cfsetispeed(&options, B9600); cfsetospeed(&options, B9600); options.c_cflag |= CREAD | CLOCAL; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; options.c_oflag = 0; options.c_lflag = 0; options.c_cc[VTIME] = 150; options.c_cc[VMIN] = 0; tcflush(devfd, TCIFLUSH); tcsetattr(devfd, TCSANOW, &options); while (1) { char buffer[1]; //fd= openserial( comport ); buffer[0] = 0xff; buffer[1] = 0xaa; buffer[2] = 0xbb; buffer[3] = 0xcc; write(devfd, buffer, 4 ); } }void MyDialog::stopsend_slot(){ //if(devfd>0) ::close(devfd); if(devfd==0) ::close(devfd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -