前言

​ 使用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的更多相关文章

  1. 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 ...

  2. Serial Port Programming using Win32 API(转载)

    In this tutorial we will learn How to communicate with an external device like a microcontroller boa ...

  3. select/poll/epoll on serial port

    In this article, I will use three asynchronous conferencing--select, poll and epoll on serial port t ...

  4. [转]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 ...

  5. 串口总是报'Error opening serial port'

    Comm1.CommName := '//./' + Trim(combx_Port.Text); 目前串口大于20  用上面方法解决的 网上也有上面方法解决如下错误的. 若是您已会应用SPCOMM且 ...

  6. Unable to open serial port /dev/ttyUSB0

    ubuntu12.04使用USB转串口时出现权限不够问题,如下 Unable to open serial port /dev/ttyUSB0 权限不够 解决办法: 通过增加udev规则来实现.步骤如 ...

  7. [原]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 ...

  8. 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 ...

  9. 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 ...

  10. Non-standard serial port baud rate setting

    ////combuad_recv.cpp #include <stdio.h> /*标准输入输出定义*/ #include <stdlib.h> /*标准函数库定义*/ #in ...

随机推荐

  1. JavaScript 取消事件的默认动作

    preventDefault() 方法 Event 对象 定义和用法 取消事件的默认动作. 语法 event.preventDefault() 说明 该方法将通知 Web 浏览器不要执行与事件关联的默 ...

  2. binlog2sql 实战心得

    原创:binlog2sql在GitHub的地址:https://github.com/danfengcao/binlog2sql 作者:danfengcao 功能:从MySQL binlog解析出你要 ...

  3. MySql 自动设置时间(自动获取时间,填充时间)

    应用场景: 1.在数据表中,要记录每条数据是什么时候创建的,不需要应用程序去特意记录,而由数据数据库获取当前时间自动记录创建时间: 2.在数据库中,要记录每条数据是什么时候修改的,不需要应用程序去特意 ...

  4. thymeleaf基础学习

    Thymeleaf 1.标准表达式 ${...}:变量表达式 *{...}: 选择表达式 #{...} : 消息表达式 @{...}: 连接表达式 <img th:src="@{url ...

  5. 国际化vue-i18n 向语言包中传入参数

    模板 <span>{{$t('el.table.total', { pagetotal: 123 })}}</span> js代码中 this.$t('el.table.num ...

  6. hdu:排列组合(指数型母函数)

    Problem Description有n种物品,并且知道每种物品的数量.要求从中选出m件物品的排列数.例如有两种物品A,B,并且数量都是1,从中选2件物品,则排列有"AB",&q ...

  7. python Queue(队列学习)

    Python 的Queue模块中提供了同步的.线程安全的队列类,包括FIFO(先入先出)队列Queue,LIFO(后入先出)队列LifoQueue,和优先级队列PriorityQueue.这些队列都实 ...

  8. 【随笔】记录Centos7 firewall-cmd防火墙的文档与命令记录

    注意:firewall-cmd命令后面的参数前面是两个短-,这里显示的不是很清晰 查看firewall-cmd运行状态 # firewall-cmd --state 开放8080端口 # firewa ...

  9. vscode工程目录文件及文件夹摘选

    在工程工作区下新建一个.vscode 文件夹中并新建一个名为"settings.json"的文件,然后在 settings.json 中输入如下内容: { "search ...

  10. Vue学习之基础大全

    1 导入vue: 2 <script src="vue.min.js"></script> 3 创建vm实例 4 var vm=new Vue({ 5 el ...