Support LED Character Devices

- Set ONLP_LED_CAP_CHAR to support a character display.
- Implement onlp_ledi_char_set().
- Add the when implementing onlp_ledi_info_get().
This commit is contained in:
Jeffrey Townsend
2016-05-16 23:37:04 +00:00
parent c7c30e87ef
commit 7783d7bb18
5 changed files with 75 additions and 29 deletions

View File

@@ -163,20 +163,21 @@ thermal_threshold: &thermal_threshold
# LED caps
led_caps: &led_caps
- ON_OFF : (1 << 0)
- RED : (1 << 10)
- RED_BLINKING : (1 << 11)
- ORANGE : (1 << 12)
- ORANGE_BLINKING : (1 << 13)
- YELLOW : ( 1 << 14)
- YELLOW_BLINKING : (1 << 15)
- GREEN : (1 << 16)
- GREEN_BLINKING : (1 << 17)
- BLUE : (1 << 18)
- BLUE_BLINKING : (1 << 19)
- PURPLE: (1 << 20)
- PURPLE_BLINKING : (1 << 21)
- AUTO : (1 << 22)
- ON_OFF : (1 << 0)
- CHAR : (1 << 1)
- RED : (1 << 10)
- RED_BLINKING : (1 << 11)
- ORANGE : (1 << 12)
- ORANGE_BLINKING : (1 << 13)
- YELLOW : (1 << 14)
- YELLOW_BLINKING : (1 << 15)
- GREEN : (1 << 16)
- GREEN_BLINKING : (1 << 17)
- BLUE : (1 << 18)
- BLUE_BLINKING : (1 << 19)
- PURPLE : (1 << 20)
- PURPLE_BLINKING : (1 << 21)
- AUTO : (1 << 22)
# LED status
led_status: &led_status
@@ -307,5 +308,3 @@ definitions:
xmacro:
ONLP_OID_TYPE_ENTRY:
members: *oid_types

View File

@@ -1,21 +1,21 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.eclipse.org/legal/epl-v10.html
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
*
* </bsn.cl>
************************************************************
*
@@ -32,11 +32,12 @@
/** onlp_led_caps */
typedef enum onlp_led_caps_e {
ONLP_LED_CAPS_ON_OFF = (1 << 0),
ONLP_LED_CAPS_CHAR = (1 << 1),
ONLP_LED_CAPS_RED = (1 << 10),
ONLP_LED_CAPS_RED_BLINKING = (1 << 11),
ONLP_LED_CAPS_ORANGE = (1 << 12),
ONLP_LED_CAPS_ORANGE_BLINKING = (1 << 13),
ONLP_LED_CAPS_YELLOW = ( 1 << 14),
ONLP_LED_CAPS_YELLOW = (1 << 14),
ONLP_LED_CAPS_YELLOW_BLINKING = (1 << 15),
ONLP_LED_CAPS_GREEN = (1 << 16),
ONLP_LED_CAPS_GREEN_BLINKING = (1 << 17),
@@ -91,6 +92,10 @@ typedef struct onlp_led_info_s {
/** Current mode, if capable. */
onlp_led_mode_t mode;
/** Current char, if capable. */
char character;
} onlp_led_info_t;
/**
@@ -124,6 +129,15 @@ int onlp_led_set(onlp_oid_t id, int on_or_off);
*/
int onlp_led_mode_set(onlp_oid_t id, onlp_led_mode_t color);
/**
* @brief Set the LED char
* @param id The LED OID
* @param c The character.
* @note Only relevant if the LED supports the char capability.
*/
int onlp_led_char_set(onlp_oid_t id, char c);
/**
* @brief LED OID debug dump
* @param id The LED OID

View File

@@ -1,21 +1,21 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.eclipse.org/legal/epl-v10.html
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
*
* </bsn.cl>
************************************************************
*
@@ -63,4 +63,12 @@ int onlp_ledi_ioctl(onlp_oid_t id, va_list vargs);
*/
int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode);
/**
* @brief Set the LED character.
* @param id The LED OID
* @param c The character..
* @notes Only called if the char capability is set.
*/
int onlp_ledi_char_set(onlp_oid_t id, char c);
#endif /* __ONLP_LED_H__ */

View File

@@ -117,6 +117,25 @@ onlp_led_mode_set_locked__(onlp_oid_t id, onlp_led_mode_t mode)
}
ONLP_LOCKED_API2(onlp_led_mode_set, onlp_oid_t, id, onlp_led_mode_t, mode);
static int
onlp_led_char_set_locked__(onlp_oid_t id, char c)
{
onlp_led_info_t info;
ONLP_LED_PRESENT_OR_RETURN(id, &info);
/*
* The mode enumeration values always match
* the capability bit positions.
*/
if(info.caps & ONLP_LED_CAPS_CHAR) {
return onlp_ledi_char_set(id, c);
}
else {
return ONLP_STATUS_E_UNSUPPORTED;
}
}
ONLP_LOCKED_API2(onlp_led_char_set, onlp_oid_t, id, char, c);
/************************************************************
*
* Debug and Show Functions
@@ -144,6 +163,7 @@ onlp_led_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
iof_iprintf(&iof, "Status: %{onlp_led_status_flags}", info.status);
iof_iprintf(&iof, "Caps: %{onlp_led_caps_flags}", info.caps);
iof_iprintf(&iof, "Mode: %{onlp_led_mode}", info.mode);
iof_iprintf(&iof, "Char: %c", info.character);
}
else {
iof_iprintf(&iof, "Not present.");
@@ -189,6 +209,9 @@ onlp_led_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
/* Present */
iof_iprintf(&iof, "State: Present");
iof_iprintf(&iof, "Mode: %{onlp_led_mode}", info.mode);
if(info.caps & ONLP_LED_CAPS_CHAR) {
iof_iprintf(&iof, "Char: %c", info.character);
}
}
else {
onlp_oid_show_state_missing(&iof);

View File

@@ -282,6 +282,7 @@ onlp_fan_status_valid(onlp_fan_status_t e)
aim_map_si_t onlp_led_caps_map[] =
{
{ "ON_OFF", ONLP_LED_CAPS_ON_OFF },
{ "CHAR", ONLP_LED_CAPS_CHAR },
{ "RED", ONLP_LED_CAPS_RED },
{ "RED_BLINKING", ONLP_LED_CAPS_RED_BLINKING },
{ "ORANGE", ONLP_LED_CAPS_ORANGE },
@@ -301,6 +302,7 @@ aim_map_si_t onlp_led_caps_map[] =
aim_map_si_t onlp_led_caps_desc_map[] =
{
{ "None", ONLP_LED_CAPS_ON_OFF },
{ "None", ONLP_LED_CAPS_CHAR },
{ "None", ONLP_LED_CAPS_RED },
{ "None", ONLP_LED_CAPS_RED_BLINKING },
{ "None", ONLP_LED_CAPS_ORANGE },