当前位置:网站首页>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
边栏推荐
- Matlab tips (6) comparison of seven filtering methods
- Daily network security certification test questions (April 14, 2022)
- MySQL auto start settings start with systemctl start mysqld
- Quantexa CDI(场景决策智能)Syneo平台介绍
- From introduction to mastery of MATLAB (2)
- QT add external font ttf
- Kettle paoding jieniu Chapter 17 text file output
- Resolves the interface method that allows annotation requests to be written in postman
- Multi thread safe reference arc of rust
- Climbing watermelon video URL
猜你喜欢
Custom prompt box MessageBox in QT
Kettle paoding jieniu Chapter 17 text file output
函数递归以及趣味问题的解决
C medium? This form of
Multifunctional toolbox wechat applet source code
Win1远程出现“这可能是由于credssp加密oracle修正”解决办法
使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
【ACM】376. Swing sequence
Resolves the interface method that allows annotation requests to be written in postman
In win10 system, all programs run as administrator by default
随机推荐
使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
QT notes on qmap container freeing memory
Install the yapiupload plug-in in idea and upload the API interface to the Yapi document
Kettle paoding jieniu Chapter 17 text file output
Docker 安裝 Redis
From introduction to mastery of MATLAB (2)
Creation and use of QT dynamic link library
Vulnérabilité d'exécution de la commande de fond du panneau de commande JD - freefuck
WiFi ap6212 driver transplantation and debugging analysis technical notes
logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours
硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)
Interpretation and compilation of JVM
Robocode tutorial 5 - enemy class
Imx6 debugging LVDS screen technical notes
Rust: how to implement a thread pool?
Multi thread safe reference arc of rust
Const keyword, variable and function are decorated with const
Daily network security certification test questions (April 12, 2022)
Closure type of rust (difference between FN, fnmut and fnone)
函数递归以及趣味问题的解决