I know we can see if the USB is connected to an active virtual com port (windows) - is it possible to detect if the USB is plugged in, before the com port is opened on the host?
In my case I’m using Teraterm to do some setup over serial USB, and I’m using Serial.isConnected() to prevent Sleep while the connection is live - but this means I have to quickly activate the correct serial port in Teraterm to catch the Photon before it sleeps again. It would be nice if the code could see if the USB was plugged in even if the com port was not active. I would have thought it possible as windows detects the USB port on the photon as soon as its plugged in, so the Photon must know its connected to a USB host device.
On a side note: how do I stop Windows creating a new com port every time I plug in a new Photon?
I’m interested in this topic as well. Did you ever find a solution @twospoons?
For my project I’d like the Photon to detect if it is connected to a host because that will change the amount of current the Photon will attempt to drive into its connected circuitry - 0.5A from a computer USB port vs. 1A from a USB charger.
No, no response from Particle on this. So for the time being I’m stuck with activating teraterm quickly.
It would be nice if the system would report the state of the USB port - in your case the current should be negotiated with the host during enumeration ( in theory - though I think lot of USB hosts will just let you pull half an amp regardless).
I just wanted to mention here that we’re talking about this internally to see how we could more easily expose this information to user space. It’s a great feature idea, and our firmware team has good ideas about how to bring this to life.
Thats great to hear. A simple ‘attached’ flag would be a good start, but if you can make other info available, such as connection speed and available current that would be even better.