Logo Search packages:      
Sourcecode: nut version File versions  Download package

static int control_outlet ( int  outlet_id,
int  state 
) [static]

Turn an outlet on or off.

Returns:
1 if the command worked, 0 if not.

Definition at line 817 of file tripplite_usb.c.

References send_cmd().

Referenced by instcmd().

{
      char k_cmd[10], buf[10];
      int ret;

      switch(tl_model) {
            case TRIPP_LITE_SMARTPRO:   /* tested */
            case TRIPP_LITE_SMART_0004: /* untested */
                  snprintf(k_cmd, sizeof(k_cmd)-1, "N%02X", 5);
                  ret = send_cmd((unsigned char *)k_cmd, strlen(k_cmd) + 1, (unsigned char *)buf, sizeof buf);
                  snprintf(k_cmd, sizeof(k_cmd)-1, "K%d%d", outlet_id, state & 1);
                  ret = send_cmd((unsigned char *)k_cmd, strlen(k_cmd) + 1, (unsigned char *)buf, sizeof buf);

                  if(ret != 8) {
                        upslogx(LOG_ERR, "Could not set outlet %d to state %d, ret = %d", outlet_id, state, ret);
                        return 0;
                  } else {
                        return 1;
                  }
            default:
                  upslogx(LOG_ERR, "control_outlet unimplemented for this UPS model");
      }
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index