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 ...
随机推荐
- Maven常用参数及其说明
Maven常用参数及其说明 -h,--help Display help information-am,--also-make 构建指定模块,同时构建指定模块依赖的其他模块;-amd,--also-m ...
- css 径向渐变实现渐变小圈
效果如下图: 代码如下: .b-list .ceil .line { height: 20px; width: 100%; margin: 0 auto; background: radial-gra ...
- Day16-异常
异常机制 一.Error和Exception 1.什么是异常 2.异常体系结构 3.Error和Exception Error Exception 二.捕获和抛出异常 1.异常处理机制 抛出异常 捕获 ...
- java图形化界面编程(AWT)
1.AWT编程简介 在JDK发布时,sun公司提供了一套基本的GUI类库,这个GUI类库希望可以在所有平台下都能运行,这套基本类库被称为"抽象窗口工具集",它为java应用程序提供 ...
- selenium webdriver 无法选中元素,修改元素属性可见
<ul data-v-6529428e="" class="el-dropdown-menu el-popper filter-dropdown el-dropdo ...
- Linux用户管理2
passwd给用户修改密码 用户自己给自己设置密码直接passwd root用户给普通用户设置密码passwd 用户名 --stdin从标准输入获取信息 echo "1" | pa ...
- 微信小程序地理定位和城市选择列表
1.先获取用户是否授权地理定位,如果没有让其跳转到设置页面手动开启(获取到的位置是经纬度,需要借助其他地图SDK的地址逆解析获取省市区的名字) getSetting() { wx.getSetting ...
- java文本转语音
下载jar包https://github.com/freemansoft/jacob-project/releases 解压,将jacob-1.18-xxx.dll相应放到项目使用的JAVA_HOME ...
- CentOS7 安裝DHCP服務並啟用DHCP failover
1. 安裝dhcp服務 yum install -y dhcp 2. host1 vi /etc/dhcp/dhcpd.failover failover peer "dhcpfailove ...
- FIR滤波器的设计
FIR数字滤波器的设计 线性相位FIR滤波器的特点 单位冲激响应:\(h(n),0\leq n\leq N-1\) 系统函数:\(H(z)=\sum_{n=0}^{N-1}h(n)z^{-n}\) 零 ...