当前位置:网站首页>K210串口通信
K210串口通信
2022-04-23 18:26:00 【卷卷怪】
一、串口配置
from machine import UART #导入UART模块
fm.register(9, fm.fpioa.UART1_TX, force=True) #9为tx接rx
fm.register(10, fm.fpioa.UART1_RX, force=True) #10为rx接tx
uart_A = UART(UART.UART1, 9600, 8, 1, 0, timeout=1000, read_buf_len=4096)
基本是就是配置串口的引脚和串口参数的设置。
二、串口发送数据
串口发送数据调用uart_A.write()即可。
三、串口接收数据
串口接收数据调用uart_A.read()即可。注意在mxai py 中接收的字节流数据,需将字节流转为字符串并且还要去掉结束符才能使用接收的数据(如果利用数据判断需这样操作)
if uart_A.any():
while uart_A.any():
read_data = uart_A.read()
read_data = read_data.decode('utf-8','ignore') # 转为字符串
if read_data[0] == 'b': # 切片
.....
read_data = ''
版权声明
本文为[卷卷怪]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_53144843/article/details/124363237
边栏推荐
- Docker 安装 Redis
- A few lines of code teach you to crawl lol skin pictures
- Introduction to QT programming
- Crawl lottery data
- Rust: a simple example of TCP server and client
- Robocode tutorial 5 - enemy class
- Matlab tips (6) comparison of seven filtering methods
- QT add external font ttf
- Connection mode of QT signal and slot connect() and the return value of emit
- idea中安装YapiUpload 插件将api接口上传到yapi文档上
猜你喜欢
QT tablewidget insert qcombobox drop-down box
Docker installation MySQL
With the use of qchart, the final UI interface can be realized. The control of qweight can be added and promoted to a user-defined class. Only the class needs to be promoted to realize the coordinate
Closure type of rust (difference between FN, fnmut and fnone)
【ACM】376. Swing sequence
Robocode tutorial 8 - advanced robot
logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours
硬核解析Promise對象(這七個必會的常用API和七個關鍵問題你都了解嗎?)
Quantexa CDI(场景决策智能)Syneo平台介绍
The vivado project corresponding to the board is generated by TCL script
随机推荐
Daily network security certification test questions (April 15, 2022)
Creation and use of QT dynamic link library
QT error: no matching member function for call to ‘connect‘
Robocode tutorial 7 - Radar locking
Cutting permission of logrotate file
Can filter
Daily CISSP certification common mistakes (April 14, 2022)
Crawl lottery data
Use of regular expressions in QT
Ionic 从创建到打包指令集顺序
CISSP certified daily knowledge points (April 18, 2022)
Linux installs MySQL in RPM (super simple)
WiFi ap6212 driver transplantation and debugging analysis technical notes
The connection of imx6 network port is unstable after power on
idea中安装YapiUpload 插件将api接口上传到yapi文档上
Quantexa CDI(场景决策智能)Syneo平台介绍
The vivado project corresponding to the board is generated by TCL script
Interpretation and compilation of JVM
Resolves the interface method that allows annotation requests to be written in postman
Software test summary