Skip to content

Fix fan speed read#30

Closed
dprital wants to merge 1 commit intomasterfrom
master_fix_fan_speed_read
Closed

Fix fan speed read#30
dprital wants to merge 1 commit intomasterfrom
master_fix_fan_speed_read

Conversation

@dprital
Copy link
Copy Markdown
Owner

@dprital dprital commented Aug 7, 2024

Why I did it

Reading fan speed can lead to the following Error:

ERR pmon#thermalctld: Failed to read from file /var/run/hw-management/thermal/fan1_speed_get - ValueError("invalid literal for int() with base 10: ''")

The error message means that the string provided to int could not be parsed as an integer.

In order to avoid from it, "float" need to be used according to the following example:

int(float('55063.000000'))

    def get_speed(self, idx):
        # 1 based fan index 
        if idx < 1 or idx > self.num_fans: 
            print("Invalid fan index %d\n" % idx)
            return 0

        attr = "fan" + str(idx) + "_input"
        output = pddf_obj.get_attr_name_output("FAN-CTRL", attr)
        if not output:
            return 0

        #mode = output['mode']
        val = output['status'].rstrip()

        if val.isalpha():
            return 0
        else:
            rpm_speed = int(float(val))

        return rpm_speed

    def get_speeds(self):
        num_fan = self.get_num_fan()
        ret = "FAN_INDEX\t\tRPM\n"

        for i in range(1, num_fan+1):
            attr1 = "fan" + str(i) + "_input"
            output = pddf_obj.get_attr_name_output("FAN-CTRL", attr1)
            if not output:
                return ""

            #mode = output['mode']
            val = output['status'].rstrip()

            if val.isalpha():
                frpm = 0
            else:
                frpm = int(val)

            ret += "FAN-%d\t\t\t%d\n" % (i, frpm)

        return ret

While the code at def get_speed(self, idx): is protected, the code in def get_speeds(self): is not.
So the fix should be to change frpm = int(val) into frpm = int(float(val)) in this API

Work item tracking
  • Microsoft ADO (number only):

How I did it

Add float(val)

How to verify it

Run sonic-mgmt tests

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@dprital dprital closed this Dec 4, 2024
dprital pushed a commit that referenced this pull request Oct 12, 2025
…#23531)

Why I did it
Cherry-pick PR sonic-net#22849 to update the Nokia PMON submodule
Update Nokia sonic-platform submodule which includes the commits in branch 202405 and 202503.
Include commits:
05abbf6 [IXR7220-D4] Add port leds functionality
d4f4e4d Update Fan Drawer index in cpld and fix fan target speed
4800083 [mackinac] warnings in general build
c5b3a14 [mackinac] adding prom programming spidev; incidental c++ changes without functional impact
fb37c5a [mackinac] working drivers, pcon, sets devices
0c56adf [x3b]Change access permissions for syseeprom
30cbed3 Using PcieUtil utility to check PCIE status
2b41e41 [x1b] modprobe.d/cpuctl.conf
f234d5a [x3b] wait for pcon driver sysfs ready
054d682 [x3b]Fix PSU status check issue (#31)
f6cb50e [X1b] Add support for Nokia X1b platform (#30)
921f9dd Adds CI to build the debian (#29)
7728ef2 [x4][x1b] consolidating shared cpuctl.ko source code from working x3b version
9f73cf4 Fix the reboot-cause fro upgrading from MFG image
7e057f9 [x3b]Update PSU code to adapt the I2C driver modification
c64aba4 Fixed Watchdog and Others reboot-cause
39215bf moving platform_init script output into journal/syslog
4755411 [x3b] combined write/read
3a13b63 Adding bridge code for x3b x1b x4
53a0696 [x3b]Update fan module and thermal algorithm
8052488 [x3b] adds spi bus
0aac79f [x3b]Fix and update fan and thermal modules
169e0d8 Fix reboot-cause for Kernel Panic when kudmp is enabled
dd003e1 [IXR7220-D4] FW Upgrades Support
e143b5f Revert "Reduce traffic loss when the IMM reboots ungracefully"
f7eec2c Revert "Add dependency for IMM ungracefyl reboot service"
b345006 [Chassis] Conditionalize stuffing QFPGA into reset based on kernel AER setting
4652166 [Chassis] Delete FP ports shutdown at LC ungraceful reset time

Work item tracking
Microsoft ADO (number only):
How I did it
Update Nokia sonic-platform submodule which includes the commits in branch 202405 and 202503.
Include commits:
05abbf6 [IXR7220-D4] Add port leds functionality
d4f4e4d Update Fan Drawer index in cpld and fix fan target speed
4800083 [mackinac] warnings in general build
c5b3a14 [mackinac] adding prom programming spidev; incidental c++ changes without functional impact
fb37c5a [mackinac] working drivers, pcon, sets devices
0c56adf [x3b]Change access permissions for syseeprom
30cbed3 Using PcieUtil utility to check PCIE status
2b41e41 [x1b] modprobe.d/cpuctl.conf
f234d5a [x3b] wait for pcon driver sysfs ready
054d682 [x3b]Fix PSU status check issue (#31)
f6cb50e [X1b] Add support for Nokia X1b platform (#30)
921f9dd Adds CI to build the debian (#29)
7728ef2 [x4][x1b] consolidating shared cpuctl.ko source code from working x3b version
9f73cf4 Fix the reboot-cause fro upgrading from MFG image
7e057f9 [x3b]Update PSU code to adapt the I2C driver modification
c64aba4 Fixed Watchdog and Others reboot-cause
39215bf moving platform_init script output into journal/syslog
4755411 [x3b] combined write/read
3a13b63 Adding bridge code for x3b x1b x4
53a0696 [x3b]Update fan module and thermal algorithm
8052488 [x3b] adds spi bus
0aac79f [x3b]Fix and update fan and thermal modules
169e0d8 Fix reboot-cause for Kernel Panic when kudmp is enabled
dd003e1 [IXR7220-D4] FW Upgrades Support
e143b5f Revert "Reduce traffic loss when the IMM reboots ungracefully"
f7eec2c Revert "Add dependency for IMM ungracefyl reboot service"
b345006 [Chassis] Conditionalize stuffing QFPGA into reset based on kernel AER setting
4652166 [Chassis] Delete FP ports shutdown at LC ungraceful reset time

Signed-off-by: mlok <marty.lok@nokia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant