Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8146

MicroPython • Re: Dynamic USB Devices

$
0
0
Hi hippy,

I'm the author of this feature, I'm glad to hear you're interested in it but sorry to hear you're not having a great experience.

The maintainers discussed the decision to reset any dynamic USB devices on soft reset a lot, as I agree it's pretty annoying. The problem is that, as you've described, if the USB device is implemented in Python and the Python environment fully resets then the state of the USB device is lost.

If you know that the exact same device configuration will come back afterwards then you may be able to pretend nothing has happened, at least provided that the host doesn't initiate any USB transfer during the period that the reset is happening. However that's only the case if the "dynamic" USB device is completely stateless, otherwise the host and the device will end up out of sync after the reset. So the trade-off was to simulate unplugging and re-plugging each time and deal with that obvious pain, rather than subtle and hard to understand bugs if the host and device end up with mismatched states.

We do plan to add support for detecting the disconnect/reconnect sequence to mpremote, so the current "error out and have to run again" pain point goes away and it keeps running smoothly. Hopefully Thonny can do something similar.

At this point the feature is only the low level interface, and there are relevant warnings and tips in the docs, so hopefully folks can manage with that.

If I understand correctly, you were previously patching Micropython to add other TinyUSB configurations? You definitely should be able to keep doing that without running into any of these limitations, if you decide this feature isn't suitable yet.

Statistics: Posted by projectgus — Wed Mar 20, 2024 6:57 am



Viewing all articles
Browse latest Browse all 8146

Trending Articles