惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
博客园_首页
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
Jina AI
Jina AI
N
Netflix TechBlog - Medium
量子位
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
InfoQ
J
Java Code Geeks
T
Tailwind CSS Blog
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
腾讯CDC

博客园 - 夕西行

miniconda安装(windows)到D盘(环境也在D盘) 显卡、cuda、pytorch版本确定与安装 conda的安装与使用 conda虚拟环境中的pip、No module named问题、missing the 'build_editable' hook和PEP660 mmyolo与官方yolo,在背景数据集上的注意事项 跨平台的文件夹映射cifs WinSCP复制时报 Received SSH2_MSG_CHANNEL_DATA for nonexistent channel 0 CMakeLists.txt之include、lib labelImg安装、改软件后打包成exe、改软件功能 Jetson插网线后启动慢 mmyolo数据集、训练 mmyolo安装 QString有中文空格时 VS2015下载 Qt5.15.2在线安装 编译Arm Qt5.14.2(在Arm上本地编译) Qt5.14.2下载 VS2022编译运行VS2015的项目 二进制字面量、字节序、串口发送、转16进制时符号扩展问题 QString的toStdString().c_str()坑
向串口发送数据的方式
夕西行 · 2025-04-12 · via 博客园 - 夕西行

1、远程发送,使用libssh

如Windows通过ssh向Arm板发送指令,Arm板依据指令向自己的串口ttyTHS1发送数据。

2、本地发送,使用QSerialPort 

如Arm板向自己的串口ttyTHS1发送数据。

以向 /dev/ttyTHS1 串口发送 0xAA为例,DeepSeek示例代码如下

#include <QSerialPort>
#include <QDebug>

void sendHexViaSerial(const QString& portName, uint8_t byte) {
    QSerialPort serial;
    serial.setPortName(portName);  // "/dev/ttyTHS1"
    serial.setBaudRate(QSerialPort::Baud115200);  // 根据设备调整
    serial.setDataBits(QSerialPort::Data8);
    serial.setParity(QSerialPort::NoParity);
    serial.setStopBits(QSerialPort::OneStop);

    if (!serial.open(QIODevice::WriteOnly)) {
        qDebug() << "Failed to open serial port:" << serial.errorString();
        return;
    }

    char data = static_cast<char>(byte);  // 0xAA
    if (serial.write(&data, 1) == -1) {
        qDebug() << "Failed to write data:" << serial.errorString();
    } else {
        qDebug() << "Sent:" << QByteArray(1, data).toHex();
    }

    serial.close();
}

int main() {
    sendHexViaSerial("/dev/ttyTHS1", 0xAA);
    return 0;
}