Beispiel #1
0
 def setled(self, item, color):
     if item.get("type", "i2c") == "sysfs":
         rgsysset(item["cmdstr"], item.get(color))
     else:
         mask = item.get("mask", 0xFF)
         ind, val = rgi2cget(item["bus"], item["devno"], item["addr"])
         if ind == True:
             setval = (int(val, 16) & ~mask) | item.get(color)
             rgi2cset(item["bus"], item["devno"], item["addr"], setval)
         else:
             logger.error("led %s" % "i2c read failed")
Beispiel #2
0
 def dealSlotLedStatus(self):
     u"""light slot status led according to slot present status"""
     slotLedList = DEV_LEDS.get("SLOTLED", [])
     for item in slotLedList:
         try:
             index = slotLedList.index(item) + 1
             slotattr = "slot%dstatus" % index
             val_t = getattr(FanControl, slotattr, None)
             if val_t == "PRESENT":
                 rgi2cset(item["bus"], item["devno"], item["addr"],
                          item["green"])
             logger.debug(
                 DEBUG_LEDCONTROL,
                 "%%ledcontrol:dealSlotLedStatus success.slotattr:%s, status:%s"
                 % (slotattr, val_t),
             )
         except Exception as e:
             logger.error("%%ledcontrol:dealSlotLedStatus error")
             logger.error(str(e))
def otherinit():
    for index in GLOBALINITPARAM:
        index_type = index.get("type", None)
        if index_type == "io":
            ret = io_wr(index.get("offset"), index.get("val"))
        else:
            ret, _ = rgi2cset(index.get("bus"), index.get("devaddr"),
                              index.get("offset"), index.get("val"))
        if not ret:
            click.echo("%%DEVICE_I2C-INIT: init param %s failed." %
                       index.get("name"))

    for index in GLOBALINITCOMMAND:
        log_os_system(index)
Beispiel #4
0
 def deal_fan_led_status(self):
     u"""light fan led according to fan status"""
     for item in MONITOR_FANS_LED:
         try:
             index = MONITOR_FANS_LED.index(item) + 1
             fanattr = "fan%dstatus" % index
             val_t = getattr(FanControl, fanattr, None)
             if val_t == "NOT OK":
                 rgi2cset(item["bus"], item["devno"], item["addr"],
                          item["red"])
             elif val_t == "OK":
                 rgi2cset(item["bus"], item["devno"], item["addr"],
                          item["green"])
             else:
                 pass
             logger.debug(
                 DEBUG_LEDCONTROL,
                 "%%ledcontrol:dealLocFanLed success.fanattr:%s, status:%s"
                 % (fanattr, val_t),
             )
         except Exception as e:
             logger.error("%%ledcontrol:deal_fan_led_status error")
             logger.error(str(e))
def otherinit():
    for index in GLOBALINITPARAM:
        # write_sysfs_value(index["loc"], index["value"])
        ret, _ = rgi2cset(
            index.get("bus"),
            index.get("devaddr"),
            index.get("offset"),
            index.get("val")
        )
        if not ret:
            click.echo("%%DEVICE_I2C-INIT: init param %s failed." % index.get("name"))

    for index in GLOBALINITCOMMAND:
        log_os_system(index)