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

void upsdrv_initups ( void   ) 

Initialize UPS and variables from ups.conf.

Todo:
Allow binding based on firmware version (which seems to vary wildly from unit to unit)

Definition at line 1364 of file tripplite_usb.c.

References USBDeviceMatcher_s::next, offdelay, USBDevice_s::Product, and USBDevice_s::Vendor.

{
      char *regex_array[6];
      int r;

      /* process the UPS selection options */
      regex_array[0] = "09AE" /* getval("vendorid") */;
      regex_array[1] = getval("productid");
      if(!regex_array[1]) regex_array[1] = "0001";
      regex_array[2] = getval("vendor"); /* vendor string */
      regex_array[3] = getval("product"); /* product string */
      regex_array[4] = getval("serial"); /* probably won't see this */
      regex_array[5] = getval("bus");

      r = USBNewRegexMatcher(&regex_matcher, regex_array, REG_ICASE | REG_EXTENDED);
      if (r==-1) {
            fatal_with_errno(EXIT_FAILURE, "USBNewRegexMatcher");
      } else if (r) {
            fatalx(EXIT_FAILURE, "invalid regular expression: %s", regex_array[r]);
      }

      /* Search for the first supported UPS matching the regular
       *            expression */
      r = comm_driver->open(&udev, &curDevice, regex_matcher, NULL);
      if (r < 1) {
            fatalx(EXIT_FAILURE, "No matching USB/HID UPS found");
      }

      hd = &curDevice;
      
      upslogx(1, "Detected a UPS: %s/%s", hd->Vendor ? hd->Vendor : "unknown", hd->Product ? hd->Product : "unknown");

      /* create a new matcher for later reopening */
      r = USBNewExactMatcher(&reopen_matcher, hd);
      if (r) {
            fatal_with_errno(EXIT_FAILURE, "USBNewExactMatcher");
      }
      /* link the two matchers */
      reopen_matcher->next = regex_matcher;

      if (getval("offdelay"))
            offdelay = atoi(getval("offdelay"));
#if 0
      if (getval("startdelay"))
            startdelay = atoi(getval("startdelay"));
      if (getval("rebootdelay"))
            bootdelay = atoi(getval("rebootdelay"));
#endif
}


Generated by  Doxygen 1.6.0   Back to index