Finish USBDevice.detach() placeholder. #397
Open
+7
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Only have Arduino Micro board to test on.
The ide fails to make the attempt to upload a sketch if the COM port is unavailable after detaching the USB serial CDC endpoint.
The RunnerException error in SerialUploader.java:152 should be caught and handled when attempting to upload to a nonexistent COM port. A console output should be given instructing the user to press the reset button, power cycle, or plug the board into a USB port so that the bootloader can upload a sketch from the IDE. This would allow a developer to upload sketches even when the sketch disables USB, or takes full control of the keyboard or mouse preventing the user from using their computer.
For example; if USBDevice.detach() is called in setup() a user would need to instruct avrdude on the command line and then get the device into the bootloader to upload a sketch. In practice the CDC endpoint resets the device and the IDE waits for the bootloader to upload the code. The bootloader can be physically triggered and a sketch uploaded if the IDE ignores the error when attempting to open the serial port and send the reset signal.