Exemplo n.º 1
0
void update_inverter_status()
{
  if((buf[INV_STATUS]) == '0')
    dstate_setinfo("inverter.status", "%s","OFF");
  else
    dstate_setinfo("inverter.status", "%s","ON");
}
Exemplo n.º 2
0
/* Set up all the funky shared memory stuff used to communicate with upsd */
void  upsdrv_initinfo (void)
{
	/* now set up room for all future variables that are supported */

	dstate_setinfo("ups.mfr", "%s", "Best Power");
	switch(fc.model) {
          case ME3100:
	    dstate_setinfo("ups.model", "Micro Ferrups (ME) %d", fc.va);
	    break;
          case MD1KVA:
	    dstate_setinfo("ups.model", "Micro Ferrups (MD) %d", fc.va);
	    break;
          case RE1800:
            dstate_setinfo("ups.model", "Micro Ferrups (RE) %d", fc.va);
            break;
          default:
	    fatalx(EXIT_FAILURE, "UPS model not matched!"); /* Will never get here, upsdrv_initups() will catch */
        } 
	fprintf(stderr, "Best Power %s detected\n", 
		dstate_getinfo("ups.model"));
	fprintf(stderr, "Battery voltages %5.1f nominal, %5.1f full, %5.1f empty\n", 
	 fc.idealbvolts,
	 fc.fullvolts,
	 fc.emptyvolts);
}
Exemplo n.º 3
0
/* write the status_buf into the externally visible dstate storage */
void status_commit(void)
{
	while (ignorelb) {
		const char	*val, *low;

		val = dstate_getinfo("battery.charge");
		low = dstate_getinfo("battery.charge.low");

		if (val && low && (strtol(val, NULL, 10) < strtol(low, NULL, 10))) {
			snprintfcat(status_buf, sizeof(status_buf), " LB");
			upsdebugx(2, "%s: appending LB flag [charge '%s' below '%s']", __func__, val, low);
			break;
		}

		val = dstate_getinfo("battery.runtime");
		low = dstate_getinfo("battery.runtime.low");

		if (val && low && (strtol(val, NULL, 10) < strtol(low, NULL, 10))) {
			snprintfcat(status_buf, sizeof(status_buf), " LB");
			upsdebugx(2, "%s: appending LB flag [runtime '%s' below '%s']", __func__, val, low);
			break;
		}

		/* LB condition not detected */
		break;
	}

	if (alarm_active) {
		dstate_setinfo("ups.status", "ALARM %s", status_buf);
	} else {
		dstate_setinfo("ups.status", "%s", status_buf);
	}
}
Exemplo n.º 4
0
void sec_setinfo(int varnum, char *value)
{	

	if (*sec_varlist[varnum].setcmd){/*Not empty*/
		
		if (sec_varlist[varnum].flags == FLAG_STRING) {
			dstate_setinfo(sec_varlist[varnum].setcmd,"%s", value);
	 	}
		else if (sec_varlist[varnum].unit == 1) {
			dstate_setinfo(sec_varlist[varnum].setcmd,"%s", value);
		}
		
		else if (sec_varlist[varnum].flags == FLAG_MULTI) {
			if (atoi(value) < 0) { 
			dstate_setinfo(sec_varlist[varnum].setcmd,"0");
			}
			else
			{dstate_setinfo(sec_varlist[varnum].setcmd,"%d", atoi(value) * sec_varlist[varnum].unit);
			}
			}
		else { 
			dstate_setinfo(sec_varlist[varnum].setcmd,"%.1f", atof(value) / sec_varlist[varnum].unit);}
			
		}
		
}
Exemplo n.º 5
0
void update_charge_source_status()
{
      if( (buf[CHARGE_SOURCE]) == '0'){
	dstate_setinfo("charge.solar", "%s","OFF");   //charge on mains
      }
      else
	dstate_setinfo("charge.solar", "%s","ON");    //charge on solar
}
Exemplo n.º 6
0
void upsdrv_initinfo(void)
{
	
	dstate_setinfo("ups.mfr", "%s", "PACE");
	dstate_setinfo("ups.model", "PACE  %s", "UPS7");
	printf("Detected %s %s on %s\n", dstate_getinfo("ups.mfr"), 
	dstate_getinfo("ups.model"), device_path);
	
}
Exemplo n.º 7
0
void upsdrv_initinfo(void)
{
	dstate_setinfo("ups.mfr", "%s", "Richcomm dry-contact to USB solution");
	dstate_setinfo("ups.model", "%s", usbdevice.Product ? usbdevice.Product : "unknown");
	dstate_setinfo("ups.serial", "%s", usbdevice.Serial ? usbdevice.Serial : "unknown");

	dstate_setinfo("ups.vendorid", "%04x", usbdevice.VendorID);
	dstate_setinfo("ups.productid", "%04x", usbdevice.ProductID);
}
Exemplo n.º 8
0
void upsdrv_initinfo(void)
{
	/* try to detect the UPS here - call fatal_with_errno(EXIT_FAILURE, ) if it fails */

	char device_name[80] = "";
	CFStringRef device_type_cfstr, device_name_cfstr;
	CFPropertyListRef power_dictionary;
	CFNumberRef max_capacity;

	upsdebugx(1, "upsdrv_initinfo()");

	dstate_setinfo("device.mfr", "(unknown)");

	power_dictionary = copy_power_dictionary(g_power_key);

	device_type_cfstr = CFDictionaryGetValue(power_dictionary, CFSTR(kIOPSTypeKey));
	if(device_type_cfstr && !CFStringCompare(device_type_cfstr, CFSTR(kIOPSInternalBatteryType), 0)) {
		dstate_setinfo("device.type", "battery");
	}

	upsdebugx(2, "Getting 'Name' key");

	device_name_cfstr = CFDictionaryGetValue(power_dictionary, CFSTR(kIOPSNameKey));

	if (!device_name_cfstr) {
		fatalx(EXIT_FAILURE, "Couldn't retrieve 'Name' key from power dictionary.");
	}

	CFRetain(device_name_cfstr);

	CFStringGetCString(device_name_cfstr, device_name, sizeof(device_name), kCFStringEncodingUTF8);
	upsdebugx(2, "Got name: %s", device_name);

	CFRelease(device_name_cfstr);

	dstate_setinfo("device.model", "%s", device_name);

	max_capacity = CFDictionaryGetValue(power_dictionary, CFSTR(kIOPSMaxCapacityKey));
	if(max_capacity) {
		CFRetain(max_capacity);

		CFNumberGetValue(max_capacity, kCFNumberDoubleType, &max_capacity_value);
		CFRelease(max_capacity);

		upsdebugx(3, "Max Capacity = %.f units (usually 100)", max_capacity_value);
		if(max_capacity_value != 100) {
			upsdebugx(1, "Max Capacity: %f != 100", max_capacity_value);
		}
	}

	/* upsh.instcmd = instcmd; */
	CFRelease(power_dictionary);
}
Exemplo n.º 9
0
void upsdrv_updateinfo(void)
{
    static int	retry = 0;

    if (blazer_status(command[proto].status)) {

        if (retry < MAXTRIES) {
            upsdebugx(1, "Communications with UPS lost: status read failed!");
            retry++;
        } else if (retry == MAXTRIES) {
            upslogx(LOG_WARNING, "Communications with UPS lost: status read failed!");
            retry++;
        } else {
            dstate_datastale();
        }

        return;
    }

    if (getval("runtimecal")) {
        time_t	now;

        time(&now);

        if (online) {	/* OL */
            batt.runt.est += batt.runt.nom * difftime(now, lastpoll) / batt.chrg.time;
            if (batt.runt.est > batt.runt.nom) {
                batt.runt.est = batt.runt.nom;
            }
        } else {	/* OB */
            batt.runt.est -= load.eff * difftime(now, lastpoll);
            if (batt.runt.est < 0) {
                batt.runt.est = 0;
            }
        }

        dstate_setinfo("battery.charge", "%.0f", 100 * batt.runt.est / batt.runt.nom);
        dstate_setinfo("battery.runtime", "%.0f", batt.runt.est / load.eff);

        lastpoll = now;
    }

    if (retry > MAXTRIES) {
        upslogx(LOG_NOTICE, "Communications with UPS re-established");
    }

    retry = 0;

    dstate_dataok();
}
Exemplo n.º 10
0
Arquivo: ivtscd.c Projeto: sbutler/nut
void upsdrv_initinfo(void)
{
	if (ivt_status() < 7) {
		fatal_with_errno(EXIT_FAILURE, "IVT Solar Controller not detected");
	}

	/* set the device general information */
	dstate_setinfo("device.mfr", "IVT");
	dstate_setinfo("device.model", "Solar Controller Device");
	dstate_setinfo("device.type", "scd");

	dstate_addcmd("reset.input.minmax");

	upsh.instcmd = instcmd;
}
Exemplo n.º 11
0
/* initialize information */
void upsdrv_initinfo(void)
{
	/* write constant data for this model */
	dstate_setinfo ("ups.mfr", "%s", manufacturer);
	dstate_setinfo ("ups.model", "%s", modelname);
	dstate_setinfo ("ups.serial", "%s", serialnumber);
	dstate_setinfo ("ups.model.type", "%s", types[type].name);
	dstate_setinfo ("input.voltage.nominal", "%u", linevoltage);

	/* now add the instant commands */
    dstate_addcmd ("test.battery.start");
   	dstate_addcmd ("shutdown.return");
   	dstate_addcmd ("shutdown.stayoff");
	upsh.instcmd = instcmd;
}
Exemplo n.º 12
0
void upsdrv_initinfo(void)
{
	char	*page, *last = NULL;
	char	buf[SMALLBUF];
	
	snprintf(buf, sizeof(buf), "%s", subdriver->initinfo);

	for (page = strtok_r(buf, " ", &last); page != NULL; page = strtok_r(NULL, " ", &last)) {

		if (netxml_get_page(page) != NE_OK) {
			continue;
		}

		dstate_setinfo("driver.version.data", "%s", subdriver->version);

		if (testvar("subscribe") && (netxml_alarm_subscribe(subdriver->subscribe) == NE_OK)) {
			extrafd = ne_sock_fd(sock);
			time(&lastheard);
		}

		/* Register r/w variables */
		vname_register_rw();

		/* Set UPS driver handler callbacks */
		upsh.setvar  = &setvar;
		upsh.instcmd = &instcmd;

		return;
	}

	fatalx(EXIT_FAILURE, "%s: communication failure [%s]", __func__, ne_get_error(session));
}
Exemplo n.º 13
0
void update_err_status()
{
      int i;
      int x;
      char data[2];
      for(i=0;i<ERR_LEN;i++)
      {
	 data[i] = buf[ERR_STATUS+i];
      }
      data[i] = '\0';
      x = atoi(data);
      if(x==0)
	dstate_setinfo("error.status", "%d",0);        //No error
      else
	dstate_setinfo("error.status", "%d",x);        //update error code
}
Exemplo n.º 14
0
static int upsc_getvalue(const char *cmd, const char *param,
			const char *resp, const char *nutvar, char *ret)
{
	char var[UPSC_BUFLEN];
	char val[UPSC_BUFLEN];

	upsdebugx(2, "Request value: %s %s", cmd, param ? param : "\"\"");
	upscsend(cmd);
	if (param)
		upscsend(param);
	upscrecv(var);
	upscrecv(val);
	upsdebugx(2, "Got value: %s %s", var, val);
	if (strcmp(var, resp)) {
		upslogx(LOG_ERR, "Bad response to %s %s: %s %s",
			cmd, param ? param : "\"\"", var, val);
		return 0;
	}
	else {
		if (nutvar)
			dstate_setinfo(nutvar, "%s", val);
		if (ret)
			strcpy(ret, val);
	}
	return 1;
}
Exemplo n.º 15
0
/* Convert the local status information to NUT format and set NUT
   status. */
