当前位置: 首页>>代码示例>>C++>>正文


C++ ONLP_OID_ID_GET函数代码示例

本文整理汇总了C++中ONLP_OID_ID_GET函数的典型用法代码示例。如果您正苦于以下问题:C++ ONLP_OID_ID_GET函数的具体用法?C++ ONLP_OID_ID_GET怎么用?C++ ONLP_OID_ID_GET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ONLP_OID_ID_GET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onlp_ledi_info_get

int
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
    int  lid, value;
		
    VALIDATE(id);
	
    lid = ONLP_OID_ID_GET(id);

    /* Set the onlp_oid_hdr_t and capabilities */
    *info = linfo[ONLP_OID_ID_GET(id)];

    /* Get LED mode */
    if (onlp_file_read_int(&value, LED_FORMAT, leds[lid]) < 0) {
        DEBUG_PRINT("Unable to read status from file "LED_FORMAT, leds[lid]);
        return ONLP_STATUS_E_INTERNAL;
    }

    info->mode = driver_to_onlp_led_mode(lid, value);

    /* Set the on/off status */
    if (info->mode != ONLP_LED_MODE_OFF) {
        info->status |= ONLP_LED_STATUS_ON;
    }

    return ONLP_STATUS_OK;
}
开发者ID:carlroth,项目名称:OpenNetworkLinux,代码行数:27,代码来源:ledi.c

示例2: onlp_ledi_info_get

int
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
    int  local_id;
	char data[2] = {0};
    char fullpath[50] = {0};
		
    VALIDATE(id);
	
    local_id = ONLP_OID_ID_GET(id);
    		
    /* get fullpath */
    sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename);
		
	/* Set the onlp_oid_hdr_t and capabilities */
    *info = linfo[ONLP_OID_ID_GET(id)];

    /* Set LED mode */
    if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) {
        DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__);
        return ONLP_STATUS_E_INTERNAL;
    }

    info->mode = driver_to_onlp_led_mode(local_id, atoi(data));

    /* Set the on/off status */
    if (info->mode != ONLP_LED_MODE_OFF) {
        info->status |= ONLP_LED_STATUS_ON;
    }

    return ONLP_STATUS_OK;
}
开发者ID:carlroth,项目名称:OpenNetworkLinux,代码行数:32,代码来源:ledi.c

示例3: onlp_fani_info_get

int
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
{
    VALIDATE(id);

    *info = finfo[ONLP_OID_ID_GET(id)]; /* Set the onlp_oid_hdr_t */
    ONLP_OID_TABLE_CLEAR(info->hdr.coids);

    if (ONLP_OID_ID_GET(id) == FAN_ID_CHASSIS) {
        return chassis_fan_get_info(info);
    }
    else {
        int psu_id = ONLP_OID_ID_GET(id)-1;
        as5610_52x_psu_type_t psu_type = as5610_52x_get_psu_type(psu_id, NULL, 0);

        switch (psu_type) {
            case PSU_TYPE_AC_F2B:
                return psu_cpr_4011_f2b_fan_info_get(info);
            case PSU_TYPE_AC_B2F:
                return psu_cpr_4011_b2f_fan_info_get(info);
            case PSU_TYPE_DC_48V_F2B:
                return psu_um400d_f2b_fan_info_get(info);
            case PSU_TYPE_DC_48V_B2F:
                return psu_um400d_b2f_fan_info_get(info);
            default:
                break;
        }
    }

    return ONLP_STATUS_E_UNSUPPORTED;
}
开发者ID:brandonchuang,项目名称:OpenNetworkLinux,代码行数:31,代码来源:fani.c

示例4: onlp_ledi_info_get

int
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
    int  len, local_id = 0;
    uint8_t data[driver_value_len] = {0};

    VALIDATE(id);

    local_id = ONLP_OID_ID_GET(id);

    /* Set the onlp_oid_hdr_t and capabilities */
    *info = linfo[ONLP_OID_ID_GET(id)];

    /* Get LED mode */
    if (onlp_file_read(data, sizeof(data), &len, "%s%s",
    		prefix_path, file_names[local_id]) != 0) {
        return ONLP_STATUS_E_INTERNAL;
    }

    info->mode = driver_to_onlp_led_mode(local_id, (char*)data);

    /* Set the on/off status */
    if (info->mode != ONLP_LED_MODE_OFF) {
        info->status |= ONLP_LED_STATUS_ON;
    }

    return ONLP_STATUS_OK;
}
开发者ID:opencomputeproject,项目名称:OpenNetworkLinux,代码行数:28,代码来源:ledi.c

