nas_fan_control icon indicating copy to clipboard operation
nas_fan_control copied to clipboard

Missing Default values

Open Linus12 opened this issue 4 years ago • 0 comments

It's been a while since I have coded in Perl, but I think there is a problem with read_config sub in the current version of the script.

In the PID_fan_control.pl script, the sub read_config (line 1307 - 1324) the config file is executed which sets the $config_xxx variables. Those are then assigned to the global variables, or if not defined, the $default_xxx variables are assigned.

The problem that I see is that the $default_xxx values are never assigned, So if one of the variables is missing from the $config_file, the global variable's value is set to null.

I haven't run the scripts to see what happens for each of the cases, but I'm pretty sure that is not something that would be desired.

The complex solution would be to define the $default_xxx values in the global configuration area of the script. The simpler solution, I think, would be to replace the $default_xxx values with the values existing values, i.e. $Kp = $cofig_Kp // $default_Kp; would become: $Kp = $cofig_Kp // $Kp;

I think you ran into this problem because the #hd_fan_duty_start was commented out of the FAN CONFIGURATION section with the comment: # HD fan duty cycle when script starts - defined in config file but it was added back in the DEFAULT VALUES area.

As I said it has been a while since I have walked through a Perl script, so if my assumptions are wrong I apologize for wasting your time.

Linus

Linus12 avatar Mar 28 '20 05:03 Linus12