K230 USB CDC

Viewed 14

问题描述


发现更新了USB Serial 模块 API 手册,想试用下
1、直接用这个模块传输图片会不会比用串口更快(Canmv实时显示很流畅,但是用串口发图片就很卡)
2、有没有示例代码,不会用报错

from usb import Serial

help(Serial)

import time

usb = Serial("/dev/ttyUSB1", timeout_ms=300)
usb.open()

# 发送数据
msg = f"Hello from K230\r\n"
n = usb.write(msg)
print(f"Sent {n} bytes: {msg.strip()}")

usb.close()

报错:

object <class 'py_usb_serial'> is of type type
  __del__ -- <function>
  open -- <function>
  close -- <function>
  readline -- <function>
  readinto -- <function>
  write -- <function>
  read -- <function>
USB Serial: Open /dev/ttyUSB2 failed

Traceback (most recent call last):
  File "<stdin>", line 14, in <module>
OSError: USB Serial not opened
MPY: soft reboot
CanMV v1.4-2-g873d625(based on Micropython e00a144) on 2025-09-12; k230_canmv_lckfb with K230

硬件板卡


庐山派

1 Answers

你好,CanMV 默认和通信使用的就是CDC ACM,这里的USB_Serial是和4G模块通信使用的。

我其实是想问下这个模块库有没有使用案例,想试一下,自己写的跑不通过