static void netxml_status_set(void)
{
	if (STATUS_BIT(VRANGE)) {
		dstate_setinfo("input.transfer.reason", "input voltage out of range");
	} else if (STATUS_BIT(FRANGE)) {
		dstate_setinfo("input.transfer.reason", "input frequency out of range");
	} else {
		dstate_delinfo("input.transfer.reason");
	}

	if (STATUS_BIT(ONLINE)) {
		status_set("OL");		/* on line */
	} else {
		status_set("OB");		/* on battery */
	}
	if (STATUS_BIT(DISCHRG)) {
		status_set("DISCHRG");		/* discharging */
	}
	if (STATUS_BIT(CHRG)) {
		status_set("CHRG");		/* charging */
	}
	if (STATUS_BIT(LOWBATT)) {
		status_set("LB");		/* low battery */
	}
	if (STATUS_BIT(OVERLOAD)) {
		status_set("OVER");		/* overload */
	}
	if (STATUS_BIT(REPLACEBATT)) {
		status_set("RB");		/* replace batt */
	}
	if (STATUS_BIT(TRIM)) {
		status_set("TRIM");		/* SmartTrim */
	}
	if (STATUS_BIT(BOOST)) {
		status_set("BOOST");		/* SmartBoost */
	}
	if (STATUS_BIT(BYPASSAUTO) || STATUS_BIT(BYPASSMAN)) {
		status_set("BYPASS");		/* on bypass */
	}
	if (STATUS_BIT(OFF)) {
		status_set("OFF");		/* ups is off */
	}

	if (STATUS_BIT(SHUTDOWNIMM)) {
		status_set("FSD");		/* shutdown imminent */
	}
}
Exemplo n.º 16
0
Arquivo: clone.c Projeto: AlexLov/nut
static int setvar(const char *varname, const char *val)
{
	if (!strcasecmp(varname, "battery.charge.low")) {
		battery.charge.low = strtod(val, NULL);
		dstate_setinfo("battery.charge.low", "%g", battery.charge.low);
		return STAT_SET_HANDLED;
	}

	if (!strcasecmp(varname, "battery.runtime.low")) {
		battery.runtime.low = strtod(val, NULL);
		dstate_setinfo("battery.runtime.low", "%g", battery.runtime.low);
		return STAT_SET_HANDLED;
	}

	upslogx(LOG_NOTICE, "setvar: unknown variable [%s]", varname);
	return STAT_SET_UNKNOWN;
}
Exemplo n.º 17
0
Arquivo: ivtscd.c Projeto: sbutler/nut
void upsdrv_updateinfo(void)
{
	if (ivt_status() < 7) {
		dstate_datastale();
		return;
	}

	dstate_setinfo("battery.voltage", "%.2f", battery.voltage.act);
	dstate_setinfo("battery.voltage.minimum", "%.2f", battery.voltage.min);
	dstate_setinfo("battery.voltage.maximum", "%.2f", battery.voltage.max);

	dstate_setinfo("battery.current", "%.1f", battery.current.act);
	dstate_setinfo("battery.current.minimum", "%.1f", battery.current.min);
	dstate_setinfo("battery.current.maximum", "%.1f", battery.current.max);

	dstate_setinfo("battery.temperature", "%.0f", battery.temperature);

	status_init();

	if (battery.current.act > 0) {
		status_set("OL");		/* charging */
	} else {
		status_set("OB");		/* discharging */
	}

	if (battery.voltage.act < battery.voltage.low) {
		status_set("LB");
	}

	status_commit();

	dstate_dataok();
}
Exemplo n.º 18
0
void upsdrv_initinfo(void)
{
	char	*tmp;

	tmp = getval("mfr");

	if (!tmp)
		dstate_setinfo("ups.mfr", "Liebert");
	else
		dstate_setinfo("ups.mfr", "%s", tmp);

	tmp = getval("model");

	if (!tmp)
		dstate_setinfo("ups.model", "MultiLink");
	else
		dstate_setinfo("ups.model", "%s", tmp);
}
Exemplo n.º 19
0
static int get_identification(void) {
	char response[MAX_RESPONSE_LENGTH];

	if (do_command(POLL, IDENTIFICATION, "", response) >= 0) {
		dstate_setinfo("ups.id", "%s", response);
		return 1;
	}

	return 0;
}
Exemplo n.º 20
0
int upsdrv_initups(void)
{
	/* check the running mode... */
	if (strchr(device_path, '@'))
	{
		upsdebugx(1, "Repeater mode");
		mode = MODE_REPEATER;
		dstate_setinfo("driver.parameter.mode", "repeater");
		/* FIXME: if there is at least one more => MODE_META... */
	}
	else
	{
		upsdebugx(1, "Dummy (simulation) mode");
		mode = MODE_DUMMY;
		dstate_setinfo("driver.parameter.mode", "dummy");
	}

	return 1;
}
Exemplo n.º 21
0
/* write the status_buf into the info array */
void alarm_commit(void)
{
	if (strlen(alarm_buf) > 0) {
		dstate_setinfo("ups.alarm", "%s", alarm_buf);
		alarm_active = 1;
	} else {
		dstate_delinfo("ups.alarm");
		alarm_active = 0;
	}
}
Exemplo n.º 22
0
static int setvar(const char *varname, const char *val)
{
	dummy_info_t *item;

	upsdebugx(2, "entering setvar(%s, %s)", varname, val);

	/* FIXME: the below is only valid if (mode == MODE_DUMMY)
	 * if (mode == MODE_REPEATER) => forward
	 * if (mode == MODE_META) => ?
	 */
	if (!strncmp(varname, "ups.status", 10))
	{
		status_init();
		 /* FIXME: split and check values (support multiple values), à la usbhid-ups */
		status_set(val);
		status_commit();

		return STAT_SET_HANDLED;
	}

	/* Check variable validity */
	if (!is_valid_data(varname))
	{
		upsdebugx(2, "setvar: invalid variable name (%s)", varname);
		return STAT_SET_UNKNOWN;
	}

	/* Check value validity */
	if (!is_valid_value(varname, val))
	{
		upsdebugx(2, "setvar: invalid value (%s) for variable (%s)", val, varname);
		return STAT_SET_UNKNOWN;
	}

	/* If value is empty, remove the variable (FIXME: do we need
	 * a magic word?) */
	if (strlen(val) == 0)
	{
		dstate_delinfo(varname);
	}
	else
	{
		dstate_setinfo(varname, "%s", val);

		if ( (item = find_info(varname)) != NULL)
		{
			dstate_setflags(item->info_type, item->info_flags);

			/* Set max length for strings, if needed */
			if (item->info_flags & ST_FLAG_STRING)
				dstate_setaux(item->info_type, item->info_len);
		}
	}
	return STAT_SET_HANDLED;
}
Exemplo n.º 23
0
static void upsc_getbaseinfo(void)
{
	char *buf;

	dstate_setinfo("ups.mfr", "%s",
		((buf = getval("manufacturer")) != NULL) ? buf : "unknown");

	if (!upsc_getvalue("UPTP", NULL, "NNAME", "ups.model", NULL))
		upsc_getvalue("UPTP", NULL, "NNAME", "ups.model", NULL);
	upsc_getvalue("UPSN", "0", "ACSN", "ups.serial", NULL);
}
Exemplo n.º 24
0
void upsdrv_initinfo(void)
{
	char	*s;

	dstate_setinfo("ups.mfr", "CyberPower");
	dstate_setinfo("ups.model", "[unknown]");
	dstate_setinfo("ups.serial", "[unknown]");

	subdriver[mode]->initinfo();

	/*
	 * Allow to override the following parameters
	 */
	if ((s = getval("manufacturer")) != NULL) {
		dstate_setinfo("ups.mfr", "%s", s);
	}
	if ((s = getval("model")) != NULL) {
		dstate_setinfo("ups.model", "%s", s);
	}
	if ((s = getval("serial")) != NULL) {
		dstate_setinfo("ups.serial", "%s", s);
	}

	upsh.instcmd = subdriver[mode]->instcmd;
	upsh.setvar = subdriver[mode]->setvar;
}
Exemplo n.º 25
0
void upsdrv_updateinfo(void)
{
	int r;
	int x,i=0,j,k,value;
	float value1;
	char ch;
	char data[10];
	int data_position = 4;
	
	test_EOL();
	
    	x= ser_get_buf_len(upsfd,buf, 64, SER_WAIT_SEC,SER_WAIT_USEC);
	printf("reading status is %d\n",x);
	printf("the reading data is %s\n",buf);

	ser_comm_good();
	r = test_CMD();
	if(r != TRUE){
	  printf("command error\n");
	  return;
	}
	i = data_position;
	for(j =0;j< _countof(pacefield);j++)
	{
	   
		 for(k=0;k<pacefield[j].len;k++)
		 {
			data[k] = buf[i+k];
			
		
		 }
		 data[k] = '\0';
		 printf("the reading data is %s\n",data);
		 value = atoi(data);
		 value1 = (float)value/pacefield[j].divident;
		 printf("value 1 = %f\n",value1);
		 dstate_setinfo(pacefield[j].name, "%0.2f",value1);
		 i = i+pacefield[j].len;
	    
	}
	status_init();
	update_err_status();
	update_charge_source_status();
	update_inverter_status();
	update_battery_status();
	update_load_status();
	update_battery_charge_dchrg_status();
	status_commit();
	dstate_dataok();
  
	
}
Exemplo n.º 26
0
static int get_transfer_voltage_high(void) {
	char response[MAX_RESPONSE_LENGTH];
	char *ptr;

	if (do_command(POLL, TRANSFER_VOLTAGE, "", response) > 0) {
		ptr = field(response, 1);
		if (ptr)
			dstate_setinfo("input.transfer.high", "%d", atoi(ptr));
		return 1;
	}

	return 0;
}
Exemplo n.º 27
0
Arquivo: clone.c Projeto: AlexLov/nut
void upsdrv_initinfo(void)
{
	const char	*val;

	time(&last_poll);

	dstate_addcmd("shutdown.return");
	dstate_addcmd("shutdown.stayoff");

	val = getval("offdelay");
	if (val) {
		offdelay = strtol(val, NULL, 10);
	}

	val = getval("ondelay");
	if (val) {
		ondelay = strtol(val, NULL, 10);
	}

	val = getval("mincharge");
	if (val) {
		battery.charge.low = strtod(val, NULL);
	}

	val = getval("minruntime");
	if (val) {
		battery.runtime.low = strtod(val, NULL);
	}

	dstate_setinfo("ups.delay.shutdown", "%d", offdelay);
	dstate_setinfo("ups.delay.start", "%d", ondelay);

	dstate_setinfo("ups.timer.shutdown", "%d", ups.timer.shutdown);
	dstate_setinfo("ups.timer.start", "%d", ups.timer.start);

	upsh.instcmd = instcmd;
	upsh.setvar = setvar;
}
Exemplo n.º 28
0
static int blazer_rating(const char *cmd)
{
    const struct {
        const char	*var;
        const char	*fmt;
        double		(*conv)(const char *, char **);
    } rating[] = {
        { "input.voltage.nominal", "%.0f", strtod },
        { "input.current.nominal", "%.1f", strtod },
        { "battery.voltage.nominal", "%.1f", blazer_packs },
        { "input.frequency.nominal", "%.0f", strtod },
        { NULL }
    };

    char	buf[SMALLBUF], *val, *last = NULL;
    int	i;

    /*
     * > [F\r]
     * < [#220.0 000 024.0 50.0\r]
     *    0123456789012345678901
     *    0         1         2
     */
    if (blazer_command(cmd, buf, sizeof(buf)) < 22) {
        upsdebugx(2, "%s: short reply", __func__);
        return -1;
    }

    if (buf[0] != '#') {
        upsdebugx(2, "%s: invalid start character [%02x]", __func__, buf[0]);
        return -1;
    }

    for (i = 0, val = strtok_r(buf+1, " ", &last); rating[i].var; i++, val = strtok_r(NULL, " \r\n", &last)) {

        if (!val) {
            upsdebugx(2, "%s: parsing failed", __func__);
            return -1;
        }

        if (strspn(val, "0123456789.") != strlen(val)) {
            upsdebugx(2, "%s: non numerical value [%s]", __func__, val);
            continue;
        }

        dstate_setinfo(rating[i].var, rating[i].fmt, rating[i].conv(val, NULL));
    }

    return 0;
}
Exemplo n.º 29
0
Arquivo: clone.c Projeto: AlexLov/nut
static int instcmd(const char *cmdname, const char *extra)
{
	const char	*val;

	val = dstate_getinfo(getval("load.status"));
	if (val) {
		if (!strcasecmp(val, "off") || !strcasecmp(val, "no")) {
			outlet = 0;
		}

		if (!strcasecmp(val, "on") || !strcasecmp(val, "yes")) {
			outlet = 1;
		}
	}

	if (!strcasecmp(cmdname, "shutdown.return")) {
		if (outlet && (ups.timer.shutdown < 0)) {
			ups.timer.shutdown = offdelay;
			dstate_setinfo("ups.status", "FSD %s", ups.status);
		}
		ups.timer.start = ondelay;
		return STAT_INSTCMD_HANDLED;
	}

	if (!strcasecmp(cmdname, "shutdown.stayoff")) {
		if (outlet && (ups.timer.shutdown < 0)) {
			ups.timer.shutdown = offdelay;
			dstate_setinfo("ups.status", "FSD %s", ups.status);
		}
		ups.timer.start = -1;
		return STAT_INSTCMD_HANDLED;
	}

	upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname);
	return STAT_INSTCMD_UNKNOWN;
}
Exemplo n.º 30
0
static int get_sensitivity(void) {
	char response[MAX_RESPONSE_LENGTH];
	unsigned int i;

	if (do_command(POLL, VOLTAGE_SENSITIVITY, "", response) <= 0)
		return 0;
	for (i = 0; i < sizeof(sensitivity) / sizeof(sensitivity[0]); i++) {
		if (sensitivity[i].code == atoi(response)) {
			dstate_setinfo("input.sensitivity", "%s",
			               sensitivity[i].name);
			return 1;
		}
	}

	return 0;
}