-
Notifications
You must be signed in to change notification settings - Fork 1.3k
isREPLconnected & isUSBconnected #544
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
I've been researching this between Travis battles. I think I've got USB mostly figured out, but still working on a plan for REPL. Initially I was hoping it could go into the Here are my USB notes so far.
For where to put the function calls, I'm ok with being assigned on this one, but definitely not trying to block anyone out from doing it. I just wanted to document that I'm looking at it, and start the conversation on the particulars. Lastly, please let me know if I'm way off in my approach. I'm well known for trying to make things more difficult than they actually are. |
@sommersoft seems like you are headed the right direction! I think a new |
So, after a few more days crawling around the core, I think checking for a live REPL connection isn't currently possible. One exception to that is WebREPL; that would be doable by checking for the file stats. Of course I caveat all of this with "I am very possibly wrong", but here is how I've come to that conclusion.
In summary, there is no active REPL state information; it all just assumes if the serial connection, through USB/BLE/Web, is active then we should send and listen for REPL activity. I'll keep digging into it, but I think I've hit bedrock... I've got USB check running on SAMD. I'll start working the others soon. |
Use I think USB enumeration status would be a bit more difficult actually. I don't believe we track it at this point. |
So, I'll press forward with just extending I started to look at checking/tracking USB enumeration...a bit out of my depth. That ASF4 stuff is seriously fragmented. Don't know how you and Dan deal with that on the regular... |
The nRF may not be able to tell because it uses a separate USB to UART chip. The newer ones will do USB but this probably hasn't been updated for it. Do a PR for the serial connection first and then do usb enumeration separately. |
After a slightly exhaustive dig into the ESP8266 UART realm, I have concluded that
While we could just as easily return I can of course have my opinions changed or overridden. |
@sommersoft I think I have it set up to wait for a character input before thinking its connected. Its not exact but good enough in my mind. |
Hi, |
@No1089 you can use the following to determine if a USB serial connection is established:
Since USB status is detected based on a serial connection, we named the function according to that. Here is a link to the documentation: https://circuitpython.readthedocs.io/en/3.x/shared-bindings/supervisor/Runtime.html#supervisor.Runtime |
@sommersoft I considered using serial_connected(), but the PC does not have a serial connection running, so would it still work? |
@No1089, is it connected to the PC using a data-capable USB cable? You asked about checking if the filesystem has been mounted by the PC, which leads me to believe that it is. If it isn't connected with a data cable, but rather a charge only cable, then no |
@No1089 If you're mostly trying to determine whether USB power is being supplied or not (as opposed to a serial conenction being present), you could put a voltage divider (two series resistors) between the USB voltage pin and ground, and connect the middle to a pin set to be an analog input. Measure the voltage on the pin.The voltage divider could be two equal resistors (say 100k each), so the voltage would be 2.5V if USB is connected, and 0V if not. You need the voltage divider because the max voltage on an analog pin is 3.3V. It would be damaged by 5V. |
Thanks @dhalbert. Totally forgot about using the USB power pin... |
@sommersoft Thanks. I'll look into it. There is a button input that I'll poll for a couple of seconds and then do a reset before checking |
@No1089 You may know this already, but you can force a reset with |
I think these are both covered now by |
yay for closing our oldest issue! |
could be handy to be able to query, from the python side, if USB is enumerated and/or the REPL is opened!
put down for 3.0 but can be long-term
The text was updated successfully, but these errors were encountered: