前言

​ 使用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. Oracle存储过程 Call使用

    在 Oracle 中,可以将存储过程(PROCEDURE)定义在一个包(PACKAGE)中. 要调用包中的存储过程,需要使用包名和存储过程名来引用它们.以下是一个示例: 假设我们有一个名为 my_pa ...

  2. Jetpack compose初尝试

    2021/07/29 Jetpack compose1.0正式发布,已经可以在生产环境中使用了. 下面的内容为根据官方教程尝试的总结,上手没难度,而且也不需要配置什么环境. Android 开发者   ...

  3. 20200925--矩阵乘法(奥赛一本通P94 多维数组)

    计算两个矩阵的乘法.n*m阶的矩阵A乘以m*k阶的矩阵B得到的矩阵C是n*k阶的,且C[i][j]=A[i][0]*B[0][j]+A[i][1]*B[1][j]+...+A[i][m-1]*B[m- ...

  4. ArrayList 的toArray的转换数组方法的注意事项

    ArrayList 的toArray的转换数组方法的注意事项 toArray()一共有两个方法 toArray(T[] a) 和toArray() 源码是 进行使用toArray()方法时候,使用 ( ...

  5. Upload上传组件,上传之后,再次预览下载按钮不见问题

    如图所示红色部分不见了. 解决方式: fileList 代表的是上传后当前文件内容的具体信息名称,该数据决定了上传之后页面展示的内容 this.fileList.push({ uid:remark.i ...

  6. 原来sed不支持非贪婪匹配

    场景 从GISAID上面批量下载下来的序列id很长,格式如下: 太长了,并且makeblastdb的时候-parse_seqids参数会导致报错,大概是长度太长不符合要求无法处理之类的. 不作处理去掉 ...

  7. 探秘ThreadLocal

    一 类结构 主要是set(T), get(), remove()方法 二  TheadLocal是什么时候创建的 threadLocal的初始化, lazy creating, 用到的时候(get 或 ...

  8. 使用npm包安装vant组件

  9. tuxedo How To Disable Server Side Trace Which IS Enabled BY Client?

    影响版本: Oracle Tuxedo - Version 8.1 to 11.1.1.2.0Information in this document applies to any platform. ...

  10. 全新TI AM62xx系列核心板上市,小小身板蕴藏巨大势能!

    2011年TI推出AM335x,成为了此后市场上最受欢迎的通用工业级ARM处理器,并广泛应用于工业HMI, 医疗电子,机器人,能源,汽车等领域.随着工业4.0的发展,HMI人机交互.工业工控.医疗等领 ...