MBEG #else int main( int argc, char* argv[] ) #endif { int cacheControl = -1; if ( argc == 1 ) { printf( "usage: clock [cache_control_in_sec]\n" ); cacheControl = 1800; } else if ( argc > 2 ) { printf( "usage: clock [cache_control_in_sec]\n" ); exit( 0 ); } else if (sscanf(argv[1], "%i", &cacheControl) != 1) { printf( "Invalid CACHE-CONTROL value.\n" ); exit( 0 ); } printf( "Using CACHE-CONTROL value: %d sec\n", cacheControl ); if (!InitApp( cacheControl )) { fprintf(stderr, "Couldn't create this clock device !!\n"); exit(0); } #if !defined(TENGINE) kbinit(); #endif int ch = 0; do { #if !defined(TENGINE) if (0 < kbhit()) { ch = getchar(); ch = toupper( ch ); } else mupnp_wait(1000); #else mupnp_wait(1000); #endif upnp_clock_device_update(clockDev); } while( ch != 'Q'); #if !defined(TENGINE) kbexit(); #endif ExitApp(); return(0); }
int kbhit() { if(!initialized) { kbinit(); } int bytesWaiting; ioctl(fileno(stdin), FIONREAD, &bytesWaiting); return bytesWaiting; }
void main (void) { uint8 wave = 0; WDTCN = 0xde; /* disable watchdog timer */ WDTCN = 0xad; SFRPAGE = CONFIG_PAGE; /* set up Crossbar and GPIO */ XBR2 = 0x40; /* Enable crossbar and weak pull-ups */ /* need to enable Port 1 pins for output */ XBR0 = 0x03; /* Enable SPI and SMBus on crossbar */ OSCICN = 0xc2; SFRPAGE = 0; /* Put SPI into three-wire mode */ SPI0CFG = 0x40; NSSMD1 = NSSMD0 = 0; kbinit (); dacinit (); EA = 1; /* Enable all interrupts */ dacplay(240*2, sinewave[wave]); while (1) { PCON |= 1; if ( ! dacbusy() ) { dacplay(240*2, sinewave[wave]); } switch ( kbcheck() ) { case '1', '!': wave = 0; break; case '2', '@': wave = 1; break; case 't', 'T': wave = 1 - wave; break; default: break; } } }
MBEG #else int main( int argc, char* argv[] ) #endif { mUpnpControlPoint *ctrlPoint; int key; ctrlPoint = mupnp_controlpoint_new(); mupnp_controlpoint_setssdplistener(ctrlPoint, SSDPNotifyListner); mupnp_controlpoint_seteventlistener(ctrlPoint, EventListener); if (mupnp_controlpoint_start(ctrlPoint) == false) { printf("Couldn't start this control point !!"); exit(1); } PrintKeyMessage(); #if (!defined(WIN32) || defined(__CYGWIN__)) && !defined(TENGINE) kbinit(); #endif key = 0; do { #if !defined(TENGINE) key = kbgetkey(); key = toupper(key); switch (key) { case 'P': PrintControlPointDevice(ctrlPoint); break; #if !defined(MUPNP_NOUSE_ACTIONCTRL) case 'C': ControlDeviceAlter(ctrlPoint, CMD_NO_ALTERATIONS); break; case 'O': ControlDeviceAlter(ctrlPoint, CMD_LOOP_ACTION_CALLS); break; #endif #if !defined(MUPNP_NOUSE_QUERYCTRL) case 'Q': QueryDevice(ctrlPoint); break; #endif #if !defined(MUPNP_NOUSE_SUBSCRIPTION) case 'S': SubscribeService(ctrlPoint); break; case 'U': UnsubscribeService(ctrlPoint); break; #endif case 'M': SetMXValue(ctrlPoint); break; case 'R': printf("M-Search upnp::rootdevice\n"); mupnp_controlpoint_search(ctrlPoint, MUPNP_ST_ROOT_DEVICE); break; case 'H': printf("M-Search ssdp:all\n"); mupnp_controlpoint_search(ctrlPoint, "ssdp:all"); break; case 'V': printf("M-Search device type\n"); mupnp_controlpoint_search(ctrlPoint, "urn:schemas-upnp-org:device:clock:1"); break; case 'T': printf("M-Search service type\n"); mupnp_controlpoint_search(ctrlPoint, "urn:schemas-upnp-org:service:timer:1"); break; case 'A': { int i; printf("Doing all searches four times...\n"); for (i=0; i<4; i++) { mupnp_controlpoint_search(ctrlPoint, MUPNP_ST_ROOT_DEVICE); mupnp_controlpoint_search(ctrlPoint, "ssdp:all"); mupnp_controlpoint_search(ctrlPoint, "urn:schemas-upnp-org:device:clock:1"); mupnp_controlpoint_search(ctrlPoint, "urn:schemas-upnp-org:service:timer:1"); } printf("Done (doing all searches four times).\n"); } break; case 'X': break; default: PrintKeyMessage(); } #else mupnp_wait(1000); #endif } while( key != 'X'); #if (!defined(WIN32) || defined(__CYGWIN__)) && !defined(TENGINE) kbexit(); #endif mupnp_controlpoint_stop(ctrlPoint); mupnp_controlpoint_delete(ctrlPoint); return(0); }