diff --git a/Dell_iDRAC_fan_controller.sh b/Dell_iDRAC_fan_controller.sh index ae3e8b7..d3b9425 100644 --- a/Dell_iDRAC_fan_controller.sh +++ b/Dell_iDRAC_fan_controller.sh @@ -15,7 +15,7 @@ trap 'graceful_exit' SIGINT SIGQUIT SIGTERM # Check if FAN_SPEED variable is in hexadecimal format. If not, convert it to hexadecimal if [[ $FAN_SPEED == 0x* ]]; then - readonly DECIMAL_FAN_SPEED=$(printf '%d' $FAN_SPEED) + readonly DECIMAL_FAN_SPEED=$(convert_hexadecimal_value_to_decimal $FAN_SPEED) readonly HEXADECIMAL_FAN_SPEED=$FAN_SPEED else readonly DECIMAL_FAN_SPEED=$FAN_SPEED diff --git a/functions.sh b/functions.sh index 2e4c947..a485cae 100644 --- a/functions.sh +++ b/functions.sh @@ -15,7 +15,7 @@ function apply_user_fan_control_profile() { } # Convert first parameter given ($DECIMAL_NUMBER) to hexadecimal -# Usage : convert_decimal_value_to_hexadecimal $DECIMAL_NUMBER +# Usage : convert_decimal_value_to_hexadecimal "$DECIMAL_NUMBER" # Returns : hexadecimal value of DECIMAL_NUMBER function convert_decimal_value_to_hexadecimal() { local DECIMAL_NUMBER=$1 @@ -23,6 +23,15 @@ function convert_decimal_value_to_hexadecimal() { echo $HEXADECIMAL_NUMBER } +# Convert first parameter given ($HEXADECIMAL_NUMBER) to decimal +# Usage : convert_hexadecimal_value_to_decimal "$HEXADECIMAL_NUMBER" +# Returns : decimal value of HEXADECIMAL_NUMBER +function convert_hexadecimal_value_to_decimal() { + local HEXADECIMAL_NUMBER=$1 + local DECIMAL_NUMBER=$(convert_hexadecimal_value_to_decimal $HEXADECIMAL_NUMBER) + echo $DECIMAL_NUMBER +} + # Retrieve temperature sensors data using ipmitool # Usage : retrieve_temperatures $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT $IS_CPU2_TEMPERATURE_SENSOR_PRESENT function retrieve_temperatures() {