From 7874386ce23a7b7383f587e6bf6ae665756024ba Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 14 Jul 2016 18:43:43 +0200 Subject: Send an USB remote wakeup if data need to be written On Linux, setting autosuspend_delay_ms to N and control to auto allows the host pc to suspend the peripheral. Some Linux distro (Ubuntu, Mint) apply this behaviour by default. If the sketch's prints where less frequent than N milliseconds the sketch prints would never arrive. This patch allows sending a remote wakeup event to unsuspend the peripheral and allow the serial prints to be received. --- cores/arduino/USBCore.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cores/arduino') diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 6c8ae63..ddc4812 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -1,6 +1,7 @@ -/* Copyright (c) 2010, Peter Barrett +/* Copyright (c) 2010, Peter Barrett +** Sleep/Wakeup support added by Michael Dreher ** ** Permission to use, copy, modify, and/or distribute this software for ** any purpose with or without fee is hereby granted, provided that the @@ -266,6 +267,11 @@ int USB_Send(u8 ep, const void* d, int len) if (!_usbConfiguration) return -1; + if (_usbSuspendState & (1<