示例5: onlp_fani_info_get

int
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv)
{
    *rv = fans__[ONLP_OID_ID_GET(id)];
    rv->caps |= ONLP_FAN_CAPS_GET_RPM;

    int len;
    char direction[16] = {0};

    int fid = ONLP_OID_ID_GET(id);

    /* Read the current airflow direction */
    onlp_file_read((uint8_t*)direction, sizeof(direction), &len,
                   SYS_HWMON_PREFIX "/fan_dir");

#define FAN_DIR_F2B "front-to-back"
#define FAN_DIR_B2F "back-to-front"

    if(!strncmp(direction, FAN_DIR_F2B, strlen(FAN_DIR_F2B))) {
        rv->status |= ONLP_FAN_STATUS_F2B;
        rv->caps |= ONLP_FAN_CAPS_F2B;
    }
    else if(!strncmp(direction, FAN_DIR_B2F, strlen(FAN_DIR_B2F))) {
        rv->status |= ONLP_FAN_STATUS_B2F;
        rv->caps |= ONLP_FAN_CAPS_B2F;
    }
    else {
        AIM_LOG_WARN("Invalid fan direction: '%s'", direction);
    }


    switch(fid)
        {
        case FAN_ID_FAN1:
        case FAN_ID_FAN2:
        case FAN_ID_FAN3:
        case FAN_ID_FAN4:
            {
                if(rv->status & ONLP_FAN_STATUS_F2B) {
                    return sys_fan_info_get__(rv, fid);
                }
                if(rv->status & ONLP_FAN_STATUS_B2F) {
                    return sys_fan_info_get__(rv, fid+4);
                }
                return ONLP_STATUS_E_INTERNAL;
            }

        case FAN_ID_FAN5:
        case FAN_ID_FAN6:
            {
                return psu_fan_info_get__(rv, fid);
            }
        }

    return ONLP_STATUS_E_INVALID;
}
开发者ID:JS-Wang,项目名称:proceeding-onlp,代码行数:56,代码来源:fani.c

示例6: onlp_snmp_sensor_register_oid__

static int
onlp_snmp_sensor_register_oid__(onlp_oid_t oid, void* cookie)
{
    onlp_oid_hdr_t hdr;
    onlp_snmp_sensor_t s;

    onlp_oid_hdr_get(oid, &hdr);

    AIM_MEMSET(&s, 0x0, sizeof(onlp_snmp_sensor_t));
    switch(ONLP_OID_TYPE_GET(oid))
        {
        case ONLP_OID_TYPE_THERMAL:
#if ONLP_SNMP_CONFIG_INCLUDE_THERMALS == 1
            s.sensor_id = oid;
            sprintf(s.name, "%d - ", ONLP_OID_ID_GET(oid));
            aim_strlcpy(s.desc, hdr.description, sizeof(s.desc));
            if(onlp_snmp_sensor_reg__(ONLP_SNMP_SENSOR_TYPE_TEMP, &s) < 0) {
                AIM_LOG_ERROR("onlp_snmp_sensor_reg for OID 0x%x failed.", oid);
            }
#endif
            break;

        case ONLP_OID_TYPE_FAN:
#if ONLP_SNMP_CONFIG_INCLUDE_FANS == 1
            s.sensor_id = oid;
            sprintf(s.name, "%d - ", ONLP_OID_ID_GET(oid));
            aim_strlcpy(s.desc, hdr.description, sizeof(s.desc));
            if(onlp_snmp_sensor_reg__(ONLP_SNMP_SENSOR_TYPE_FAN, &s) < 0) {
                AIM_LOG_ERROR("onlp_snmp_sensor_reg for OID 0x%x failed.", oid);
            }
#endif
            break;

        case ONLP_OID_TYPE_PSU:
#if ONLP_SNMP_CONFIG_INCLUDE_PSUS == 1
            /* Register Sensors for VIN,VOUT,IIN,IOUT,PIN,POUT */
            s.sensor_id = oid;
            sprintf(s.name, "%d - ", ONLP_OID_ID_GET(oid));
            aim_strlcpy(s.desc, hdr.description, sizeof(s.desc));
            if(onlp_snmp_sensor_reg__(ONLP_SNMP_SENSOR_TYPE_PSU, &s) < 0) {
                AIM_LOG_ERROR("onlp_snmp_sensor_reg for OID 0x%x failed.", oid);
            }
#endif
            break;

        default:
            AIM_LOG_INFO("snmp type %s id %d unsupported",
                         onlp_oid_type_name(ONLP_OID_TYPE_GET(oid)),
                         ONLP_OID_ID_GET(oid));
            break;
    }

    return 0;
}
开发者ID:Lewis-Kang,项目名称:OpenNetworkLinux,代码行数:54,代码来源:onlp_snmp_sensors.c

