Page 1 of 1
newbie: how to send data to PC without polling
Posted: Sun Mar 06, 2011 4:41 pm
by ChaseTheSun
Simple idea, i have a temperature probe connected to an attiny45 running v-usb:
if the temperature goes above or below predefined limits, I would like a msgbox to popup on my desktop.
i sortof got it working with the hid-data example, but the host .exe polls the attiny every 60sec.. Is there another way without polling?
thanks in advance, im totally lost :S
Re: newbie: how to send data to PC without polling
Posted: Tue Mar 08, 2011 6:23 pm
by Jaewoo Kim
why don't you write polling routine waiting USB receive-in in DLL,then sent event signal to your app ?
Re: newbie: how to send data to PC without polling
Posted: Tue Mar 08, 2011 7:30 pm
by Bob
Perhaps, make the AVR device a keyboard and generate a special button combination (hotkey) at your desired temperature, this can be used to generate an interrupt then the PC side software can read the temperature from the AVR using feature reports then make your popup. This avoids polling, although internally, polling is really going on at a system level.
Re: newbie: how to send data to PC without polling
Posted: Thu Mar 10, 2011 6:21 pm
by ChaseTheSun
Bob wrote:Perhaps, make the AVR device a keyboard and generate a special button combination (hotkey) at your desired temperature, this can be used to generate an interrupt then the PC side software can read the temperature from the AVR using feature reports then make your popup. This avoids polling, although internally, polling is really going on at a system level.
beautiful, i like this idea. have you done anything of the like before? so if i have got this right: I would implement a keyboard, then my firmware would check the temperature every minute or however how long.. then if the temperature matches certain parameters, send a special key. How would i be able to catch that key on the PC side though?
Re: newbie: how to send data to PC without polling
Posted: Sat Mar 19, 2011 6:03 pm
by Bob
Yes I have done this before with a bar code reader I was playing with, once the bar code was decoded, I simulated a key press then the PC side software would gather feature reports from the AVR.
To catch the key on the PC side software depends on what programming language and OS you are using.
In windows and C++, here's a simple example of catching the key in the MsgProc:
Code: Select all
#define KEYCODE_TRIGGER 0xhh // where hh is the 8 bit hex code for the key you wish to use, search web for VK codes (Virtual Keys)
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_KEYDOWN:
if (wParam == KEYCODE_TRIGGER)
{
CallYourPopupDisplayFunction();
}
break;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}