Is it possible to detect whether the PC is running?
Is it possible to detect whether the PC is running?
Hi everybody,
as written above I'd like to know whether it's possible to detect whether the PC, to which V-USB is connected, is running or turned off? In my application USB voltage is supplied all the time but the PC is not running all the time and I'd like to detect when it's running and when it isn't. A software solution for V-USB would be preferred.
Best regards,
Michael
as written above I'd like to know whether it's possible to detect whether the PC, to which V-USB is connected, is running or turned off? In my application USB voltage is supplied all the time but the PC is not running all the time and I'd like to detect when it's running and when it isn't. A software solution for V-USB would be preferred.
Best regards,
Michael
Re: Is it possible to detect whether the PC is running?
Well if the voltage is applied just look at the usb (-) pin. If its constant then no data is present.
just use a function i.e. checkAlive
while (!usbInterruptIsReady()){ checkAlive(); usbPoll(); }
just use a function i.e. checkAlive
while (!usbInterruptIsReady()){ checkAlive(); usbPoll(); }
Re: Is it possible to detect whether the PC is running?
How long must I monitor USB- to be sure that there's no communication? Is there any time constant?
Re: Is it possible to detect whether the PC is running?
Well I have found its ok to use a loop count of 5 but be sure to kill the interrupts. Since the pin (-) of the usb has a pullup it should normally be hi. I found xp can take a max loop of 20, but vista needs 5 or less.
A more elegant way could be to use a pin Change interrupt.
Code: Select all
checkAlive()
{
cli();
DDRD &= ~0x02;
for( ; i < 5 ; i++)
{
//make your test...
}
DDRD |= 0x02;
sei();
}
A more elegant way could be to use a pin Change interrupt.
Re: Is it possible to detect whether the PC is running?
Do you know what happens when the PC is booting (especially XP)? Is there periodic communication? If not one would detect that the PC is turned off although it is booting at that time.
Re: Is it possible to detect whether the PC is running?
I dont think much goes on during boot. possible some driver talk as the usb device initialize but then the talk with silence I would guess.
Re: Is it possible to detect whether the PC is running?
I think "USB_RX_USER_HOOK" is what you are looking for. Once the device has been found by the PC the PC will keep communicating with it, so if you put a timeout after the USB_RX_USER_HOOK you can detect if the PC is running and knows the device is there.
Re: Is it possible to detect whether the PC is running?
Daid wrote:I think "USB_RX_USER_HOOK" is what you are looking for. Once the device has been found by the PC the PC will keep communicating with it, so if you put a timeout after the USB_RX_USER_HOOK you can detect if the PC is running and knows the device is there.
I am also looking to detect if the PC is running or not.
As I was testing the hook with USB_RX_USER_HOOK it only change the status when data transfer is done between my application and the device.
But it doesn't work if no data transfer is happening.