示例7: onlp_fani_info_get

int
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
{
    int rc = 0;
    int local_id;
    VALIDATE(id);

    local_id = ONLP_OID_ID_GET(id);
    *info = linfo[local_id];

    switch (local_id)
    {
	    case FAN_1_ON_PSU1:
        case FAN_1_ON_PSU2:
            rc = _onlp_fani_info_get_fan_on_psu(local_id, info);
            break;
        case FAN_1_ON_MAIN_BOARD:
        case FAN_2_ON_MAIN_BOARD:
        case FAN_3_ON_MAIN_BOARD:
        case FAN_4_ON_MAIN_BOARD:
        case FAN_5_ON_MAIN_BOARD:
            rc =_onlp_fani_info_get_fan(local_id, info);
            break;
        default:
            rc = ONLP_STATUS_E_INVALID;
            break;
    }

    return rc;
}
开发者ID:carlroth,项目名称:OpenNetworkLinux,代码行数:30,代码来源:fani.c

示例8: onlp_psui_info_get

int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
    int val   = 0;
    int ret   = ONLP_STATUS_OK;
    int index = ONLP_OID_ID_GET(id);
    psu_type_t psu_type; 

    VALIDATE(id);

    memset(info, 0, sizeof(onlp_psu_info_t));
    *info = pinfo[index]; /* Set the onlp_oid_hdr_t */

    if (onlp_file_read_int(&val, PSU_PRESENT_FORMAT, index) < 0) {
        AIM_LOG_ERROR("Unable to read present status from PSU(%d)\r\n", index);
        return ONLP_STATUS_E_INTERNAL;
    }

    if (val != PSU_STATUS_PRESENT) {
        info->status &= ~ONLP_PSU_STATUS_PRESENT;
        return ONLP_STATUS_OK;
    }
    info->status |= ONLP_PSU_STATUS_PRESENT;


    /* Get power good status */
    if (onlp_file_read_int(&val, PSU_POWERGOOD_FORMAT, index) < 0) {
        AIM_LOG_ERROR("Unable to read power status from PSU(%d)\r\n", index);
        return ONLP_STATUS_E_INTERNAL;
    }

    if (val != PSU_STATUS_POWER_GOOD) {
        info->status |=  ONLP_PSU_STATUS_FAILED;
    }


    /* Get PSU type
     */
    psu_type = psu_type_get(index, info->model, sizeof(info->model));
    switch (psu_type) {
        case PSU_TYPE_AC_DPS850_F2B:
        case PSU_TYPE_AC_DPS850_B2F:
            ret = psu_dps850_info_get(info);      
            break;
        case PSU_TYPE_AC_YM2851_F2B:
        case PSU_TYPE_AC_YM2851_B2F:
            ret = psu_ym2651y_info_get(info);
            break;
        case PSU_TYPE_UNKNOWN:  /* User insert a unknown PSU or unplugged.*/
            info->status |= ONLP_PSU_STATUS_UNPLUGGED;
            info->status &= ~ONLP_PSU_STATUS_FAILED;
            ret = ONLP_STATUS_OK;
            break;
        default:
            ret = ONLP_STATUS_E_UNSUPPORTED;
            break;
    }

    return ret;
}
开发者ID:carlroth,项目名称:OpenNetworkLinux,代码行数:60,代码来源:psui.c

