当前位置:网站首页>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
边栏推荐
- Resolves the interface method that allows annotation requests to be written in postman
- Rust: a simple example of TCP server and client
- 14 py games source code share the second bullet
- kettle庖丁解牛第17篇之文本文件输出
- MATLAB从入门到精通(二)
- Daily CISSP certification common mistakes (April 19, 2022)
- Mysqldump backup database
- QT add external font ttf
- Qt读写XML文件(含源码+注释)
- Gobang game based on pyGame Library
猜你喜欢

Analysez l'objet promise avec le noyau dur (Connaissez - vous les sept API communes obligatoires et les sept questions clés?)

QT reading and writing XML files (including source code + comments)

Imx6 debugging LVDS screen technical notes

powerdesigner各种字体设置;preview字体设置;sql字体设置

C medium? This form of

硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)

Setting up keil environment of GD single chip microcomputer

Docker installation MySQL

Cygwin64 right click to add menu, and open cygwin64 here

MySQL auto start settings start with systemctl start mysqld
随机推荐
Installation du docker redis
Resolves the interface method that allows annotation requests to be written in postman
QT add external font ttf
Daily CISSP certification common mistakes (April 12, 2022)
Docker 安装 MySQL
CISSP certified daily knowledge points (April 14, 2022)
Gobang game based on pyGame Library
Mysqldump backup database
Keil RVMDK compiled data type
STM32学习记录0008——GPIO那些事1
C language simulates entering and leaving the stack, first in first out, first in first out, shared memory
Introduction to QT programming
Implement a simple function to calculate the sum of all integers between M ~ n (m < n)
Excel intercept text
Reptile efficiency improvement method
word frequency count
Creation and use of QT dynamic link library
Qt读写XML文件(含源码+注释)
Setting up keil environment of GD single chip microcomputer
Win1远程出现“这可能是由于credssp加密oracle修正”解决办法