资源简介
一款使用与windows(qt开发)的串口软件,具有接受发送数据,波形显示,crc16-MODBUS数据解析,保存文件,导入文件并绘制波形的功能。
代码片段和文件信息
#include “frmmain.h“
#include “ui_frmmain.h“
#include “myhelper.h“
#define _TIME_ qPrintable (QTime::currentTime().toString(“hh:mm:ss:zzz“))
frmMain::frmMain(QWidget *parent) :
QWidget(parent)
ui(new Ui::frmMain)
{
ui->setupUi(this);
myHelper::FormInCenter(this);
this->InitForm();
this->InitPlot();
windows=true;
lingdian=false;
stop=true;
ui->TXPID->setEnabled(false);
ui->cboxSleepTime->setEnabled(false);
ui->ckHexReceive->setEnabled(false);
ui->ckHexSend->setEnabled(false);
}
frmMain::~frmMain()
{
delete ui;
}
void frmMain::InitForm()
{
this->showMaximized();
MaxCount = 20000;
CurrentCount = 0;
SleepTime = 100;
ReceiveCount = 0;
SendCount = 0;
IsShow = true;
IsHexSend = true;
IsHexReceive = true;
com = 0;
QStringList comList;//串口号
QStringList baudList;//波特率
QStringList parityList;//校验位
QStringList dataBitsList;//数据位
QStringList stopBitsList;//停止位
#ifdef Q_OS_WIN32
comList.clear();
comList << “COM1“ << “COM2“ << “COM3“ << “COM4“ << “COM5“ << “COM6“ << “COM7“ << “COM8“;
#endif
#ifdef Q_OS_LINUX
#ifdef __arm__
comList.clear();
comList << “ttySAC0“ << “ttySAC1“ << “ttySAC2“ << “ttySAC3“;
#else
comList.clear();
comList << “ttyUSB0“ << “ttyS0“ << “ttyS1“ << “ttyS2“ << “ttyS3“ << “ttyS4“;
#endif
#endif
ui->cboxPortName->addItems(comList);
ui->cboxPortName->setCurrentIndex(0);
baudList << “50“ << “75“ << “100“ << “134“ << “150“ << “200“ << “300“
<< “600“ << “1200“ << “1800“ << “2400“ << “4800“ << “9600“
<< “14400“ << “19200“ << “38400“ << “56000“ << “57600“
<< “76800“ << “115200“ << “128000“ << “256000“;
ui->cboxBaudRate->addItems(baudList);
ui->cboxBaudRate->setCurrentIndex(12);
parityList << “无“ << “奇“ << “偶“;
#ifdef Q_OS_WIN//如果是windows系统
parityList << “标志“;
#endif
parityList << “空格“;
ui->cboxParity->addItems(parityList);
ui->cboxParity->setCurrentIndex(0);
dataBitsList << “5“ << “6“ << “7“ << “8“;
ui->cboxDataBit->addItems(dataBitsList);
ui->cboxDataBit->setCurrentIndex(3);
stopBitsList << “1“;
#ifdef Q_OS_WIN//如果是windows系统
stopBitsList << “1.5“;
#endif
stopBitsList << “2“;
ui->cboxStopBit->addItems(stopBitsList);
ui->cboxStopBit->setCurrentIndex(0);
for (int i = 0; i <= 500; i = i + 50) {
ui->cboxSleepTime->addItem(QString::number(i));
}
ui->cboxSleepTime->setCurrentIndex(0);
ui->cboxInterval->addItem(QString::number(100));
ui->cboxInterval->addItem(QString::number(200));
ui->cboxInterval->addItem(QString::number(300));
for (int i = 500; i <= 10000; i = i + 500) {
ui->cboxInterval->addItem(QString::number(i));
}
ui->cboxInterval->setCurrentIndex(3);
// for (int i = 100; i <= 1000; i = i + 100) {
ui->cboxMaxCou
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-06-05 14:36 com\
文件 480103 2015-03-26 10:12 com\QQ截图20150321135219.jpg
文件 955 2019-05-31 09:27 com\com.pro
文件 23908 2019-06-05 14:36 com\com.pro.user
文件 2014 2019-05-21 09:12 com\form.ui
文件 22822 2019-06-05 14:25 com\frmmain.cpp
文件 2144 2019-06-04 09:20 com\frmmain.h
文件 15413 2019-06-04 11:19 com\frmmain.ui
文件 237 2019-05-23 17:51 com\main.cpp
文件 5432 2019-05-21 15:38 com\myhelper.h
文件 6807 2019-06-03 10:05 com\mythread.cpp
文件 1043 2019-06-03 14:09 com\mythread.h
文件 842538 2014-12-28 06:09 com\qcustomplot.cpp
文件 149211 2014-12-28 06:09 com\qcustomplot.h
目录 0 2019-05-08 11:05 com\serialportapi\
文件 32794 2015-03-20 14:05 com\serialportapi\qextserialport.cpp
文件 7245 2015-03-20 14:05 com\serialportapi\qextserialport.h
文件 2641 2015-03-20 14:05 com\serialportapi\qextserialport_global.h
文件 7191 2015-03-20 14:05 com\serialportapi\qextserialport_p.h
文件 15351 2015-03-20 14:05 com\serialportapi\qextserialport_unix.cpp
文件 15069 2015-03-20 14:05 com\serialportapi\qextserialport_win.cpp
评论
共有 条评论