示例9: onlp_thermali_info_get

/*
 * Retrieve the information structure for the given thermal OID.
 *
 * If the OID is invalid, return ONLP_E_STATUS_INVALID.
 * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
 * Otherwise, return ONLP_STATUS_OK with the OID's information.
 *
 * Note -- it is expected that you fill out the information
 * structure even if the sensor described by the OID is not present.
 */
int
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
    int tid;

    VALIDATE(id);

    memset(info, 0, sizeof(onlp_thermal_info_t));
    tid = ONLP_OID_ID_GET(id);
    *info = temps__[tid];

    switch(tid)
    {
        case THERMAL_ID_THERMAL1:
        case THERMAL_ID_THERMAL2:
        case THERMAL_ID_THERMAL3:
            return sys_thermal_info_get__(info, tid);

        case THERMAL_ID_THERMAL4:
        case THERMAL_ID_THERMAL5:
            return psu1_thermal_info_get__(info, (tid - THERMAL_ID_THERMAL4 + 1));

        case THERMAL_ID_THERMAL6:
        case THERMAL_ID_THERMAL7:
            return psu2_thermal_info_get__(info, (tid - THERMAL_ID_THERMAL6 + 1));
    }

    return ONLP_STATUS_E_INVALID;
}
开发者ID:carlroth,项目名称:OpenNetworkLinux,代码行数:39,代码来源:thermali.c

示例10: psu_um400d_fan_info_get

static int
psu_um400d_fan_info_get(onlp_fan_info_t* info)
{
    unsigned char cpld_offset, data;

    info->mode       = ONLP_FAN_MODE_INVALID; /* Set current mode */
    info->rpm        = 0; /* Set rpm as 0 since the fan controller does not support rpm reading */
    info->percentage = 0;

    /* Get operating status
     */
    if (FAN_ID_PSU1 == ONLP_OID_ID_GET(info->hdr.id)) {
        cpld_offset = CPLD_REG_PSU1_STATUS;
    }
    else { /* FAN_ID_PSU2 */
        cpld_offset = CPLD_REG_PSU2_STATUS;
    }

    data = cpld_base__[cpld_offset];

    if (!(data & CPLD_PSU_FAN_FAILURE_MASK)) {
        info->status |= ONLP_FAN_STATUS_FAILED;
    }

    return ONLP_STATUS_OK;
}
开发者ID:brandonchuang,项目名称:OpenNetworkLinux,代码行数:26,代码来源:fani.c

示例11: onlp_psui_status_get

/**
 * @brief Get the PSU's operational status.
 * @param id The PSU OID.
 * @param rv [out] Receives the operational status.
 */
