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; }
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; }
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; }