Go Down

Topic: Virtual USB Keyboard stuck waiting for host (Read 1 time) previous topic - next topic

sa10

Hi all,

I have combined an IR-receiver (e.g. http://www.gumbolabs.org/2010/05/29/radioshack-infrared-receiver-arduino/) with the virtual USB keyboard (http://www.practicalarduino.com/projects/virtual-usb-keyboard). This allows me to turn on/off and control my htpc using the tv remote.

However, when I press a button while the pc is off, the arduino gets stuck in a while loop waiting for the USB host. Specifically, in UsbKeyboard.h:
Code: [Select]
while (!usbInterruptIsReady()) {
      // Note: We wait until we can send keystroke
      //       so we know the previous keystroke was
      //       sent.
    }


I tried to make this loop quit after a certain amount of time, but I can't call micros() from that part of the program. (I'm guessing this has to do with interrupts, but I don't really know much about that.) For now I have fixed the problem by inserting a counter and having the loop quit after 100 000 repetitions, but that's not really a clean solution. Isn't there a better way to go about doing this?

BTW, is development of Virtual Usb Keyboard still active? There are a few easy improvements to the library, like adding more keys. Especially the arrow keys should be there.

regards,
sa10

Go Up