-
Notifications
You must be signed in to change notification settings - Fork 1.3k
2nd USB CDC works at first, then device won't connect to computer #6018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could you upload your |
On the host/computer I used: import serial
import time
import adafruit_board_toolkit.circuitpython_serial
comports = adafruit_board_toolkit.circuitpython_serial.data_comports()
device_COM = 'COM6'
if not comports:
raise Exception("No sensor modules found")
try:
device = serial.Serial(device_COM, baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=1, xonxoff=0, rtscts=0)
device.write(b'hi!')
response = str(device.readline(), 'utf-8')
print(response)
finally:
device.close() On the CircuitPython side I used: import time
import usb_cdc
if usb_cdc.data is None:
print("Need to enable USB CDC serial data in boot.py!")
while True:
pass
usbl = usb_cdc.data[1]
def send_data(data):
data = bytes(data+"\n", 'utf-8')
usbl.write(data)
def read_data():
data = usb_cdc.data.read(6)
return data
usb_cdc.data.timeout = 5
while True:
print(read_data())
send_data("Helooo!")
time.sleep(1)` |
When it does not work, see if there are any errors in |
You are always using COM6, but it might not be COM6: comports = adafruit_board_toolkit.circuitpython_serial.data_comports()
device_COM = 'COM6' There is no usbl.write(data) |
When I boot in safe mode, the boot_out.txt is clean (see below). When the device is not able to connect, I don't know how to access the file that would have generated. I has happened to all those I've tried: 1 Feather M4 and 2 Adalogger M0. I will test more devices as able. I change the address manually. 'COM6' has been typical in Windows, 'ttyACM01' in linux/Rpi. I will note that the code never above runs as far as I know ... the microcontroller does not connect REPL or CIRCUITPY when data CDC is enabled. Code edited for usbl = usb_cdc.data[1] (I had edited it away, apologize)
|
I no longer see the issue in Circuitpython 7.3.0 |
I have encountered this issue on a Pi Pico running version 7.3.1 (just installed); my
My
I've found that if I start with a working |
@nhedler-cubeworks What are the host computer(s) and their OS versions? Thanks. |
Windows 10 and some kind of Linux, maybe Mint? Two different systems. |
I can reproduce the issue on the pico with 7.3.1 and main, on MacOS. This code.py waits for supervisor.runtime.usb_connected, in case it's related (though it might just insert a wait in the code, like the sleep). It has the board appear correctly and prints out values between 100 and 400ms. import time
import usb_cdc
# time.sleep(2)
t0 = time.monotonic_ns()
import supervisor
while not supervisor.runtime.usb_connected:
pass
t1 = time.monotonic_ns()
delta = (t1 - t0) // 1000 / 1000
usb_cdc.data.timeout = 1
usb_cdc.data.read(1)
while True:
print(delta)
time.sleep(0.2) # don't flood |
I'm able to reproduce this issue as well on 7.3.1 and 8.x. |
Man, thought I fried my Raspberry (was playing with non-micro USB connection). The same issue as above.
|
@hathach It looks like this is hitting a TU_ASSERT on nRF.
|
I found the issue. TinyUSB isn't checking that the CDC structures are actually setup and the read can queue a USB transfer. This transfer can happen on the wrong endpoint when the CDC structures aren't ready! So, we check connected before reading. |
Check for connected before calling read. Otherwise TinyUSB may setup the read on the wrong endpoint. Fixes #6018 `
CircuitPython version
Code/REPL
Behavior
When connected to a Windows machine sees the microcontroller as "Unknown USB device (device descriptor request failed)". When connected to a Rpi, there is no apparent acknowledgement of plugging it in and there are no new objects in /dev.
Description
I enabled CDC in boot.py as above and I established communications between microcontrollers (M4, 2 different M0 Adalogger) and hosts (3 different Win10 tested, Raspberry Pi 4). I wrote and successfully tested code, per Adafruit guides here, here and here (thank you!!).
A few hours later the device stops ceases to behave well. Instead, now when connected to a computer, the microcontroller is unable to connect to the computer in "normal" mode.
When connected to a Windows machine sees the microcontroller as "Unknown USB device (device descriptor request failed)" No new COM devices become present, REPL does not work, CIRCUITPY does not appear. I tried Device Cleanup Tool v1.2.1 to no avail. When connected to a Rpi, there is no apparent acknowledgement of plugging it in and there are no new objects in /dev (when it worked, I saw them as ttyACM0 and ttyACM1, rather than ttyUSBx).
However, the microcontrollers connect in "safe" and "boot" modes. Removing usb_cdc.enable from boot.py makes it so that REPL/CIRCUITPY connects as usual, and behaves as expected in other ways.
I have re-installed CircuitPython to no avail. I have not attempted previous versions (I can't navigate to the repository of my devices! please, link?). I have turned on, off, re-booted in various orders, and looked for newly-installed drivers.
Additional information
I wonder if it is related to issue #4986, in a way that makes the microcontroller unable to connect at all if the 2nd CDC is enabled.
The text was updated successfully, but these errors were encountered: