From 7783d7bb18fc6dde80cf19cda02dd9d5768af230 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 16 May 2016 23:37:04 +0000 Subject: [PATCH] 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(). --- .../any/onlp/src/onlp/module/auto/onlp.yml | 31 +++++++++---------- .../any/onlp/src/onlp/module/inc/onlp/led.h | 28 ++++++++++++----- .../src/onlp/module/inc/onlp/platformi/ledi.h | 20 ++++++++---- .../base/any/onlp/src/onlp/module/src/led.c | 23 ++++++++++++++ .../any/onlp/src/onlp/module/src/onlp_enums.c | 2 ++ 5 files changed, 75 insertions(+), 29 deletions(-) diff --git a/packages/base/any/onlp/src/onlp/module/auto/onlp.yml b/packages/base/any/onlp/src/onlp/module/auto/onlp.yml index 4507898f..47adc6e6 100644 --- a/packages/base/any/onlp/src/onlp/module/auto/onlp.yml +++ b/packages/base/any/onlp/src/onlp/module/auto/onlp.yml @@ -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 - - diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h index 233cd243..2909b9df 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/led.h @@ -1,21 +1,21 @@ /************************************************************ * - * - * 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. - * + * * ************************************************************ * @@ -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 diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h index 9bb043fa..7d5bb545 100644 --- a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/ledi.h @@ -1,21 +1,21 @@ /************************************************************ * - * - * 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. - * + * * ************************************************************ * @@ -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__ */ diff --git a/packages/base/any/onlp/src/onlp/module/src/led.c b/packages/base/any/onlp/src/onlp/module/src/led.c index f78fac92..50f85809 100644 --- a/packages/base/any/onlp/src/onlp/module/src/led.c +++ b/packages/base/any/onlp/src/onlp/module/src/led.c @@ -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); diff --git a/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c b/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c index 7fd366bf..0c5a185f 100644 --- a/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c +++ b/packages/base/any/onlp/src/onlp/module/src/onlp_enums.c @@ -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 },