Subsections


B.10 HWSUPP - Hints for package developers

This chapter describes the things a package developer has to do to add LED or button functionality to a packageB.1.

B.10.1 LED extensions

B.10.1.1 LED type

Within the file check/myopt.exp the list of LED types which can be entered in HWSUPP_LED_x is extended.

Example:

+HWSUPP_LED_TYPE(OPT_MYOPT) = 'myopt' 
                            : ', myopt'

B.10.1.2 Parameter check

Within check/myopt.ext the parameters which can be entered in HWSUPP_LED_x_PARAM will be checked.

Example:

if (opt_hwsupp)
then
    depends on hwsupp version 4.0

    foreach i in hwsupp_led_n
    do
        set action=hwsupp_led_%[i]
        set param=hwsupp_led_%_param[i]
        if (action == "myopt")
        then
            if (!(param =~ "(RE:MYOPT_LED_PARAM)"))
            then
                error "When HWSUPP_LED_\${i}='myopt', ...
                       must be entered in HWSUPP_LED_\${i}_PARAM" 
            fi
        fi
    done
fi

B.10.1.3 LED Display

The command /usr/bin/hwsupp_setled <LED> <status>/ has to be executed to set a LED in a package script (eg. /usr/bin/<opt>_setled)

The LED number can be found in /var/run/hwsupp.conf.

Status can be off, on or blink.

Example:

if [ -f /var/run/hwsupp.conf ]
then
    . /var/run/hwsupp.conf
    [ 0$hwsupp_led_n -eq 0 ] || for i in `seq 1 $hwsupp_led_n`
    do
        eval action=\$hwsupp_led_${i}
        eval param=\$hwsupp_led_${i}_param
        if [ "$action" = "<opt>" ]
        then
            if [ <myexpression> ]
            then
                /usr/bin/hwsupp_setled $i on
            else
                /usr/bin/hwsupp_setled $i off
            fi
        fi
    done
fi

The actual state of a LED can be queried with /usr/bin/hwsupp_getled <LED>/. The result will be off, on or blink.

B.10.2 Button extensions

B.10.3 Button action

In check/myopt.exp the list of button types allowed in HWSUPP_LED_x can be extended.

Beispiel:

+HWSUPP_BUTTON_TYPE(OPT_MYOPT) = 'myopt' 
                               : ', myopt'

B.10.3.1 Parameter check

The parameters which can be entered in HWSUPP_BUTTON_x_PARAM will be checked using check/myopt.ext .

Example:

if (opt_hwsupp)
then
    depends on hwsupp version 4.0

    foreach i in hwsupp_button_n
    do
        set action=hwsupp_buttonn_%[i]
        set param=hwsupp_button_%_param[i]
        if (action == "myopt")
        then
            add_to_opt "files/usr/bin/myopt_keyprog" "mode=555 flags=sh"
            if (!(param =~ "(RE:MYOPT_BUTTON_PARAM)"))
            then
                error "When HWSUPP_BUTTON_\${i}='myopt', ...
                       must be entered in  HWSUPP_BUTTON_\${i}_PARAM" 
            fi
        fi
    done
fi

B.10.3.2 Button function

When a button is pressed the script file /usr/bin/myopt_keyprog will be executed.

The content of HWSUPP_BUTTON_x_PARAM is passed as a parameter.

Example:

##TODO## example

© 2001-2019 The fli4l-Team - 28 April 2019