Skip to content

Commit

Permalink
main: wait a few seconds before shutting down interfaces
Browse files Browse the repository at this point in the history
The USB gadget may hang if we do not wait a few seconds between the
power cut and the removal of the USB function (possibly because some
power remains on the USB line for a few seconds).

Signed-off-by: Cedric Hombourger <[email protected]>
  • Loading branch information
chombourger committed Mar 5, 2022
1 parent 1db735e commit 7eb9d10
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mtda/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,15 +917,23 @@ def _target_off(self, session=None):
self.exec_power_off_script()

result = True

# cut power and wait a few seconds before shutting down
# our interfaces (keyboard, console, USB gadget, etc.)
if self.power_controller is not None:
result = self.power_controller.off()
time.sleep(3)

# shutdown our gadgets
if self.keyboard is not None:
self.keyboard.idle()
if self.console_logger is not None:
self.console_logger.reset_timer()
if result is True:
self.console_logger.pause()
self._composite_stop()

# send power-off event to clients
self._power_event(CONSTS.POWER.OFF)

self.mtda.debug(3, "main._target_off(): {}".format(result))
Expand Down

0 comments on commit 7eb9d10

Please sign in to comment.