/******************************************************************************** * TvCtrlPointSendActionNumericArg * * Description:Send an action with one argument to a device in the global device list. * * Parameters: * devnum -- The number of the device (order in the list, starting with 1) * service -- TV_SERVICE_CONTROL or TV_SERVICE_PICTURE * actionName -- The device action, i.e., "SetChannel" * paramName -- The name of the parameter that is being passed * paramValue -- Actual value of the parameter being passed * ********************************************************************************/ int TvCtrlPointSendActionNumericArg(int devnum, int service, const char *actionName, const char *paramName, int paramValue) { char param_val_a[50]; char *param_val = param_val_a; sprintf(param_val_a, "%d", paramValue); return TvCtrlPointSendAction( service, devnum, actionName, ¶mName, ¶m_val, 1); }
int TvCtrlPointProcessCommand( char *cmdline ) { char cmd[100]; char strarg[100]; int arg_val_err = -99999; int arg1 = arg_val_err; int arg2 = arg_val_err; int cmdnum = -1; int numofcmds = sizeof( cmdloop_cmdlist ) / sizeof( cmdloop_commands ); int cmdfound = 0; int i, rc; int invalidargs = 0; int validargs; validargs = sscanf( cmdline, "%s %d %d", cmd, &arg1, &arg2 ); for( i = 0; i < numofcmds; i++ ) { if( strcasecmp( cmd, cmdloop_cmdlist[i].str ) == 0 ) { cmdnum = cmdloop_cmdlist[i].cmdnum; cmdfound++; if( validargs != cmdloop_cmdlist[i].numargs ) invalidargs++; break; } } if( !cmdfound ) { SampleUtil_Print( "Command not found; try 'Help'" ); return TV_SUCCESS; } if( invalidargs ) { SampleUtil_Print( "Invalid arguments; try 'Help'" ); return TV_SUCCESS; } switch ( cmdnum ) { case PRTHELP: TvCtrlPointPrintShortHelp( ); break; case PRTFULLHELP: TvCtrlPointPrintLongHelp( ); break; case POWON: TvCtrlPointSendPowerOn( arg1 ); break; case POWOFF: TvCtrlPointSendPowerOff( arg1 ); break; case SETCHAN: TvCtrlPointSendSetChannel( arg1, arg2 ); break; case SETVOL: TvCtrlPointSendSetVolume( arg1, arg2 ); break; case SETCOL: TvCtrlPointSendSetColor( arg1, arg2 ); break; case SETTINT: TvCtrlPointSendSetTint( arg1, arg2 ); break; case SETCONT: TvCtrlPointSendSetContrast( arg1, arg2 ); break; case SETBRT: TvCtrlPointSendSetBrightness( arg1, arg2 ); break; case CTRLACTION: /* re-parse commandline since second arg is string */ validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg ); if( 3 == validargs ) TvCtrlPointSendAction( TV_SERVICE_CONTROL, arg1, strarg, NULL, NULL, 0 ); else invalidargs++; break; case PICTACTION: /* re-parse commandline since second arg is string */ validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg ); if( 3 == validargs ) TvCtrlPointSendAction( TV_SERVICE_PICTURE, arg1, strarg, NULL, NULL, 0 ); else invalidargs++; break; case CTRLGETVAR: /* re-parse commandline since second arg is string */ validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg ); if( 3 == validargs ) TvCtrlPointGetVar( TV_SERVICE_CONTROL, arg1, strarg ); else invalidargs++; break; case PICTGETVAR: /* re-parse commandline since second arg is string */ validargs = sscanf( cmdline, "%s %d %s", cmd, &arg1, strarg ); if( 3 == validargs ) TvCtrlPointGetVar( TV_SERVICE_PICTURE, arg1, strarg ); else invalidargs++; break; case PRTDEV: TvCtrlPointPrintDevice( arg1 ); break; case LSTDEV: TvCtrlPointPrintList( ); break; case REFRESH: TvCtrlPointRefresh( ); break; case EXITCMD: rc = TvCtrlPointStop( ); exit( rc ); break; default: SampleUtil_Print( "Command not implemented; see 'Help'" ); break; } if( invalidargs ) SampleUtil_Print( "Invalid args in command; see 'Help'" ); return TV_SUCCESS; }
int TvCtrlPointSendPowerOff(int devnum) { return TvCtrlPointSendAction( TV_SERVICE_CONTROL, devnum, "PowerOff", NULL, NULL, 0); }