Skip to content

Commit 4a21c8c

Browse files
skipfirejgyatesmagomez96notjj
authored
Update fork to 1.16.20 (#3)
* V1.14.12 * V1.14.12 * V1.14.12 * V1.14.12 * V1.14.12 * V1.14.13 * V1.14.14 * V1.14.15 * V1.14.16 * V1.14.16 * V1.14.17 * V1.14.18 * V1.14.18 * V1.14.19 * V1.14.20 * Fix LDAP Remove statically defined search base in code, add support for login with short name, improve error handling * V1.14.21 * V1.14.21 * V1.14.21 * V1.14.22 * 1.14.22 * V1.14.22 * V1.14.22 * V1.14.22 * V1.14.23 * V1.14.23 * V1.14.23 * V1.14.23 * V1.14.23 * V1.14.23 * V1.14.23 * V1.14.23 * V1.14.23 * V1.14.23 * 1.14.24 * V1.14.24 * V1.14.24 * V1.14.24 * V1.14.25 * V1.14.25 * V1.14.26 * V1.14.27 * V1.14.27 * V1.14.27 * V1.14.47 * V1.14.47 * V1.14.27 * V1.14.47 * V1.14.27 * V1.14.27 * V1.14.28 * V2.14.28 * V1.14.28 * V1.14.29 * V1.14.30 * V1.14.30 * V1.14.30 * V1.14.31 * V1.14.31 * V1.14.31 * V1.14.31 * V1.14.31 * V1.14.32 * V1.14.32 * V1.14.33 * V1.14.33 * 1.14.33 * V1.15.00 * V1.15.00 * V1.15.00 * V1.15.01 * V1.15.02 * V1.15.02 * V1.15.02 * V1.15.02 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.03 * V1.15.04 * V1.15.04 * V1.15.05 * V1.15.05 * V1.15.05 * V1.15.05 * V1.15.05 * V1.15.05 * V1.15.05 * V1.15.05 * V1.15.06 * V1.15.06 * V1.15.06 * V1.15.06 * V1.15.07 * V1.15.07 * V1.15.08 * V1.15.09 * V1.15.09 * V1.15.09 * V1.15.09 * V1.15.09 * V1.15.09 * V1.15.09 * V1.15.09 * PR Template Added * V1.15.09 * V1.15.09 * V1.15.09 * V1.15.09 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.10 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V1.15.11 * V2.15.11 * V1.15.11 * V1.15.11 * V1.15.12 * V1.15.12 * V1.15.12 * V1.15.12 * V1.15.13 * V1.15.13 * V1.15.13 * V1.15.14 * V1.15.14 * V1.15.14 * Add functionality to allow using I2C channels other than 1 or 2, by detectecting available I2C channels in /dev * bug fixes modified: genmonlib/gaugediy.py * V1.15.15 * V1.15.16 * V1.15.16 * V1.15.16 * V1.15.16 * V1.15.16 * V1.15.16 * V1.15.16 * V1.15.16 * V1.15.16 * V1.15.17 * V1.15.17 * V1.15.17 * V1.15.17 * - Add missing 'self' variable to on_disconnect - Modify logging level to Info on connect/disconnect for easier tracking of state * V1.15.18 * V1.15.18 * V1.15.19 * V1.15.19 * V1.15.19 * V1.15.19 * Fix Security Vulnerability Fix security vulnerability in checking for LDAP group memberships * V1.15.19 * V1.16.0 * V1.16.0 * LDAP Updates Updated sample config to clarify that LDAPS is supported. Improved LDAP session cleanup * LDAP Updates Code consistency * V1.16.0 * V1.15.19 * V1.15.19 * V1.16.00 * V1.16.00 * V1.16.00 * Fix Typo in Tooltips Goolge Authenticator -> Google Authenticator * V1.16.00 * V1.16.00 * V1.16.00 Co-authored-by: jgyates <jgyates@users.noreply.github.com> Co-authored-by: Matthew Gomez <magomez96@gmail.com> Co-authored-by: = <=> Co-authored-by: JJ Crawford <jj@mu.org>
1 parent a08c499 commit 4a21c8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+10480
-3415
lines changed

.github/ISSUE_TEMPLATE.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Use the template below if you have an issue or want to report a bug. If you have a question or a feature request you can ignore the questions below.
1+
Use the template below if you have an issue or want to report a bug. If you have a question or a feature request you can ignore the questions below. This is a template so feel free to remove any of this text. Try to include the info below when applicable.
22

33
***NOTE:*** If you are having issues with your serial connection, please read this page before posting:
44

@@ -8,7 +8,9 @@ If you are having other issues, please see the following page:
88

99
https://github.com/jgyates/genmon/wiki/3.5---General-Troubleshooting
1010

11-
If you need to send you logs and registers to the developer, if you email is setup and working properly you can click send your logs on the About page in the web interface.
11+
You can search past issues by removing the "is:open" keywords from the search window and adding any keywords that are relevant to your issue.
12+
13+
If you need to send you logs and registers to the developer, if your email is setup and working properly you can click send your logs on the About page in the web interface.
1214

1315
### Expected Behavior
1416

@@ -29,5 +31,5 @@ If you need to send you logs and registers to the developer, if you email is set
2931
### Your Environment
3032

3133
- Generator Model: {Please write here}
32-
- Generator Registers: Submit via the About page
34+
- Genmon Logs: Submit via the About page
3335
- Genmon Version: {Please write here}

.github/PULL_REQUEST_TEMPLATE.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Pull Request Template
2+
3+
## Description
4+
5+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
6+
7+
Fixes # (issue)
8+
9+
## Type of change
10+
11+
Please delete options that are not relevant.
12+
13+
- [ ] Bug fix (non-breaking change which fixes an issue)
14+
- [ ] New feature (non-breaking change which adds functionality)
15+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
16+
- [ ] This change requires a documentation update
17+
18+
## How Has This Been Tested?
19+
20+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
21+
22+
- [ ] Test A
23+
- [ ] Test B
24+
25+
**Test Configuration**:
26+
* Firmware version:
27+
* Hardware:
28+
29+
## Checklist:
30+
31+
- [ ] Are any new libaries required and have they been added to the install scripts
32+
- [ ] My code follows the existing code style and formatting of this project
33+
- [ ] I have performed a self-review of my own code
34+
- [ ] I have reasonably commented my code, particularly in hard-to-understand areas
35+
- [ ] I have made corresponding changes to the documentation
36+
- [ ] My changes generate no new warnings or errors
37+
- [ ] I have checked my code and corrected any misspellings
38+
- [ ] I have tested any python code on 2.7 and 3.x
39+
- [ ] I have tested any javascript on most popular browsers for compatiblity

ClientInterface.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,7 @@ def signal_handler(signal, frame):
5858
# Set the signal handler
5959
signal.signal(signal.SIGINT, signal_handler)
6060

61-
startcount = 0
62-
while startcount <= 2:
63-
try:
64-
MyClientInterface = ClientInterface(host = address, port = port, log = log)
65-
break
66-
except Exception as e1:
67-
startcount += 1
68-
if startcount >= 2:
69-
console.error("Error: genmon not loaded.")
70-
sys.exit(1)
71-
time.sleep(1)
72-
continue
73-
61+
MyClientInterface = ClientInterface(host = address, port = port, log = log)
7462

7563
try:
7664

Diagrams/gauge/gauge01.jpg

22.1 KB
Loading

Diagrams/gauge/gauge02.jpg

30.9 KB
Loading

Diagrams/gauge/gauge03.jpg

43.7 KB
Loading

Diagrams/gauge/gauge04.jpg

25.3 KB
Loading

Diagrams/gauge/gauge05.jpg

191 KB
Loading

Diagrams/gauge/gauge06.jpg

50.4 KB
Loading

Diagrams/gauge/gauge07.jpg

993 KB
Loading

Diagrams/propane_fuel_gauge.png

113 KB
Loading

OtherApps/DIY2TankSensorCalibrate.py

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
#!/usr/bin/env python
2+
#------------------------------------------------------------
3+
# FILE: DIY2TankSensorCalibrate.py
4+
# PURPOSE: Get calibration values for the Infinieon TLE5501 E0001 TMR-based angle sensor
5+
# used in gentankdiy2.py and write them in gentankdiy2.conf file.
6+
#
7+
# AUTHOR: Curtis Case @curtis1757
8+
# DATE: 10-Oct-2020
9+
# Free software. Use at your own risk.
10+
# MODIFICATIONS:
11+
#------------------------------------------------------------
12+
import time, sys, os, getopt, math
13+
14+
# This program assumes the directory genmonlib is one level higher
15+
sys.path.append(os.path.dirname(sys.path[0])) # Adds higher directory to python modules path.
16+
17+
try:
18+
from genmonlib.myconfig import MyConfig
19+
from genmonlib.gaugediy import GaugeDIY2
20+
from genmonlib.mylog import SetupLogger
21+
from genmonlib.mycommon import MyCommon
22+
23+
except Exception as e1:
24+
print("\n\nThis program requires the modules located in the genmonlib directory in the github repository.\n")
25+
print("Please see the project documentation at https://github.com/jgyates/genmon.\n")
26+
print("Error: " + str(e1))
27+
sys.exit(2)
28+
29+
#---------------------input_float-----------------------------------------------
30+
def input_float(prompt, ndec = 2):
31+
"""Get a float number from the user"""
32+
33+
while True:
34+
try:
35+
s = input(prompt)
36+
v = float(s)
37+
38+
return round(v, ndec)
39+
except Exception as e1:
40+
if s == "": return None
41+
print("{0}, try again".format(e1))
42+
43+
#---------------------check_ap_table--------------------------------------------
44+
def check_ap_table():
45+
"""Checks to mke sure the angle-percentage table is linear"""
46+
47+
if gauge.ap_table != None and len(gauge.ap_table) > 2:
48+
increasing = gauge.ap_table[0][0] < gauge.ap_table[-1][0]
49+
for i in range(1,len(gauge.ap_table)):
50+
if (increasing and gauge.ap_table[i-1][0] < gauge.ap_table[i][0]) or \
51+
(not increasing and gauge.ap_table[i-1][0] < gauge.ap_table[i][0]):
52+
53+
print(("error in calibration table at row {0}, {1:.2f}" +
54+
" is {2} than {3:.2f}\n" +
55+
"value not added to calibration table.").format(i, gauge.ap_table[i-1][0], 'greater' if increasing else 'less', gauge.ap_table[i][0]))
56+
57+
guage.ap_table.pop(i)
58+
59+
#---------------------show_ap_table---------------------------------------------
60+
def show_ap_table():
61+
if gauge.ap_table != None and len(gauge.ap_table) > 0:
62+
i = 1
63+
print("{0:>6s}{1:>8s}{2:>8s}".format('Index', 'Angle', 'Percent'))
64+
for a, p in gauge.ap_table:
65+
print("{0:6d}{1:8.2f}{2:8.1f}".format(i, a, p))
66+
i+=1
67+
else:
68+
print("calibration table is empty")
69+
70+
#---------------------main------------------------------------------------------
71+
if __name__=='__main__':
72+
HelpStr = """python DIY2TankSensorCalibrate.py [OPTIONS] ...
73+
74+
Usage: python DIY2TankSensorCalibrate.py [OPTION] ...
75+
76+
Gets information to modify 'gentankDIY2.conf' file
77+
78+
Valid [OPTIONS] are:
79+
-c <config file path>
80+
"""
81+
try:
82+
console = SetupLogger("DIY2_console", log_file = "", stream = True)
83+
opts, args = getopt.getopt(sys.argv[1:],"hc:",["help","config="])
84+
85+
except getopt.GetoptError:
86+
print (HelpStr)
87+
sys.exit(2)
88+
89+
configfilename = "gentankdiy.conf"
90+
configfile = os.path.join(MyCommon.DefaultConfPath, configfilename)
91+
92+
for opt, arg in opts:
93+
if opt == '-h':
94+
print (HelpStr)
95+
sys.exit()
96+
elif opt in ("-c"):
97+
configfile = os.path.join(arg, configfilename)
98+
99+
100+
if not os.path.isfile(configfile):
101+
console.error("Missing config file: {0}".format(configfile))
102+
sys.exit(1)
103+
104+
console.error("Using config file %s" % configfile)
105+
106+
config = MyConfig(filename = configfile, section = 'gentankdiy')
107+
108+
gauge = GaugeDIY2(config, console = console, log = console)
109+
110+
if not gauge.InitADC():
111+
console.error("Error initializing ADC, exiting")
112+
exit(2)
113+
114+
average_n = 10
115+
116+
while True:
117+
print("""
118+
Enter command:
119+
1 - Show current calibration table
120+
2 - Clear all entries from calibration table
121+
3 - Enter lowest and highest readings possible
122+
4 - Add new entry(s) to calibration table
123+
5 - Delete entry(s) in calibration table
124+
6 - Save '{configfile}'
125+
7 - Show current dial reading using current calibration table
126+
0 - exit
127+
""")
128+
c = str(input("Command: ")).strip()
129+
130+
if c == '1':
131+
show_ap_table()
132+
133+
elif c == '2':
134+
gauge.ap_table.clear()
135+
136+
elif c == '3':
137+
p = input_float("Set dial as low as possible and enter the percent value (typically 5%)\n" +
138+
"when enter is pressed after the value is entered the dial angle will be read and recorded: ")
139+
if p != None:
140+
a = gauge.GetAvgGaugeAngle(average_n, 1.0, True)
141+
gauge.ap_table = [(a,p)]
142+
143+
p = input_float("Set dial as high as possible and enter the percent value (typically 100%)\n" +
144+
"when enter is pressed after the value is entered the dial angle will be read and recorded: ")
145+
if p != None:
146+
if p < gauge.ap_table[0][1]:
147+
print("Error: the low entry must be less than the high entry, {0:.1f} is not less than {1:.1f}".format(gauge.ap_table[0][1]), p)
148+
else:
149+
a = gauge.GetAvgGaugeAngle(average_n, 1.0, True)
150+
gauge.ap_table.append((a,p))
151+
152+
print()
153+
show_ap_table()
154+
print("Next use option 4 to add calibration points between {0:.1f} and {1:.1f}".format(gauge.ap_table[0][1], gauge.ap_table[1][1]))
155+
print("suggested to use major markings on dial, ie 10, 20, 30, 40, 50, 60, 70")
156+
157+
elif c == '4':
158+
if gauge.ap_table == None or len(gauge.ap_table) < 2:
159+
print("must use option 3 first to set lowest and highest dial values")
160+
else:
161+
if len(gauge.ap_table) >= gauge.MAX_AP_TABLE:
162+
print("already maximum of {0} entries, delete some (5) or all (2)".format(gauge.MAX_AP_TABLE))
163+
else:
164+
while len(gauge.ap_table) < gauge.MAX_AP_TABLE:
165+
while True:
166+
p = input_float("Set dial to desired value to read the associated angle for\n" +
167+
"(or just 'Return' to stop entering values). When enter is pressed \n" +
168+
"after a value is entered the dial angle will be read and recorded: ")
169+
if p == None: break
170+
if p < 0.0 or p > 100.0:
171+
print("value must be between 0 and 100")
172+
else:
173+
break
174+
175+
if p == None: break
176+
177+
a = gauge.GetAvgGaugeAngle(average_n, 1.0, True)
178+
gauge.ap_table.append((a,p))
179+
180+
gauge.ap_table.sort(key = lambda x: x[1])
181+
182+
check_ap_table()
183+
184+
print("\nadded angle {0:.2f} to represent dial value {1:.1f}% to calibration table\n".format(a, p))
185+
186+
elif c == '5':
187+
show_ap_table()
188+
if gauge.ap_table != None and len(gauge.ap_table) > 0:
189+
while True:
190+
i = input_float("Enter Index of entry to be deleted:")
191+
if i == None: break
192+
if i >= 1 and i <= len(gauge.ap_table):
193+
gauge.ap_table.pop(i-1)
194+
print("updated calibration table:")
195+
show_ap_table()
196+
else:
197+
print("Index must be from 1 to {0}, try again".format(len(gauge.ap_table)))
198+
199+
elif c == '6':
200+
if gauge.ap_table != None:
201+
if len(gauge.ap_table) < 2:
202+
print("must have at least 2 entries in calibration table, file not written")
203+
else:
204+
for i in range(1,gauge.MAX_AP_TABLE+1):
205+
config.WriteValue("ang_pct_pnt_{0}".format(i), "", remove = True)
206+
207+
i = 1
208+
for a, p in gauge.ap_table:
209+
config.WriteValue("ang_pct_pnt_{0}".format(i), "{0:8.2f},{1:6.1f}".format(a, p))
210+
i += 1
211+
212+
print("wrote {0} calibration entries in '{1}'".format(len(gauge.ap_table), configfile))
213+
214+
elif c == '7':
215+
a = gauge.read_gauge_angle()
216+
print("Current dial angle is {0:.2f} degrees which is {1:.1f}%".format(a, gauge.convert_angle_to_percent(a)))
217+
218+
elif c == '0':
219+
sys.exit(0)
220+
else:
221+
print("unknown command '{0}'".format(c))
222+
223+
sys.exit(1)

0 commit comments

Comments
 (0)