int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv)
{
    int result = ONLP_STATUS_OK;
    hwmon_psu_state_t psu_state;
    int local_id;
    VALIDATE(id);
    int len;
    char buf[ONLP_CONFIG_INFO_STR_MAX];

    local_id = ONLP_OID_ID_GET(id);
    if(local_id >= ONLP_PSU_MAX) {
        result = ONLP_STATUS_E_INVALID;
    } else {
        result = onlp_file_read((uint8_t*)&buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%s""psu%d", INV_HWMON_PREFIX, local_id);
        if( result != ONLP_STATUS_OK ) {return result;}
        psu_state = (uint8_t)strtoul(buf, NULL, 0);
        if( psu_state == HWMON_PSU_UNPOWERED) {
            *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED;
        } else if ( psu_state == HWMON_PSU_NORMAL) {
            *rv = ONLP_PSU_STATUS_PRESENT;
        } else if( psu_state == HWMON_PSU_FAULT) {
            *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED;
        } else if( psu_state == HWMON_PSU_NOT_INSTALLED) {
            *rv = 0;
        } else {
            result = ONLP_STATUS_E_INVALID;
        }
    }
    return result;
}
开发者ID:carlroth,项目名称:OpenNetworkLinux,代码行数:35,代码来源:psui.c

示例12: _psu_info_get

static int
_psu_info_get(onlp_psu_info_t* info)
{
    int val   = 0;
    int index = ONLP_OID_ID_GET(info->hdr.id);

    /* Set capability */
    info->caps = ONLP_PSU_CAPS_AC;

    if (info->status & ONLP_PSU_STATUS_FAILED) {
        return ONLP_STATUS_OK;
    }

    /* Read voltage, current and power */
	if (psu_power_info_get(index, "volt", &val) == 0) {
		info->mvout = val;
		info->caps |= ONLP_PSU_CAPS_VOUT;
	}

	if (psu_power_info_get(index, "curr", &val) == 0) {
		info->miout = val;
		info->caps |= ONLP_PSU_CAPS_IOUT;
	}

	info->mpout = info->mvout * info->miout;
	info->caps |= ONLP_PSU_CAPS_POUT;

	info->mpin = ((int)(info->mpout / 91)) * 100;
	info->caps |= ONLP_PSU_CAPS_PIN;

    return ONLP_STATUS_OK;
}
开发者ID:opencomputeproject,项目名称:OpenNetworkLinux,代码行数:32,代码来源:psui.c

示例13: onlp_psui_info_get

int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
    int val   = 0;
    int ret   = ONLP_STATUS_OK;
    int index = ONLP_OID_ID_GET(id);
    const char psu_model[]=PSU_MODEL;

    VALIDATE(id);

    memset(info, 0, sizeof(onlp_psu_info_t));
    *info = pinfo[index]; /* Set the onlp_oid_hdr_t */

    /* Fixed system, PSU is always present */
	info->status |= ONLP_PSU_STATUS_PRESENT;

	strncpy(info->model, psu_model, sizeof(info->model));

    /* Get the cable preset state */
    if (psu_module_info_get(index, "pwr_status", &val) != 0) {
        AIM_LOG_ERROR("Unable to read PSU(%d) node(cable_present)\r\n", index);
    }

    if (val != PSU_CABLE_PRESENT) {
        info->status |= ONLP_PSU_STATUS_UNPLUGGED;
        return ONLP_STATUS_OK;
    }

    info->status |= ONLP_PSU_STATUS_PRESENT;

    ret = _psu_info_get(info);

    return ret;
}
开发者ID:opencomputeproject,项目名称:OpenNetworkLinux,代码行数:34,代码来源:psui.c

示例14: onlp_thermali_info_get

/*
 * Retrieve the information structure for the given thermal OID.
 *
 * If the OID is invalid, return ONLP_E_STATUS_INVALID.
 * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
 * Otherwise, return ONLP_STATUS_OK with the OID's information.
 *
 * Note -- it is expected that you fill out the information
 * structure even if the sensor described by the OID is not present.
 */
int
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
    int   fd, len, nbytes = 10, temp_base=1, local_id;
    char  r_data[10]   = {0};
    char  fullpath[50] = {0};
    VALIDATE(id);
	
    local_id = ONLP_OID_ID_GET(id);
	
    /* Set the onlp_oid_hdr_t and capabilities */		
    *info = linfo[local_id];

    if(local_id == THERMAL_CPU_CORE) {
        int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
        return rv;
    }	
	
    /* get fullpath */
    sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]);

    OPEN_READ_FILE(fd, fullpath, r_data, nbytes, len);
    info->mcelsius = atoi(r_data) / temp_base;	
    DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius);

    return ONLP_STATUS_OK;								
}
开发者ID:Lewis-Kang,项目名称:OpenNetworkLinux,代码行数:37,代码来源:thermali.c

示例15: onlp_led_show

void
onlp_led_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
{
    int rv;
    iof_t iof;
    onlp_led_info_t info;

    VALIDATENR(id);
    onlp_oid_show_iof_init_default(&iof, pvs);
    iof_push(&iof, "LED %d", ONLP_OID_ID_GET(id));
    rv = onlp_led_info_get(id, &info);
    if(rv < 0) {
        onlp_oid_info_get_error(&iof, rv);
    }
    else {
        onlp_oid_show_description(&iof, &info.hdr);
        if(info.status & 1) {
            /* Present */
            iof_iprintf(&iof, "Mode: %{onlp_led_mode}", info.mode);
        }
        else {
            onlp_oid_show_state_missing(&iof);
        }
    }
    iof_pop(&iof);

}
开发者ID:bigswitch,项目名称:ONLP,代码行数:27,代码来源:led.c


注:本文中的ONLP_OID_ID_GET函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。