Esempio n. 1
0
int
onlp_gpio_set(int gpio, int v)
{
    char* str = (v) ? "1\n" : "0\n";
    return onlp_file_write((uint8_t*)str, strlen(str),
                           SYS_CLASS_GPIO_PATH "/value", gpio);
}
Esempio n. 2
0
/*
 * This function puts the LED into the given mode. It is a more functional
 * interface for multimode LEDs.
 *
 * Only modes reported in the LED's capabilities will be attempted.
 */
int
onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
{
    int  local_id;

    VALIDATE(id);

    local_id = ONLP_OID_ID_GET(id);

    if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len,
    	"%s%s", prefix_path, file_names[local_id]) != 0) {
        return ONLP_STATUS_E_INTERNAL;
    }

    return ONLP_STATUS_OK;
}
Esempio n. 3
0
int
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
{
    int bus = FRONT_PORT_TO_MUX_INDEX(port);
    int ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);

    if (ret == 0)  {
	unsigned char buf[8] = { 0 };
	char str[20];

	buf[port/8] = (1 << port%8);
	sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]);
	if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) {
	    AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port);
	    return ONLP_STATUS_E_INTERNAL;
	}
        return ONLP_STATUS_OK;
    }
    AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port);
    return ret;
}