newbie: how to send data to PC without polling

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
ChaseTheSun
Posts: 2
Joined: Sat Feb 26, 2011 4:00 am

newbie: how to send data to PC without polling

Post by ChaseTheSun » Sun Mar 06, 2011 4:41 pm

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

Jaewoo Kim

Re: newbie: how to send data to PC without polling

Post by Jaewoo Kim » Tue Mar 08, 2011 6:23 pm

why don't you write polling routine waiting USB receive-in in DLL,then sent event signal to your app ?

Bob
Posts: 17
Joined: Sun Jun 10, 2007 7:10 pm
Location: Melbourne

Re: newbie: how to send data to PC without polling

Post by Bob » Tue Mar 08, 2011 7:30 pm

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.

ChaseTheSun
Posts: 2
Joined: Sat Feb 26, 2011 4:00 am

Re: newbie: how to send data to PC without polling

Post by ChaseTheSun » Thu Mar 10, 2011 6:21 pm

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?

Bob
Posts: 17
Joined: Sun Jun 10, 2007 7:10 pm
Location: Melbourne

Re: newbie: how to send data to PC without polling

Post by Bob » Sat Mar 19, 2011 6:03 pm

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 );
}

Post Reply