8000 Reorganization, making better use of variable substitution, and fix multiple (potential) issues by cgomesu · Pull Request #9 · cgomesu/nanopim4-satahat-fan · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganization, making better use of variable substitution, and fix multiple (potential) issues #9

Merged
merged 20 commits into from
Jan 28, 2022

Conversation

cgomesu
Copy link
Owner
@cgomesu cgomesu commented Jan 25, 2022

This is a comprehensive PR that addresses the following (as also noted in the commit history):

  • It reorganizes the entire code to improve readability and make it easier to edit/customize in the future. One of such changes has to do with the addition of DEFAULT_ variables, which are used in substitutions when the corresponding non-default variable is missing (null). The later and other key variables were moved to the top of the code, which lets users change default behavior and other aspects of the code without going into the details of the implementation and its functions.
  • The indentation was standardized across the code to two spaces.
  • Arg regex was double checked and fixed when missing valid matches.
  • Double quotations were included around variables that could (possibly) have special characters.
  • A few functions that were used only once (configuration, interrupt) were removed and their logic was added directly to the code that made use of them.
  • A message function was created to avoid using echo in multiple contexts (to push values to sysfs and output messages to users) and also facilitate editing the structure of the messages that users see (or logged into syslog).
  • Move pwm-fan.service to its own systemd/ dir to better organize the repo.
  • Included a .gitignore to prevent pushing unwanted files and dirs to the remote.
  • Other minor changes are noted in the commit history.

As usual, the new script was tested with the hardware and software described in the README.md. Other users are welcomed to test and review the code before Jan 28. Otherwise, this PR will be merged into master then.

Include a message() function to output messages to users instead of
calling echo for the same purpose.  This makes a more clear
distinction between echo that is meant to change values in the
sysfs vs. those that are meant to be display messages to users.
Fix for incorrect regex and spacing.

Change the acceptable values for MIN/MAX DC_PERCENT and other
various thresholds.
Reorganization of the order of the functions according to what they
do, instead of purely on alphabetical order.

Simplification of the main logic by removing the config function,
which was just called once (no need for it to be a function).
Replace tabs for two spaces.

Standardize the indentation across the entire script.

Fix minor typos elsewhere.
Add key global variables to the top of the script.  The addition
of DEFAULT_ makes allows changin default variables right at the top
for all variables that can be customized via CLI.  Defaults are now
implemented via variable substitution.
@araynard
Copy link

Hello @cgomesu, I looked at the code and have no comments on the revised coding style.
I also gave it a quick test, checked a couple of different inputs for the argument verification. I didn't fine any issue here.
The reworked error/info messages are rather useful and very clear.
I run the script as a service with my favorite parameters -F 10 -u 45 -U 55 -t 45 -d 10 -T 85 -D 100 and everything behaves as I expect, exactly like before.

@cgomesu
Copy link
Owner Author
cgomesu commented Jan 25, 2022

Hello @cgomesu, I looked at the code and have no comments on the revised coding style. I also gave it a quick test, checked a couple of different inputs for the argument verification. I didn't fine any issue here. The reworked error/info messages are rather useful and very clear. I run the script as a service with my favorite parameters -F 10 -u 45 -U 55 -t 45 -d 10 -T 85 -D 100 and everything behaves as I expect, exactly like before.

thanks again, @araynard . it looks like the new implementation is ready for prime time but I will wait until the end of the week to merge, just in case something new comes up or another user wants to chime in.

@cgomesu cgomesu merged commit 0fc580d into master Jan 28, 2022
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.

2 participants
0