Serial port
前言
使用qt开发一款简易串口助手。
目标:
1. 实现正常串口通信。
2. 能够传输AT指令。(需要注意回车符)
github仓库地址:shadow-wd/Serial-port-assistant: 简易串口助手 (github.com)
还在持续更新.......
开发环境
windows平台:qtcreator 5.9.5
代码
代码量小,注释写在代码中。
QcomboBox
对于下拉选项框来说,有一些选项框需要显示给用户汉字(字符串),但是代码中获取用户选项的时候,不能去匹配汉字。

使用QMap将string和int类型绑定,显示给用户string类型,匹配时通过int类型匹配。
QMap<QString,int> parityvalue;
parityvalue.insert("NoParity",1);
parityvalue.insert("EvenParity",2);
parityvalue.insert("OddParity",3);
parityvalue.insert("SpaceParity",4);
parityvalue.insert("MarkParity",5);
// 不知道为什么这里插入的顺序很混乱
foreach (const QString &str, parityvalue.keys()) {
ui->checkbit->addItem(str,parityvalue.value(str));
}
AT指令回车
在开发过程中,接收数据很容易,但是发送AT指令总是失败,经过排查问题发现时AT指令的回车符没能成功识别。
// 对发送数据追加回车
if(ui->enter->isChecked())
{
bytes.append("\r\n");
}
a= serialPort->write(bytes.data());
因此添加了给数据追加回车的选项框。
Serial port的更多相关文章
- Serial Port Programming on Linux(转载)
This is a tutorial on how to program the Serial Ports on your Linux box.Serial Ports are nice little ...
- Serial Port Programming using Win32 API(转载)
In this tutorial we will learn How to communicate with an external device like a microcontroller boa ...
- select/poll/epoll on serial port
In this article, I will use three asynchronous conferencing--select, poll and epoll on serial port t ...
- [转]How Can I Find Out What Is Using a Busy or Reserved Serial Port?
转自:http://digital.ni.com/public.nsf/allkb/29B079481C5ECE76862578810082394E How Can I Find Out What I ...
- 串口总是报'Error opening serial port'
Comm1.CommName := '//./' + Trim(combx_Port.Text); 目前串口大于20 用上面方法解决的 网上也有上面方法解决如下错误的. 若是您已会应用SPCOMM且 ...
- Unable to open serial port /dev/ttyUSB0
ubuntu12.04使用USB转串口时出现权限不够问题,如下 Unable to open serial port /dev/ttyUSB0 权限不够 解决办法: 通过增加udev规则来实现.步骤如 ...
- [原]OS X 10.9 Mavericks - Virtual Serial Port Issues
If want to do iOS kernel debugging on A4 device, first you should install Virtual COM port (VCP) dri ...
- ROS 进阶学习笔记(12) - Communication with ROS through USART Serial Port
Communication with ROS through USART Serial Port We always need to communicate with ROS through seri ...
- Connecting to a Remote Serial Port over TCP/IP
https://www.acmesystems.it/socat This article illustrates how to realize a lan to serial gateway Rem ...
- Non-standard serial port baud rate setting
////combuad_recv.cpp #include <stdio.h> /*标准输入输出定义*/ #include <stdlib.h> /*标准函数库定义*/ #in ...
随机推荐
- stm32 微秒定延时问题
problem: 如果想用计时器定时微秒级,不要使能自动重载:代码如下: static uint16_t counter; void Delay_us(uint32_t us){ counter=0x ...
- 微信小程序开发常见问题
1.不同页面之间的传值方式 通过URL问号传值 当前页面 wx.navigateTo({ url: '/pages/aaa/aaa?/userName=norma' }) 2. 另一个页面通过opti ...
- swift 应用内切换语言
1:在project info中的locations添加需要的语言 2:创建Localizable.strings文件 点击右边的localization勾选需要的语言 3:创建InfoPlist.s ...
- LEETCODE 数组嵌套
题目:数组嵌套 索引从0开始长度为N的数组A,包含0到N - 1的所有整数.找到最大的集合S并返回其大小,其中 S[i] = {A[i], A[A[i]], A[A[A[i]]], ... }且遵守以 ...
- Qt编译问题之FTH (7156) Fault tolerant heap shim applied to current process
有时候Qt编译会出现FTH: (7156): *** Fault tolerant heap shim applied to current process. This is usually due ...
- 06 HBase安装与伪分布式配置
1.下载压缩文件 2.解压 3.修改文件夹名 4.修改文件夹权限 5.配置环境变量 6.伪分布式配置文件 7.启动HDFS,启动Hbase 8.进入shell界面 9.停止Hbase,停止HDFS运行
- EF调用sql语句
1.连接数据库 2.在Dal进行调用sql语句 public List<UserInfo> PageShow(out int totalcount,out int totalpage, s ...
- 怎样清空 DNS 缓存?
在 Windows 下命令行执行:ipconfig /flushdns 在 macOS 下执行命令:sudo killall -HUP mDNSResponder
- C#测试web服务是否可用(转)
转摘:http://www.cnblogs.com/xienb/p/3443282.html winform客户端经常需要调用webservice或者WCF进行数据交互,但是远程服务有可能不存在或者服 ...
- [Unity基础]碰撞和触发
参考链接: https://www.cnblogs.com/hont/p/4472326.html 碰撞关系表: https://docs.unity3d.com/Manual/CollidersOv ...