WildernessLabs / Meadow_Issues

Public repo for bugs and issues with Meadow
15 stars 0 forks source link

COM Port Not Available After Sleep #406

Open thegreatco opened 11 months ago

thegreatco commented 11 months ago
Describe the bug After calling Device.PlatformOS.Sleep, when the device wakes, Windows reports Event Type Event Time Device Name Description Device Type Drive Letter Serial Number Vendor ID Product ID Vendor Name Product Name Firmware Revision USB Class USB SubClass USB Protocol
Plug 12/8/2023 8:49:04 AM Port#0004.Hub#0013 USB Serial Device Communication COM23 2058317E5230 2e6a 0001 1.01 02 02 01
Unplug 12/8/2023 8:52:06 AM Port#0004.Hub#0013 USB Serial Device Communication COM23 2058317E5230 2e6a 0001 1.01 02 02 01
Plug 12/8/2023 8:52:26 AM Port#0004.Hub#0013 Unknown USB Device (Device Descriptor Request Failed) Unknown 0000 0002 0.00 00 00 00

To Reproduce Steps to reproduce the behavior:

  1. Connect a Meadow
  2. Deploy an application that calls Device.PlatformOS.Sleep()
  3. Wait for the device to sleep
  4. Note the device disconnects from Windows
  5. Wait for the device to wake
  6. Note the device connects but Windows is unable to recognize the device

Expected behavior The Meadow reconnects and presents a COM port

Screenshots If applicable, add screenshots to help explain your problem.

Developer tools (please complete the following information as best as you can):

Meadow (please complete the following information as best as you can): Most of these vaues can be found by running meadow device info using the Meadow CLI.

alexischr commented 11 months ago

@Peter-Moody sounds like we either have to send a disconnect signal, a re-connect signal, or both? @alexischr I added new message type sent to CLI before entering low-power. But, sending a re-connect signal would do no good unless CLI is connected and this is the problem we're trying to solved.

Peter-Moody commented 11 months ago

I added a new message type HCOM_HOST_REQUEST_TEXT_NEXT_LOW_PWR = 0x14 | HCOM_PROTOCOL_HEADER_SIMPLE_TEXT_TYPE which HCOM now sends to CLI before entering low-power mode. Also added Dominique as an assignee

Peter-Moody commented 11 months ago

Slack message from @ctacke

sleep/wake for interrupt is only sort-of working. I can go to sleep. When I get the wake interrupt I know something is happening because Windows makes noise about USB getting connected, but the code immediately following the ioctl is failing to execute (I'm trying to turn on an LED) (edited)

If I use the same app to wake after a period of time (5s) then it works.

Not sure if it matters, but when it wakes from a timer, the USB re-enumerates as a serial port. When it re-enumerates from interrupt, it comes up as an unknown device

alexischr commented 1 month ago

@Peter-Moody do you think this is still an issue?

alexischr commented 1 month ago

I am going to investigate this one a little, since a lot of work has been done improving sleep/wake

Peter-Moody commented 1 month ago

Alexis, good idea to verify. From the original problem description, it sounds like a CLI problem, if Windows is showing the COM Port again after sleeping. Also, we don't know if this is from CLIv1 or CLIv2.