资源简介
能够实现串口通信,实现hex的收发。用到了qtserialport。重设积分

代码片段和文件信息
#include “datadeal.h“
#include
#include
char ConvertHexChar(char ch)
{
if ((ch >= ‘0‘) && (ch <= ‘9‘))
return ch - 0x30;
else if ((ch >= ‘A‘) && (ch <= ‘F‘))
return ch - ‘A‘ + 10;
else if ((ch >= ‘a‘) && (ch <= ‘f‘))
return ch - ‘a‘ + 10;
else return (-1);
}
QByteArray QString2Hex(QString str)
{
QByteArray senddata;
int hexdata lowhexdata;
int hexdatalen = 0;
int len = str.length();
senddata.resize(len / 2);
char lstr hstr;
for (int i = 0; i {
hstr = str[i].toLatin1(); //字符型
if (hstr == ‘ ‘)
{
i++;
continue;
}
i++;
if (i >= len)
break;
lstr = str[i].toLatin1();
hexdata = ConvertHexChar(hstr);
lowhexdata = ConvertHexChar(lstr);
if ((hexdata == 16) || (lowhexdata == 16))
break;
else
hexdata = hexdata * 16 + lowhexdata;
i++;
senddata[hexdatalen] = (char)hexdata;
hexdatalen++;
}
senddata.resize(hexdatalen);
return senddata;
}
QString ShowHex(QByteArray str)
{
QDataStream out(&str QIODevice::ReadWrite); //将str的数据 读到out里面去
QString buf;
while (!out.atEnd())
{
qint8 outChar = 0;
out >> outChar; //每次一个字节的填充到 outchar
QString str = QString(“%1“).arg(outChar & 0xFF 2 16 QLatin1Char(‘0‘)).toUpper() + QString(“ “); //2 字符宽度
buf += str+“\n“;
}
return buf.simplified();
}
//QString Convert4Hex(QByteArray str)
//{
//
// QDataStream out(&str QIODevice::ReadWrite); //将str的数据 读到out里面去
// QString buf;
// while (!out.atEnd())
// {
// qint16 outChar = 0;
// out >> outChar; //每次一个字节的填充到 outchar
// QString str = QString(“%1“).arg(outChar & 0xFFFF 4 16 QLatin1Char(‘0‘)).toUpper() + QString(“ “); //2 字符宽度
//
// buf += str;
// }
// return buf;
//}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 955 2018-08-02 14:54 Serialpor.sln
文件 16142336 2018-08-02 20:05 Serialpor.VC.db
文件 1801 2018-08-02 19:55 Serialpor\datadeal.cpp
文件 212 2018-08-02 16:19 Serialpor\datadeal.h
目录 0 2018-08-02 20:04 Serialpor\Debug\
文件 86898 2018-08-02 19:55 Serialpor\Debug\datadeal.obj
文件 103065 2018-08-02 16:20 Serialpor\Debug\main.obj
文件 107038 2018-08-02 16:20 Serialpor\Debug\moc_Serialpor.obj
文件 5521 2018-08-02 15:20 Serialpor\Debug\qrc_Serialpor.obj
文件 676 2018-08-02 20:04 Serialpor\Debug\qt.log
文件 171 2018-08-02 20:04 Serialpor\Debug\Serialpor.log
文件 282212 2018-08-02 20:04 Serialpor\Debug\Serialpor.obj
目录 0 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\
文件 5974 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\CL.command.1.tlog
文件 134426 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\CL.read.1.tlog
文件 3848 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\CL.write.1.tlog
文件 1868 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\li
文件 4110 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\li
文件 792 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\li
文件 186 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\Serialpor.lastbuildstate
文件 17242 2018-08-02 20:04 Serialpor\Debug\Serialpor.tlog\Serialpor.write.1u.tlog
文件 1978368 2018-08-02 20:04 Serialpor\Debug\vc140.pdb
目录 0 2018-08-02 16:19 Serialpor\GeneratedFiles\
目录 0 2018-08-02 15:20 Serialpor\GeneratedFiles\Debug\
文件 4298 2018-08-02 15:20 Serialpor\GeneratedFiles\Debug\moc_Serialpor.cpp
文件 1408 2018-08-02 15:20 Serialpor\GeneratedFiles\qrc_Serialpor.cpp
文件 7306 2018-08-02 16:19 Serialpor\GeneratedFiles\ui_Serialpor.h
文件 177 2018-08-02 14:54 Serialpor\main.cpp
目录 0 2018-08-02 14:54 Serialpor\Resources\
文件 2162 2018-08-02 20:05 Serialpor\Serialpor.cpp
文件 594 2018-08-02 15:00 Serialpor\Serialpor.h
............此处省略9个文件信息
- 上一篇:MAX17043电量检测模块代码
- 下一篇:仿百度网盘
相关资源
- 易语言OTG串口通信
- delphi 串口通讯
- STM32蓝牙和串口程序
- LCD显示温度+串口接收温度.rar
- WPF USB 网络 串口 通信软件
- DELPHI与西门子200PLC的串口通信实例
- Verilog FPGA UART串口控制器
- USB转串口驱动,FT232R驱动程序,最新
- vtk QT做的三维地质可视化系统2of2
- Qt局域网聊天软件
- PC -- 单片机的串口数据传输系统设计
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- Qt Creator opengl实现四元数鼠标控制轨迹
- QT局域网聊天系统(基于QT5.修改过)
- PC 串口调试软件
- qt-电子点菜系统
- 51单片机读取温度数据存储到SD卡中并
- 单片机与PC机串口通讯仿真
- C 餐厅叫号系统(QT平)
- 串口调试助手V5.0
- QT 实现文件下载
- qt图像处理
- 双串口调试助手 V4.0 _ 可同时调试两个
- 读取串口数据并画实时曲线的VC 程序
- QT,JPEG解码源代码(已完成)
- 网络(UDP)转串口程序
- 串口绘制曲线 将收到的数据进行曲线
- 基于ARM蓝牙传输源程序
- JS操作本地网页串口源码
评论
共有 条评论