当前位置:网站首页>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
边栏推荐
- Daily CISSP certification common mistakes (April 19, 2022)
- Custom prompt box MessageBox in QT
- 14 py games source code share the second bullet
- Crawler for querying nicknames and avatars based on qqwebapi
- Connection mode of QT signal and slot connect() and the return value of emit
- Test questions of daily safety network (February 2024)
- Hard core parsing promise object (do you know these seven common APIs and seven key questions?)
- 登录和发布文章功能测试
- 7-21 wrong questions involve knowledge points.
- Implement a simple function to calculate the sum of all integers between M ~ n (m < n)
猜你喜欢

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

Robocode tutorial 8 - advanced robot

mysql自动启动设置用Systemctl start mysqld启动

Qt读写XML文件(含源码+注释)

In win10 system, all programs run as administrator by default

Vulnérabilité d'exécution de la commande de fond du panneau de commande JD - freefuck

QT add external font ttf

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

Robocode tutorial 3 - Robo machine analysis

Gobang game based on pyGame Library
随机推荐
Notepad + + replaces tabs with spaces
From source code to executable file
Daily CISSP certification common mistakes (April 12, 2022)
Dynamically add default fusing rules to feign client based on sentinel + Nacos
Custom prompt box MessageBox in QT
In shell programming, the shell file with relative path is referenced
CISSP certified daily knowledge points (April 19, 2022)
Serialization scheme of serde - trust
Docker 安裝 Redis
Kettle paoding jieniu Chapter 17 text file output
【ACM】70. 爬楼梯
Cells in rust share variable pointers
Gobang game based on pyGame Library
Multifunctional toolbox wechat applet source code
Hard core parsing promise object (do you know these seven common APIs and seven key questions?)
Qt读写XML文件(含源码+注释)
QT error: no matching member function for call to ‘connect‘
Halo open source project learning (VII): caching mechanism
Software test summary
Imx6 debugging LVDS screen technical notes