Skip to content

Commit

Permalink
Created convert_hexadecimal_value_to_decimal function
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerblue77 committed Dec 18, 2024
1 parent 2c44ead commit d53ff72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dell_iDRAC_fan_controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ 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
local HEXADECIMAL_NUMBER=$(printf '0x%02x' $DECIMAL_NUMBER)
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() {
Expand Down

0 comments on commit d53ff72

Please sign in to comment.