micrOSDevToolKit 2.9.8__py3-none-any.whl → 2.9.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of micrOSDevToolKit might be problematic. Click here for more details.
- micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +20 -20
- micrOS/source/LM_oled_ui.py +1 -1
- micrOS/source/LM_system.py +4 -4
- micrOS/source/Notify.py +4 -0
- micrOS/source/Server.py +1 -1
- micrOS/source/Shell.py +3 -3
- micrOS/source/Tasks.py +1 -1
- micrOS/source/Time.py +7 -8
- micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
- micrOS/source/micrOSloader.py +0 -1
- micrOS/source/urequests.py +14 -7
- {micrOSDevToolKit-2.9.8.data → micrOSDevToolKit-2.9.10.data}/scripts/devToolKit.py +10 -0
- {micrOSDevToolKit-2.9.8.dist-info → micrOSDevToolKit-2.9.10.dist-info}/METADATA +14 -4
- {micrOSDevToolKit-2.9.8.dist-info → micrOSDevToolKit-2.9.10.dist-info}/RECORD +51 -47
- {micrOSDevToolKit-2.9.8.dist-info → micrOSDevToolKit-2.9.10.dist-info}/WHEEL +1 -1
- toolkit/DevEnvUSB.py +6 -5
- toolkit/MicrOSDevEnv.py +19 -5
- toolkit/WebRepl.py +73 -0
- toolkit/dashboard_apps/BackupRestore.py +20 -35
- toolkit/dashboard_apps/CCTDemo.py +12 -17
- toolkit/dashboard_apps/CCTTest.py +20 -24
- toolkit/dashboard_apps/CamStream.py +2 -6
- toolkit/dashboard_apps/CatGame.py +14 -16
- toolkit/dashboard_apps/Dimmer.py +11 -21
- toolkit/dashboard_apps/GetVersion.py +11 -19
- toolkit/dashboard_apps/MicrophoneTest.py +1 -6
- toolkit/dashboard_apps/NeoEffectsDemo.py +28 -34
- toolkit/dashboard_apps/NeopixelTest.py +20 -25
- toolkit/dashboard_apps/PresenceTest.py +2 -8
- toolkit/dashboard_apps/RGBTest.py +20 -24
- toolkit/dashboard_apps/RoboArm.py +24 -32
- toolkit/dashboard_apps/SED_test.py +10 -14
- toolkit/dashboard_apps/SensorsTest.py +61 -0
- toolkit/dashboard_apps/SystemTest.py +151 -77
- toolkit/dashboard_apps/Template_app.py +11 -23
- toolkit/dashboard_apps/_app_base.py +34 -0
- toolkit/dashboard_apps/uLightDemo.py +15 -24
- toolkit/lib/micrOSClient.py +16 -11
- toolkit/micrOSlint.py +3 -3
- toolkit/socketClient.py +0 -1
- toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
- toolkit/workspace/precompiled/LM_system.mpy +0 -0
- toolkit/workspace/precompiled/Notify.mpy +0 -0
- toolkit/workspace/precompiled/Shell.mpy +0 -0
- toolkit/workspace/precompiled/Time.mpy +0 -0
- toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
- toolkit/workspace/precompiled/urequests.mpy +0 -0
- toolkit/dashboard_apps/AirQualityBME280.py +0 -36
- toolkit/dashboard_apps/AirQualityDHT22_CO2.py +0 -36
- {micrOSDevToolKit-2.9.8.dist-info → micrOSDevToolKit-2.9.10.dist-info}/LICENSE +0 -0
- {micrOSDevToolKit-2.9.8.dist-info → micrOSDevToolKit-2.9.10.dist-info}/top_level.txt +0 -0
toolkit/DevEnvUSB.py
CHANGED
|
@@ -65,12 +65,13 @@ class USB(Compile):
|
|
|
65
65
|
{'erase': '{esptool_interface} --chip esp32s3 --port {dev} erase_flash',
|
|
66
66
|
'deploy': '{esptool_interface} --chip esp32s3 --port {dev} write_flash -z 0 {micropython}',
|
|
67
67
|
'mpremote_cmd': 'mpremote',
|
|
68
|
-
'cmd_line_info': '[
|
|
68
|
+
'cmd_line_info': '[!HINNT!] Press boot button under connecting the board over USB: enables flash erase'},
|
|
69
69
|
'esp32s3':
|
|
70
70
|
{'erase': '{esptool_interface} --chip esp32s3 --port {dev} erase_flash',
|
|
71
71
|
'deploy': '{esptool_interface} --chip esp32s3 --port {dev} write_flash -z 0 {micropython}',
|
|
72
72
|
'mpremote_cmd': 'mpremote',
|
|
73
|
-
'
|
|
73
|
+
#'ampy_cmd': 'ampy -p {dev} -b 115200 -d 2 {args}',
|
|
74
|
+
'cmd_line_info': '[!HINNT!] Press boot button under connecting board over USB: enables flash erase'},
|
|
74
75
|
'esp32c3':
|
|
75
76
|
{'erase': '{esptool_interface} --chip esp32c3 --port {dev} erase_flash',
|
|
76
77
|
'deploy': '{esptool_interface} --chip esp32c3 --port {dev} --baud 460800 write_flash -z 0x0 {micropython}',
|
|
@@ -239,7 +240,7 @@ class USB(Compile):
|
|
|
239
240
|
# Legacy ampy command (esp32 auto reboot tolerance...)
|
|
240
241
|
command = self.dev_types_and_cmds[self.selected_device_type]['ampy_cmd'].format(dev=device, args=f'put {source}')
|
|
241
242
|
else:
|
|
242
|
-
command = f'{mpremote_cmd} cp {source} :{source}'
|
|
243
|
+
command = f'{mpremote_cmd} fs cp {source} :{source}' # new mpremote <1.24.1
|
|
243
244
|
if ' ' in source:
|
|
244
245
|
self.console("[{}%][SKIP] micrOS deploy via USB: {}".format(percent, command))
|
|
245
246
|
continue
|
|
@@ -614,7 +615,7 @@ class USB(Compile):
|
|
|
614
615
|
# Legacy ampy command (esp32 auto reboot tolerance...)
|
|
615
616
|
command = self.dev_types_and_cmds[self.selected_device_type]['ampy_cmd'].format(dev=device, args='get node_config.json')
|
|
616
617
|
else:
|
|
617
|
-
command = f'{mpremote_cmd} cat node_config.json'
|
|
618
|
+
command = f'{mpremote_cmd} fs cat node_config.json' # new mpremote <1.24.1
|
|
618
619
|
if not self.dry_run:
|
|
619
620
|
exitcode, stdout, stderr = LocalMachine.CommandHandler.run_command(command, shell=True)
|
|
620
621
|
self._archive_node_config()
|
|
@@ -671,7 +672,7 @@ class USB(Compile):
|
|
|
671
672
|
# Legacy ampy command (esp32 auto reboot tolerance...)
|
|
672
673
|
command = self.dev_types_and_cmds[self.selected_device_type]['ampy_cmd'].format(dev=device, args='ls')
|
|
673
674
|
else:
|
|
674
|
-
command = f"{mpremote_cmd} ls"
|
|
675
|
+
command = f"{mpremote_cmd} fs ls" # new mpremote <1.24.1
|
|
675
676
|
if not self.dry_run:
|
|
676
677
|
self.console("CMD: {}".format(command))
|
|
677
678
|
exitcode, stdout, stderr = LocalMachine.CommandHandler.run_command(command, shell=True, debug=False)
|
toolkit/MicrOSDevEnv.py
CHANGED
|
@@ -214,12 +214,22 @@ class MicrOSDevTool(OTA, USB):
|
|
|
214
214
|
_url = hardcoded_manual["task"]["img"]
|
|
215
215
|
hardcoded_manual['task']['img'] = f'<img src="{_url}" alt="tasks" height=150>'
|
|
216
216
|
module_function_dict_html.update(hardcoded_manual)
|
|
217
|
-
module_function_json = json.dumps(module_function_dict_html, indent=4)
|
|
218
217
|
import json2html
|
|
219
218
|
table_attributes = 'border="1" cellspacing="1" cellpadding="5" width="80%"'
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
|
|
220
|
+
sorted_modules_w_data = dict(sorted(module_function_dict_html.items(), key=lambda item: item[0].lower()))
|
|
221
|
+
module_shortcuts = ' | '.join(
|
|
222
|
+
f'<a href="#{mod_name.replace(" ", "_")}">{mod_name}</a>'
|
|
223
|
+
for mod_name in sorted_modules_w_data)
|
|
224
|
+
html_tables = module_shortcuts + "<br><hr><br>"
|
|
225
|
+
for key, value in sorted_modules_w_data.items():
|
|
226
|
+
anchor = key.replace(" ", "_") # Replace spaces with underscores for a valid anchor
|
|
227
|
+
html_tables += f'\n<br><br>\n<h2 id="{anchor}"><a href="#{anchor}">{key}</a></h2>\n'
|
|
228
|
+
html_tables += json2html.json2html.convert(json=value,
|
|
229
|
+
table_attributes=table_attributes,
|
|
230
|
+
clubbing=True,
|
|
231
|
+
escape=False,
|
|
232
|
+
encode=False)
|
|
223
233
|
|
|
224
234
|
# http://corelangs.com/css/table/tablecolor.html
|
|
225
235
|
# http://corelangs.com/css/table/tablecolor.html
|
|
@@ -267,11 +277,15 @@ Logical pin names aka pin map
|
|
|
267
277
|
<li><a href="https://github.com/BxNxM/micrOS/blob/master/micrOS/source/IO_rp2.py" target="_blank">rp2 (experimental)</a></li>
|
|
268
278
|
</ul>
|
|
269
279
|
|
|
280
|
+
<h2>
|
|
281
|
+
Built-in control modules for various peripheries.:
|
|
282
|
+
</h2>
|
|
283
|
+
|
|
270
284
|
"""
|
|
271
285
|
html_body_end = """</body>
|
|
272
286
|
</html>"""
|
|
273
287
|
|
|
274
|
-
html_page = html_body_start +
|
|
288
|
+
html_page = html_body_start + html_tables + html_body_end
|
|
275
289
|
# Write html to file
|
|
276
290
|
with open(static_help_html_path, 'w') as f:
|
|
277
291
|
f.write(html_page)
|
toolkit/WebRepl.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
MYDIR = os.path.dirname(__file__)
|
|
5
|
+
print("Module [WebRepl] path: {} __package__: {} __name__: {} __file__: {}".format(
|
|
6
|
+
sys.path[0], __package__, __name__, MYDIR))
|
|
7
|
+
try:
|
|
8
|
+
from .lib.TerminalColors import Colors
|
|
9
|
+
from .lib.LocalMachine import FileHandler, CommandHandler, SimplePopPushd
|
|
10
|
+
from .socketClient import ConnectionData
|
|
11
|
+
except Exception as e:
|
|
12
|
+
print("Import warning __name__:{}: {}".format(__name__, e))
|
|
13
|
+
from lib.TerminalColors import Colors
|
|
14
|
+
from lib.LocalMachine import FileHandler, CommandHandler, SimplePopPushd
|
|
15
|
+
from socketClient import ConnectionData
|
|
16
|
+
|
|
17
|
+
WEBREPL_DIR = os.path.join(MYDIR, "workspace/webrepl")
|
|
18
|
+
MAKE_HTML_WEBPAGE_PATH = os.path.join(WEBREPL_DIR, "make_html_js.py")
|
|
19
|
+
WEBREPL_WEBPAGE_PATH = os.path.join(WEBREPL_DIR, "webrepl.html")
|
|
20
|
+
|
|
21
|
+
def init_webrepl_frontend():
|
|
22
|
+
webrepldir_handler = SimplePopPushd()
|
|
23
|
+
webrepldir_handler.pushd(WEBREPL_DIR)
|
|
24
|
+
|
|
25
|
+
is_exists, ftype = FileHandler.path_is_exists(MAKE_HTML_WEBPAGE_PATH)
|
|
26
|
+
if is_exists and ftype == 'f':
|
|
27
|
+
print("RUN webrepl/make_html_js.py")
|
|
28
|
+
exitcode, _, stderr = CommandHandler.run_command(f"{sys.executable} {MAKE_HTML_WEBPAGE_PATH}", shell=True)
|
|
29
|
+
webrepldir_handler.popd()
|
|
30
|
+
if exitcode == 0:
|
|
31
|
+
return True
|
|
32
|
+
print(f"Cannot init {MAKE_HTML_WEBPAGE_PATH}: {stderr}")
|
|
33
|
+
return False
|
|
34
|
+
print(f"WEBREPL MAKE MISSING: {MAKE_HTML_WEBPAGE_PATH}")
|
|
35
|
+
return False
|
|
36
|
+
|
|
37
|
+
def open_webrepl_webpage(address=None, port=8266):
|
|
38
|
+
# file:///Users/usrname/micrOS/micrOS/toolkit/workspace/webrepl/webrepl.html#10.0.1.76:8266
|
|
39
|
+
fuid = ''
|
|
40
|
+
if address is None:
|
|
41
|
+
try:
|
|
42
|
+
address, _, fuid, _ = ConnectionData.select_device()
|
|
43
|
+
except KeyboardInterrupt:
|
|
44
|
+
address = None
|
|
45
|
+
|
|
46
|
+
device = "" if address is None else f"#{address}:{port}"
|
|
47
|
+
webrepl_html = f"file://{WEBREPL_WEBPAGE_PATH}{device}"
|
|
48
|
+
is_exists, ftype = FileHandler.path_is_exists(WEBREPL_WEBPAGE_PATH)
|
|
49
|
+
if is_exists and ftype == "f":
|
|
50
|
+
print(f"OPEN {fuid} webrepl {webrepl_html}")
|
|
51
|
+
if sys.platform == "darwin":
|
|
52
|
+
CommandHandler.run_command(f"open '{webrepl_html}'", shell=True)
|
|
53
|
+
elif sys.platform == "win32":
|
|
54
|
+
CommandHandler.run_command(f"start {webrepl_html}", shell=True)
|
|
55
|
+
elif sys.platform == "linux":
|
|
56
|
+
CommandHandler.run_command(f"xdg-open {webrepl_html}", shell=True)
|
|
57
|
+
else:
|
|
58
|
+
print("Unsupported OS")
|
|
59
|
+
return False
|
|
60
|
+
return True
|
|
61
|
+
print(f"{WEBREPL_WEBPAGE_PATH} not exists.")
|
|
62
|
+
return False
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def open_webrepl():
|
|
66
|
+
state = init_webrepl_frontend()
|
|
67
|
+
if state:
|
|
68
|
+
open_webrepl_webpage()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__":
|
|
73
|
+
open_webrepl()
|
|
@@ -5,27 +5,17 @@ import sys
|
|
|
5
5
|
import json
|
|
6
6
|
MYPATH = os.path.dirname(os.path.abspath(__file__))
|
|
7
7
|
BACKUP_DIR = os.path.join(MYPATH, "../user_data/node_config_archive/")
|
|
8
|
-
sys.path.append(os.path.dirname(MYPATH))
|
|
9
|
-
import socketClient
|
|
10
8
|
sys.path.append(os.path.join(MYPATH, '../lib/'))
|
|
11
9
|
from TerminalColors import Colors
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
try:
|
|
12
|
+
from ._app_base import AppBase
|
|
13
|
+
except:
|
|
14
|
+
from _app_base import AppBase
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
if PASSWD is None:
|
|
19
|
-
return ['--dev', DEVICE]
|
|
20
|
-
return ['--dev', DEVICE, '--password', PASSWD]
|
|
16
|
+
CLIENT = None
|
|
21
17
|
|
|
22
18
|
|
|
23
|
-
def run_command(cmd):
|
|
24
|
-
# EDIT YOUR COMMAND
|
|
25
|
-
args = base_cmd() + cmd
|
|
26
|
-
status, answer = socketClient.run(args)
|
|
27
|
-
return status, answer
|
|
28
|
-
|
|
29
19
|
###########################################################
|
|
30
20
|
def _value_type(value):
|
|
31
21
|
value = value.strip()
|
|
@@ -42,15 +32,16 @@ def _value_type(value):
|
|
|
42
32
|
|
|
43
33
|
|
|
44
34
|
def backup():
|
|
45
|
-
|
|
46
|
-
print(f"\
|
|
47
|
-
|
|
35
|
+
device = CLIENT.get_device()
|
|
36
|
+
print(f"\tBackup name format: {device}-<tag>-node_config.json")
|
|
37
|
+
print(f"\t\t tag is optional (press simply enter): {device}-node_config.json")
|
|
38
|
+
backup_tag = input(f"\tFill backup tag for {device}: ").strip()
|
|
48
39
|
backup_tag = "" if len(backup_tag) == 0 else f"-{backup_tag}"
|
|
49
|
-
backup_name = f"{
|
|
40
|
+
backup_name = f"{device}{backup_tag}-node_config.json"
|
|
50
41
|
backup_path = os.path.join(BACKUP_DIR, backup_name)
|
|
51
42
|
print(f"\tBackup path: {backup_path}")
|
|
52
43
|
|
|
53
|
-
status, answer =
|
|
44
|
+
status, answer = CLIENT.run(["conf", "dump"])
|
|
54
45
|
if status:
|
|
55
46
|
configuration = {line.split(":")[0].strip(): _value_type(':'.join(line.split(":")[1:])) for line in answer.strip().split("\n") if ":" in line}
|
|
56
47
|
with open(backup_path, 'w') as f:
|
|
@@ -61,7 +52,8 @@ def backup():
|
|
|
61
52
|
|
|
62
53
|
|
|
63
54
|
def restore():
|
|
64
|
-
|
|
55
|
+
device = CLIENT.get_device()
|
|
56
|
+
print(f"\tRestore backup for: {device}")
|
|
65
57
|
diff_config = {}
|
|
66
58
|
|
|
67
59
|
# SELECT AND LOAD CONFIG BACKUP
|
|
@@ -81,7 +73,7 @@ def restore():
|
|
|
81
73
|
print(f"BACKUP CONFIG DICT:\n{backup_dict}")
|
|
82
74
|
|
|
83
75
|
# LOAD LIVE DEVICE CONFIG - create config diff
|
|
84
|
-
status, answer =
|
|
76
|
+
status, answer = CLIENT.run(["conf", "dump"])
|
|
85
77
|
if not status:
|
|
86
78
|
return f"Cannot load live device config"
|
|
87
79
|
live_configuration = {line.split(":")[0].strip(): _value_type(':'.join(line.split(":")[1:])) for line in answer.strip().split("\n") if ":" in line}
|
|
@@ -103,20 +95,16 @@ def restore():
|
|
|
103
95
|
print(f"{Colors.WARN}SKIP restore...{Colors.NC}")
|
|
104
96
|
return
|
|
105
97
|
|
|
106
|
-
print(f"PACKAGE CONFIG DIFFS...{
|
|
98
|
+
print(f"PACKAGE CONFIG DIFFS...{device}")
|
|
107
99
|
conf_cmd_list = ["conf"]
|
|
108
100
|
for key, value in diff_config.items():
|
|
109
101
|
print(f"\tADD {key} : {value}")
|
|
110
102
|
conf_cmd_list.append(f"{key} {value}")
|
|
111
103
|
conf_cmd_list.append("reboot")
|
|
112
104
|
|
|
113
|
-
verify = input(f"{Colors.WARN}This is BETA feature, are you sure?{Colors.NC} [YY/n]: ")
|
|
114
|
-
if verify != "YY":
|
|
115
|
-
print(f"{Colors.WARN}SKIP restore...{Colors.NC}")
|
|
116
|
-
return
|
|
117
105
|
# Restore
|
|
118
|
-
print(f"APPLY CONFIG DIFFS...{
|
|
119
|
-
status, answer =
|
|
106
|
+
print(f"APPLY CONFIG DIFFS...{device}")
|
|
107
|
+
status, answer = CLIENT.run(conf_cmd_list)
|
|
120
108
|
if status:
|
|
121
109
|
print(f"{Colors.OKGREEN}Backup was successfully restored:{Colors.NC} {backup_path}\nRebooting...")
|
|
122
110
|
else:
|
|
@@ -148,15 +136,12 @@ def app(devfid=None, pwd=None):
|
|
|
148
136
|
send command(s) over socket connection [socketClient.run(args)]
|
|
149
137
|
list load module commands and send in single connection
|
|
150
138
|
"""
|
|
151
|
-
global
|
|
152
|
-
|
|
153
|
-
DEVICE = devfid
|
|
154
|
-
if pwd is not None:
|
|
155
|
-
PASSWD = pwd
|
|
139
|
+
global CLIENT
|
|
140
|
+
CLIENT = AppBase(device=devfid, password=pwd)
|
|
156
141
|
|
|
157
142
|
print(f"{Colors.WARN}Backup & Restore management{Colors.NC}\n")
|
|
158
143
|
while True:
|
|
159
|
-
print(f"{Colors.UNDERLINE}Operations on {
|
|
144
|
+
print(f"{Colors.UNDERLINE}Operations on {CLIENT.get_device()}{Colors.NC}")
|
|
160
145
|
print("\t[1] Backup")
|
|
161
146
|
print("\t[2] Restore")
|
|
162
147
|
print("\t[3] Delete backups")
|
|
@@ -2,38 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
import sys
|
|
5
|
-
import time
|
|
6
5
|
MYPATH = os.path.dirname(os.path.abspath(__file__))
|
|
7
|
-
sys.path.append(os.path.dirname(MYPATH))
|
|
8
|
-
import socketClient
|
|
9
6
|
sys.path.append(os.path.join(MYPATH, '../lib/'))
|
|
10
|
-
from TerminalColors import Colors
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
try:
|
|
9
|
+
from ._app_base import AppBase
|
|
10
|
+
except:
|
|
11
|
+
from _app_base import AppBase
|
|
14
12
|
|
|
13
|
+
CLIENT = None
|
|
15
14
|
|
|
16
|
-
def base_cmd():
|
|
17
|
-
return ['--dev', DEVICE]
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
def app(devfid=None):
|
|
16
|
+
def app(devfid=None, pwd=None):
|
|
21
17
|
"""
|
|
22
18
|
devfid: selected device input
|
|
23
19
|
send command(s) over socket connection [socketClient.run(args)]
|
|
24
20
|
list load module commands and send in single connection
|
|
25
21
|
"""
|
|
26
|
-
global
|
|
27
|
-
|
|
28
|
-
DEVICE = devfid
|
|
22
|
+
global CLIENT
|
|
23
|
+
CLIENT = AppBase(device=devfid, password=pwd)
|
|
29
24
|
|
|
30
|
-
status, answer =
|
|
25
|
+
status, answer = CLIENT.run(['cct white 50 400',
|
|
31
26
|
'cct brightness 50'])
|
|
32
|
-
status, answer =
|
|
27
|
+
status, answer = CLIENT.run(['cct brightness 100', 'cct brightness 20',
|
|
33
28
|
'cct brightness 60'])
|
|
34
|
-
status, answer =
|
|
29
|
+
status, answer = CLIENT.run(['cct white 400 50',
|
|
35
30
|
'cct brightness 100', 'cct brightness 20'])
|
|
36
|
-
status, answer =
|
|
31
|
+
status, answer = CLIENT.run(['cct white 600 700',
|
|
37
32
|
'cct white 50 300'])
|
|
38
33
|
|
|
39
34
|
|
|
@@ -5,18 +5,15 @@ import sys
|
|
|
5
5
|
import time
|
|
6
6
|
import random
|
|
7
7
|
MYPATH = os.path.dirname(os.path.abspath(__file__))
|
|
8
|
-
sys.path.append(os.path.dirname(MYPATH))
|
|
9
|
-
import socketClient
|
|
10
|
-
import time
|
|
11
8
|
sys.path.append(os.path.join(MYPATH, '../lib/'))
|
|
12
9
|
from TerminalColors import Colors
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
try:
|
|
12
|
+
from ._app_base import AppBase
|
|
13
|
+
except:
|
|
14
|
+
from _app_base import AppBase
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
return ['--dev', DEVICE]
|
|
16
|
+
CLIENT = None
|
|
20
17
|
|
|
21
18
|
|
|
22
19
|
def test_random_colors(test_len=8, smooth=False):
|
|
@@ -30,12 +27,12 @@ def test_random_colors(test_len=8, smooth=False):
|
|
|
30
27
|
|
|
31
28
|
# Generate command
|
|
32
29
|
cmd_list_str = " <a> ".join(["{} {} {} {} >json".format(main_function, k[0], k[1], smooth) for k in cct_list])
|
|
33
|
-
args =
|
|
30
|
+
args = [cmd_list_str]
|
|
34
31
|
print("{} Generated command {} - multi message single connection single connection: {} cold warm {}\n{}".format(Colors.HEADER, Colors.NC, main_function, smooth, args))
|
|
35
32
|
|
|
36
33
|
start_t = time.time()
|
|
37
34
|
# SEND MESSSAGE OVER micrOS client
|
|
38
|
-
status, answer =
|
|
35
|
+
status, answer = CLIENT.run(args)
|
|
39
36
|
delta_t = round((time.time() - start_t)/test_len, 1)
|
|
40
37
|
|
|
41
38
|
#Evaluate last message
|
|
@@ -51,14 +48,14 @@ def test_random_colors(test_len=8, smooth=False):
|
|
|
51
48
|
|
|
52
49
|
def test_toogle():
|
|
53
50
|
main_function = 'cct toggle'
|
|
54
|
-
args_on =
|
|
55
|
-
args_toggle =
|
|
51
|
+
args_on = [f'{main_function} True >json']
|
|
52
|
+
args_toggle = [f'{main_function} >json']
|
|
56
53
|
|
|
57
54
|
# SEND MESSSAGE OVER micrOS client
|
|
58
|
-
status, answer =
|
|
55
|
+
status, answer = CLIENT.run(args_on)
|
|
59
56
|
if status and '"S": 1' in answer:
|
|
60
57
|
# SEND MESSSAGE OVER micrOS client
|
|
61
|
-
status, answer =
|
|
58
|
+
status, answer = CLIENT.run(args_toggle)
|
|
62
59
|
if status and '"S": 0' in answer:
|
|
63
60
|
return True, '{} works {}OK{}'.format(main_function, Colors.OK, Colors.NC)
|
|
64
61
|
return False, '{} not works {}NOK{}: {}'.format(main_function, Colors.ERR, Colors.NC, answer)
|
|
@@ -66,24 +63,23 @@ def test_toogle():
|
|
|
66
63
|
|
|
67
64
|
def test_brightness():
|
|
68
65
|
main_function = 'cct brightness'
|
|
69
|
-
args_10 =
|
|
70
|
-
args_50 =
|
|
71
|
-
args_actual_br =
|
|
66
|
+
args_10 = [f'{main_function} 10 >json']
|
|
67
|
+
args_50 = [f'{main_function} 50 >json']
|
|
68
|
+
args_actual_br = [f'{main_function} >json']
|
|
72
69
|
|
|
73
|
-
status, answer =
|
|
70
|
+
status, answer = CLIENT.run(args_10)
|
|
74
71
|
if status:
|
|
75
|
-
status, answer =
|
|
72
|
+
status, answer = CLIENT.run(args_50)
|
|
76
73
|
if status:
|
|
77
|
-
status, answer =
|
|
74
|
+
status, answer = CLIENT.run(args_actual_br)
|
|
78
75
|
if status and "50.0 %" in answer:
|
|
79
76
|
return True, "{} function {}OK{} (50.0 % == {})".format(main_function, Colors.OK, Colors.NC, answer)
|
|
80
77
|
return False, "{} function {}NOK{} (50.0 % == {})".format(main_function, Colors.ERR, Colors.NC, answer)
|
|
81
78
|
|
|
82
79
|
|
|
83
|
-
def app(devfid=None):
|
|
84
|
-
global
|
|
85
|
-
|
|
86
|
-
DEVICE = devfid
|
|
80
|
+
def app(devfid=None, pwd=None):
|
|
81
|
+
global CLIENT
|
|
82
|
+
CLIENT = AppBase(device=devfid, password=pwd)
|
|
87
83
|
|
|
88
84
|
test_pool = { 'Color change test': test_random_colors(test_len=8, smooth=False),
|
|
89
85
|
'Color smooth test': test_random_colors(test_len=4, smooth=True),
|
|
@@ -2,14 +2,10 @@ import sys, os
|
|
|
2
2
|
import subprocess
|
|
3
3
|
MYPATH = os.path.dirname(os.path.abspath(__file__))
|
|
4
4
|
|
|
5
|
-
DEVICE = "node01"
|
|
6
5
|
|
|
7
|
-
def app(devfid=None):
|
|
6
|
+
def app(devfid=None, pwd=None):
|
|
8
7
|
"""
|
|
9
8
|
Wrapper function to start subprocess plotting... (threading limitation)
|
|
10
9
|
"""
|
|
11
|
-
|
|
12
|
-
if devfid is not None:
|
|
13
|
-
DEVICE = devfid
|
|
14
|
-
result = subprocess.run([f'{sys.executable}', os.path.join(MYPATH, '_capture.py'), DEVICE])
|
|
10
|
+
result = subprocess.run([f'{sys.executable}', os.path.join(MYPATH, '_capture.py'), devfid])
|
|
15
11
|
print(result)
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
-
import sys
|
|
5
4
|
import atexit
|
|
6
5
|
from random import randint
|
|
7
6
|
MYPATH = os.path.dirname(os.path.abspath(__file__))
|
|
8
|
-
sys.path.append(os.path.dirname(MYPATH))
|
|
9
|
-
import socketClient
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
try:
|
|
9
|
+
from ._app_base import AppBase
|
|
10
|
+
except:
|
|
11
|
+
from _app_base import AppBase
|
|
12
|
+
|
|
13
|
+
CLIENT = None
|
|
12
14
|
CMD_PIPE_SEP = '<a>'
|
|
13
15
|
SERVO_CENTER_VAL = 77
|
|
14
16
|
|
|
15
17
|
|
|
16
|
-
def base_cmd():
|
|
17
|
-
return ['--dev', DEVICE]
|
|
18
|
-
|
|
19
|
-
|
|
20
18
|
def play_game(iteration=30, devfid=None):
|
|
21
19
|
global CMD_PIPE_SEP
|
|
22
20
|
for _ in range(iteration):
|
|
23
21
|
piped_commands = []
|
|
24
22
|
|
|
25
|
-
args =
|
|
23
|
+
args = ['servo sduty {} '.format(SERVO_CENTER_VAL)]
|
|
26
24
|
print("CMD: {}".format(args))
|
|
27
25
|
args.append(CMD_PIPE_SEP)
|
|
28
26
|
piped_commands += args
|
|
@@ -39,19 +37,19 @@ def play_game(iteration=30, devfid=None):
|
|
|
39
37
|
piped_commands += args
|
|
40
38
|
|
|
41
39
|
print("CMD PIPE: {}".format(piped_commands))
|
|
42
|
-
|
|
40
|
+
CLIENT.run(piped_commands)
|
|
43
41
|
|
|
44
42
|
|
|
45
43
|
def deinit_servo():
|
|
46
44
|
print("DEINIT SERVO, SET TO {} and DEINIT".format(SERVO_CENTER_VAL))
|
|
47
|
-
args =
|
|
48
|
-
|
|
45
|
+
args = ['servo sduty {}'.format(SERVO_CENTER_VAL)]
|
|
46
|
+
CLIENT.run(args)
|
|
47
|
+
|
|
49
48
|
|
|
49
|
+
def app(devfid=None, pwd=None):
|
|
50
|
+
global CLIENT
|
|
51
|
+
CLIENT = AppBase(device=devfid, password=pwd)
|
|
50
52
|
|
|
51
|
-
def app(devfid=None):
|
|
52
|
-
global DEVICE
|
|
53
|
-
if devfid is not None:
|
|
54
|
-
DEVICE = devfid
|
|
55
53
|
atexit.register(deinit_servo)
|
|
56
54
|
play_game()
|
|
57
55
|
deinit_servo()
|
toolkit/dashboard_apps/Dimmer.py
CHANGED
|
@@ -1,43 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
-
import sys
|
|
5
4
|
MYPATH = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
-
sys.path.append(os.path.dirname(MYPATH))
|
|
7
|
-
import socketClient
|
|
8
5
|
|
|
6
|
+
try:
|
|
7
|
+
from ._app_base import AppBase
|
|
8
|
+
except:
|
|
9
|
+
from _app_base import AppBase
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
DEVICE = 'CamLed'
|
|
11
|
+
CLIENT = None
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
def
|
|
15
|
-
|
|
14
|
+
def app(devfid=None, pwd=None, itr=80):
|
|
15
|
+
global CLIENT
|
|
16
|
+
CLIENT = AppBase(device=devfid, password=pwd)
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
def app(devfid=None, itr=80):
|
|
19
|
-
global DEVICE
|
|
20
|
-
if devfid is not None:
|
|
21
|
-
DEVICE = devfid
|
|
22
18
|
# EDIT YOUR COMMAND
|
|
23
19
|
cmd_list = []
|
|
24
20
|
for k in range(0, itr, 2):
|
|
25
21
|
cmd_list += ['dimmer set_value {} smooth=False >json'.format(k)]
|
|
26
|
-
|
|
22
|
+
CLIENT.run(cmd_list)
|
|
27
23
|
|
|
28
24
|
cmd_list = []
|
|
29
25
|
for k in range(itr, 0, -2):
|
|
30
26
|
cmd_list += ['dimmer set_value {} smooth=False >json'.format(k)]
|
|
31
|
-
|
|
27
|
+
CLIENT.run(cmd_list)
|
|
32
28
|
|
|
33
29
|
cmd_list = ['dimmer set_value 300', 'dimmer toggle False', 'dimmer toggle True']
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def execute(cmd_list):
|
|
38
|
-
cmd_args = base_cmd() + cmd_list
|
|
39
|
-
print("DIMMER TEST: {}".format(cmd_args))
|
|
40
|
-
socketClient.run(cmd_args)
|
|
30
|
+
CLIENT.run(cmd_list)
|
|
41
31
|
|
|
42
32
|
|
|
43
33
|
if __name__ == "__main__":
|
|
@@ -4,31 +4,23 @@ import os
|
|
|
4
4
|
import sys
|
|
5
5
|
import time
|
|
6
6
|
MYPATH = os.path.dirname(os.path.abspath(__file__))
|
|
7
|
-
sys.path.append(os.path.dirname(MYPATH))
|
|
8
|
-
import socketClient
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def base_cmd():
|
|
16
|
-
if PASSWD is None:
|
|
17
|
-
return ['--dev', DEVICE]
|
|
18
|
-
return ['--dev', DEVICE, '--password', PASSWD]
|
|
8
|
+
try:
|
|
9
|
+
from ._app_base import AppBase
|
|
10
|
+
except:
|
|
11
|
+
from _app_base import AppBase
|
|
19
12
|
|
|
13
|
+
CLIENT = None
|
|
20
14
|
|
|
21
15
|
|
|
22
16
|
def app(devfid=None, pwd=None):
|
|
23
|
-
global
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if pwd is not None:
|
|
27
|
-
PASSWD = pwd
|
|
17
|
+
global CLIENT
|
|
18
|
+
CLIENT = AppBase(device=devfid, password=pwd)
|
|
19
|
+
|
|
28
20
|
# EDIT YOUR COMMAND
|
|
29
|
-
args =
|
|
30
|
-
status, answer =
|
|
31
|
-
print("[micrOS] {}: {}".format(
|
|
21
|
+
args = ['version']
|
|
22
|
+
status, answer = CLIENT.run(args)
|
|
23
|
+
print("[micrOS] {}: {}".format(CLIENT.get_device(), answer).upper())
|
|
32
24
|
|
|
33
25
|
|
|
34
26
|
if __name__ == "__main__":
|
|
@@ -2,15 +2,10 @@ import sys, os
|
|
|
2
2
|
import subprocess
|
|
3
3
|
MYPATH = os.path.dirname(os.path.abspath(__file__))
|
|
4
4
|
|
|
5
|
-
DEVICE = "node01"
|
|
6
|
-
|
|
7
5
|
|
|
8
6
|
def app(devfid=None, pwd=None):
|
|
9
7
|
"""
|
|
10
8
|
Wrapper function to start subprocess plotting... (threading limitation)
|
|
11
9
|
"""
|
|
12
|
-
|
|
13
|
-
if devfid is not None:
|
|
14
|
-
DEVICE = devfid
|
|
15
|
-
result = subprocess.run([f'{sys.executable}', os.path.join(MYPATH, '_micPlotting.py'), DEVICE])
|
|
10
|
+
result = subprocess.run([f'{sys.executable}', os.path.join(MYPATH, '_micPlotting.py'), devfid])
|
|
16
11
|
print(result)
|