#!/usr/bin/env bash # # vim: set sw=2 ts=2 expandtab: # # Copyright (C) 2010 by Multi-Tech Systems # # Author: James Maki # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # VERBOSE=false PLATFORM_NAME=mts-io SYSFS_PLATFORM_DIR=/sys/devices/platform/${PLATFORM_NAME} MTS_IO_CONTROLS_STATUS_LED=false MTS_IO_CONTROLS_LS_LED=false LEDS_GPIO_DIR=/sys/devices/platform/leds-gpio/leds log_info() { if [ "${VERBOSE}" = "true" ]; then echo "info:" "$@" fi } log_error() { echo "error:" "$@" >&2 } store() { if [ $# -ne 2 ]; then log_error "store name value" exit 99 fi local name=${1} local value=${2} log_info "setting ${name} to '${value}'" echo -n "${value}" > ${SYSFS_PLATFORM_DIR}/${name} } show() { if [ $# -ne 1 ]; then log_error "show name" exit 99 fi local name=${1} cat ${SYSFS_PLATFORM_DIR}/${name} } store_trigger() { if [ $# -ne 2 ]; then log_error "store_trigger name value" exit 99 fi local name=${1} local value=${2} log_info "setting ${name} to '${value}'" echo -n "${value}" > ${LEDS_GPIO_DIR}/${name}/trigger } show_trigger() { if [ $# -ne 1 ]; then log_error "show_trigger name" exit 99 fi local name=${1} cat ${LEDS_GPIO_DIR}/${name}/trigger }