当前位置:网站首页>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
边栏推荐
- Crawl lottery data
- C language to achieve 2048 small game direction merging logic
- 由tcl脚本生成板子对应的vivado工程
- Implement a simple function to calculate the sum of all integers between M ~ n (m < n)
- C medium? This form of
- Resolves the interface method that allows annotation requests to be written in postman
- From introduction to mastery of MATLAB (2)
- A few lines of code teach you to crawl lol skin pictures
- Linux installs MySQL in RPM (super simple)
- Correct opening method of option
猜你喜欢

MATLAB从入门到精通(二)

A few lines of code teach you to crawl lol skin pictures

函数递归以及趣味问题的解决

How to restore MySQL database after win10 system is reinstalled (mysql-8.0.26-winx64. Zip)

Robocode tutorial 5 - enemy class

JD-FreeFuck 京東薅羊毛控制面板 後臺命令執行漏洞

Dynamically add default fusing rules to feign client based on sentinel + Nacos

logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours

Dock installation redis

JD-FreeFuck 京东薅羊毛控制面板 后台命令执行漏洞
随机推荐
登录和发布文章功能测试
Pyppeter crawler
How to restore MySQL database after win10 system is reinstalled (mysql-8.0.26-winx64. Zip)
Win1远程出现“这可能是由于credssp加密oracle修正”解决办法
Box pointer of rust
【ACM】70. 爬楼梯
QT notes on qmap container freeing memory
MySQL auto start settings start with systemctl start mysqld
Nodejs installation
QT error: no matching member function for call to ‘connect‘
Ionic instruction set order from creation to packaging
Refcell in rust
The connection of imx6 network port is unstable after power on
Robocode tutorial 7 - Radar locking
Correct opening method of option
According to the result set queried by SQL statement, it is encapsulated as JSON
14个py小游戏源代码分享第二弹
STM32学习记录0008——GPIO那些事1
In win10 system, all programs run as administrator by default
mysql自动启动设置用Systemctl start mysqld启动