# 任务 5_Serial **Repository Path**: Ermaotie/task-5--serial ## Basic Information - **Project Name**: 任务 5_Serial - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-09-24 - **Last Updated**: 2021-10-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 任务五-串口通信 以下均为`usb`转`ttl`,`rx`短接`tx`的情况。 1. `cutecom`模拟 - 短接`rx`与`tx`,`usb`插入电脑 - 查找设备 - `/dev`下 ``` $ ls /dev | grep "ttyUSB" ttyUSB0 ``` - 修改其权限,使得`cutecom`能够读写设备 ``` $ sudo chmod 666 /dev/ttyUSB0 ``` - 打开`cutecom`,查看效果。 ![cutecom_demo](./cutecom_demo.png) 模拟通信成功 2. 代码通信 - `C++`平台,`sys/ioctl.h` `termios.h` `fcntl.h`等。 - 运行方式 - 端口查找及权限设置如`cutecom`模拟 - 运行以下命令 ``` mkdir build && cd build cmake .. make ./task8-Serial ``` - 效果如下 ``` serialPort Test 向串口写入了:12345678 串口收到了: 12345678 Process finished with exit code 0 ``` - 参考:[Linux 下串口编程(C++ 程序设计)](https://blog.csdn.net/yaojiawan/article/details/90478368)