micrOSDevToolKit 2.11.0__py3-none-any.whl → 2.13.0__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 +25 -25
- micrOS/source/Common.py +34 -14
- micrOS/source/Config.py +7 -7
- micrOS/source/Debug.py +9 -9
- micrOS/source/Espnow.py +6 -6
- micrOS/source/Files.py +5 -3
- micrOS/source/Hooks.py +5 -5
- micrOS/source/InterConnect.py +5 -5
- micrOS/source/Interrupts.py +2 -2
- micrOS/source/LM_dashboard_be.py +2 -2
- micrOS/source/LM_neomatrix.py +42 -12
- micrOS/source/LM_pacman.py +16 -3
- micrOS/source/Logger.py +1 -1
- micrOS/source/Network.py +6 -6
- micrOS/source/Notify.py +2 -2
- micrOS/source/Scheduler.py +5 -5
- micrOS/source/Server.py +6 -6
- micrOS/source/Shell.py +4 -4
- micrOS/source/Tasks.py +13 -13
- micrOS/source/Time.py +7 -7
- micrOS/source/Types.py +2 -2
- micrOS/source/Web.py +20 -13
- micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Debug.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/micrOS.py +5 -5
- micrOS/source/micrOSloader.py +6 -6
- micrOS/source/urequests.py +4 -4
- {microsdevtoolkit-2.11.0.dist-info → microsdevtoolkit-2.13.0.dist-info}/METADATA +23 -22
- {microsdevtoolkit-2.11.0.dist-info → microsdevtoolkit-2.13.0.dist-info}/RECORD +84 -79
- toolkit/DevEnvCompile.py +20 -15
- toolkit/DevEnvOTA.py +29 -8
- toolkit/DevEnvUSB.py +47 -10
- toolkit/MicrOSDevEnv.py +10 -2
- toolkit/MicrosFiles.py +26 -0
- toolkit/lib/LocalMachine.py +6 -1
- toolkit/lib/file_extensions.py +9 -3
- toolkit/micrOSlint.py +3 -1
- toolkit/workspace/precompiled/Common.cpython-312.pyc +0 -0
- toolkit/workspace/precompiled/Common.mpy +0 -0
- toolkit/workspace/precompiled/Config.mpy +0 -0
- toolkit/workspace/precompiled/Debug.mpy +0 -0
- toolkit/workspace/precompiled/Espnow.mpy +0 -0
- toolkit/workspace/precompiled/Files.mpy +0 -0
- toolkit/workspace/precompiled/Hooks.mpy +0 -0
- toolkit/workspace/precompiled/InterConnect.mpy +0 -0
- toolkit/workspace/precompiled/Interrupts.mpy +0 -0
- toolkit/workspace/precompiled/LM_dashboard_be.py +2 -2
- toolkit/workspace/precompiled/LM_neomatrix.mpy +0 -0
- toolkit/workspace/precompiled/LM_pacman.mpy +0 -0
- toolkit/workspace/precompiled/Logger.cpython-312.pyc +0 -0
- toolkit/workspace/precompiled/Logger.mpy +0 -0
- toolkit/workspace/precompiled/Network.mpy +0 -0
- toolkit/workspace/precompiled/Notify.mpy +0 -0
- toolkit/workspace/precompiled/Scheduler.mpy +0 -0
- toolkit/workspace/precompiled/Server.cpython-312.pyc +0 -0
- toolkit/workspace/precompiled/Server.mpy +0 -0
- toolkit/workspace/precompiled/Shell.mpy +0 -0
- toolkit/workspace/precompiled/Tasks.mpy +0 -0
- toolkit/workspace/precompiled/Time.mpy +0 -0
- toolkit/workspace/precompiled/Types.mpy +0 -0
- toolkit/workspace/precompiled/Web.mpy +0 -0
- toolkit/workspace/precompiled/micrOS.mpy +0 -0
- toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
- toolkit/workspace/precompiled/urequests.mpy +0 -0
- /micrOS/source/{dashboard.html → web/dashboard.html} +0 -0
- /micrOS/source/{index.html → web/index.html} +0 -0
- /micrOS/source/{uapi.js → web/uapi.js} +0 -0
- /micrOS/source/{udashboard.js → web/udashboard.js} +0 -0
- /micrOS/source/{ustyle.css → web/ustyle.css} +0 -0
- /micrOS/source/{uwidgets.js → web/uwidgets.js} +0 -0
- /micrOS/source/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
- {microsdevtoolkit-2.11.0.data → microsdevtoolkit-2.13.0.data}/scripts/devToolKit.py +0 -0
- {microsdevtoolkit-2.11.0.dist-info → microsdevtoolkit-2.13.0.dist-info}/WHEEL +0 -0
- {microsdevtoolkit-2.11.0.dist-info → microsdevtoolkit-2.13.0.dist-info}/licenses/LICENSE +0 -0
- {microsdevtoolkit-2.11.0.dist-info → microsdevtoolkit-2.13.0.dist-info}/top_level.txt +0 -0
- /toolkit/workspace/precompiled/{dashboard.html → web/dashboard.html} +0 -0
- /toolkit/workspace/precompiled/{index.html → web/index.html} +0 -0
- /toolkit/workspace/precompiled/{uapi.js → web/uapi.js} +0 -0
- /toolkit/workspace/precompiled/{udashboard.js → web/udashboard.js} +0 -0
- /toolkit/workspace/precompiled/{ustyle.css → web/ustyle.css} +0 -0
- /toolkit/workspace/precompiled/{uwidgets.js → web/uwidgets.js} +0 -0
- /toolkit/workspace/precompiled/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"Time.py": [
|
|
4
|
-
9.
|
|
4
|
+
9.26,
|
|
5
5
|
6
|
|
6
6
|
],
|
|
7
7
|
"Files.py": [
|
|
8
|
-
9.
|
|
8
|
+
9.38,
|
|
9
9
|
8
|
|
10
10
|
],
|
|
11
11
|
"micrOSloader.py": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
3
|
|
22
22
|
],
|
|
23
23
|
"Web.py": [
|
|
24
|
-
9.
|
|
24
|
+
9.64,
|
|
25
25
|
1
|
|
26
26
|
],
|
|
27
27
|
"Tasks.py": [
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
4
|
|
54
54
|
],
|
|
55
55
|
"Common.py": [
|
|
56
|
-
9.
|
|
56
|
+
9.74,
|
|
57
57
|
34
|
|
58
58
|
],
|
|
59
59
|
"InterConnect.py": [
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
0
|
|
94
94
|
],
|
|
95
95
|
"urequests.py": [
|
|
96
|
-
|
|
96
|
+
9.31,
|
|
97
97
|
5
|
|
98
98
|
],
|
|
99
99
|
"LM_roboarm.py": [
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
1
|
|
106
106
|
],
|
|
107
107
|
"LM_pacman.py": [
|
|
108
|
-
8.
|
|
108
|
+
8.92,
|
|
109
109
|
0
|
|
110
110
|
],
|
|
111
111
|
"LM_genIO.py": [
|
|
@@ -113,11 +113,11 @@
|
|
|
113
113
|
0
|
|
114
114
|
],
|
|
115
115
|
"LM_oled_ui.py": [
|
|
116
|
-
8.
|
|
116
|
+
8.73,
|
|
117
117
|
0
|
|
118
118
|
],
|
|
119
119
|
"LM_system.py": [
|
|
120
|
-
8.
|
|
120
|
+
8.36,
|
|
121
121
|
5
|
|
122
122
|
],
|
|
123
123
|
"LM_robustness.py": [
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
0
|
|
142
142
|
],
|
|
143
143
|
"LM_oled.py": [
|
|
144
|
-
9.
|
|
144
|
+
9.23,
|
|
145
145
|
4
|
|
146
146
|
],
|
|
147
147
|
"LM_tinyrgb.py": [
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
0
|
|
154
154
|
],
|
|
155
155
|
"LM_bme280.py": [
|
|
156
|
-
8.
|
|
156
|
+
8.09,
|
|
157
157
|
0
|
|
158
158
|
],
|
|
159
159
|
"LM_buzzer.py": [
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
0
|
|
174
174
|
],
|
|
175
175
|
"LM_oled_sh1106.py": [
|
|
176
|
-
8.
|
|
176
|
+
8.89,
|
|
177
177
|
2
|
|
178
178
|
],
|
|
179
179
|
"LM_haptic.py": [
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
0
|
|
186
186
|
],
|
|
187
187
|
"LM_neopixel.py": [
|
|
188
|
-
7.
|
|
188
|
+
7.66,
|
|
189
189
|
2
|
|
190
190
|
],
|
|
191
191
|
"LM_cct.py": [
|
|
@@ -237,11 +237,11 @@
|
|
|
237
237
|
0
|
|
238
238
|
],
|
|
239
239
|
"LM_sound_event.py": [
|
|
240
|
-
8.
|
|
240
|
+
8.49,
|
|
241
241
|
0
|
|
242
242
|
],
|
|
243
243
|
"LM_oledui.py": [
|
|
244
|
-
|
|
244
|
+
8.34,
|
|
245
245
|
0
|
|
246
246
|
],
|
|
247
247
|
"LM_espnow.py": [
|
|
@@ -253,11 +253,11 @@
|
|
|
253
253
|
0
|
|
254
254
|
],
|
|
255
255
|
"LM_OV2640.py": [
|
|
256
|
-
9.
|
|
256
|
+
9.19,
|
|
257
257
|
0
|
|
258
258
|
],
|
|
259
259
|
"LM_rgb.py": [
|
|
260
|
-
8.
|
|
260
|
+
8.95,
|
|
261
261
|
1
|
|
262
262
|
],
|
|
263
263
|
"LM_distance.py": [
|
|
@@ -281,11 +281,11 @@
|
|
|
281
281
|
4
|
|
282
282
|
],
|
|
283
283
|
"LM_mqtt_pro.py": [
|
|
284
|
-
9.
|
|
284
|
+
9.44,
|
|
285
285
|
0
|
|
286
286
|
],
|
|
287
287
|
"LM_trackball.py": [
|
|
288
|
-
8.
|
|
288
|
+
8.49,
|
|
289
289
|
1
|
|
290
290
|
],
|
|
291
291
|
"LM_dashboard_be.py": [
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
2
|
|
306
306
|
],
|
|
307
307
|
"LM_i2s_mic.py": [
|
|
308
|
-
8.
|
|
308
|
+
8.37,
|
|
309
309
|
2
|
|
310
310
|
],
|
|
311
311
|
"LM_sdcard.py": [
|
|
@@ -313,17 +313,17 @@
|
|
|
313
313
|
0
|
|
314
314
|
],
|
|
315
315
|
"LM_neomatrix.py": [
|
|
316
|
-
8.
|
|
316
|
+
8.8,
|
|
317
317
|
0
|
|
318
318
|
]
|
|
319
319
|
},
|
|
320
320
|
"summary": {
|
|
321
321
|
"core": [
|
|
322
|
-
|
|
322
|
+
3751,
|
|
323
323
|
24
|
|
324
324
|
],
|
|
325
325
|
"load": [
|
|
326
|
-
|
|
326
|
+
9449,
|
|
327
327
|
55
|
|
328
328
|
],
|
|
329
329
|
"core_dep": [
|
|
@@ -334,8 +334,8 @@
|
|
|
334
334
|
true,
|
|
335
335
|
5
|
|
336
336
|
],
|
|
337
|
-
"core_score": 9.
|
|
338
|
-
"load_score": 8.
|
|
339
|
-
"version": "2.
|
|
337
|
+
"core_score": 9.23,
|
|
338
|
+
"load_score": 8.39,
|
|
339
|
+
"version": "2.13.0-0"
|
|
340
340
|
}
|
|
341
341
|
}
|
micrOS/source/Common.py
CHANGED
|
@@ -3,7 +3,7 @@ micrOS Load Module programming Official API-s
|
|
|
3
3
|
Designed by Marcell Ban aka BxNxM
|
|
4
4
|
"""
|
|
5
5
|
from Server import Server, WebCli
|
|
6
|
-
from Debug import
|
|
6
|
+
from Debug import syslog as debug_syslog, console_write
|
|
7
7
|
from Logger import logger, log_get
|
|
8
8
|
from Files import OSPath, path_join
|
|
9
9
|
from microIO import resolve_pin
|
|
@@ -80,7 +80,7 @@ def notify(text=None) -> bool:
|
|
|
80
80
|
try:
|
|
81
81
|
out = Notify.notify(text)
|
|
82
82
|
except Exception as e:
|
|
83
|
-
|
|
83
|
+
debug_syslog(f"[ERR] Notify: {e}")
|
|
84
84
|
out = str(e)
|
|
85
85
|
if out is not None and (out.startswith('Sent') or out.endswith('disabled')):
|
|
86
86
|
return True
|
|
@@ -136,8 +136,8 @@ def data_logger(f_name, data=None, limit=12, msgobj=None):
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
def syslog(msg):
|
|
139
|
-
""" Wrapper of
|
|
140
|
-
return
|
|
139
|
+
""" Wrapper of debug_syslog """
|
|
140
|
+
return debug_syslog(f"{msg}")
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
def console(msg):
|
|
@@ -155,6 +155,16 @@ def data_dir(f_name=None):
|
|
|
155
155
|
return root_path
|
|
156
156
|
return path_join(root_path, f_name)
|
|
157
157
|
|
|
158
|
+
def web_dir(f_name=None):
|
|
159
|
+
"""
|
|
160
|
+
Access for web dir path
|
|
161
|
+
:param f_name: if given, returns full path, otherwise returns web dir root path
|
|
162
|
+
"""
|
|
163
|
+
root_path = OSPath.WEB
|
|
164
|
+
if f_name is None:
|
|
165
|
+
return root_path
|
|
166
|
+
return path_join(root_path, f_name)
|
|
167
|
+
|
|
158
168
|
#####################################################################################
|
|
159
169
|
# CHANNEL: SIGNAL GENERATORS #
|
|
160
170
|
#####################################################################################
|
|
@@ -238,25 +248,27 @@ class AnimationPlayer:
|
|
|
238
248
|
Generic async animation (generator) player.
|
|
239
249
|
"""
|
|
240
250
|
|
|
241
|
-
def __init__(self, animation:callable=None, tag:str=None, batch_draw:bool=False, batch_size:int=None):
|
|
251
|
+
def __init__(self, animation:callable=None, tag:str=None, batch_draw:bool=False, batch_size:int=None, loop:bool=True):
|
|
242
252
|
"""
|
|
243
253
|
Initialize the AnimationPlayer with an optional animation.
|
|
244
254
|
:param animation: Function to GENERATE animation data
|
|
245
255
|
:param tag: Optional task tag for micro_task management.
|
|
246
256
|
:param batch_draw: If True - draw in batches
|
|
247
257
|
:param batch_size: Number of pixels per batch when drawing
|
|
258
|
+
:param loop: If True - loop the animation (default)
|
|
248
259
|
"""
|
|
249
260
|
self.animation:callable = None
|
|
250
261
|
self.batch_draw:bool = batch_draw
|
|
251
262
|
self.__max_batch_size:int = 256 # MAX BATCH SIZE - ASYNC PROTECTION
|
|
252
263
|
self.__batch_size:int = 8 # Default batch size: 8
|
|
264
|
+
self.__loop:bool = loop # Loop the animation (generator)
|
|
253
265
|
self._set_batch_size(batch_size) # Set batch size from parameter
|
|
254
266
|
self._player_speed_ms:int = 10 # Default speed in ms between frames
|
|
255
267
|
main_tag:str = tag if tag else "animation"
|
|
256
268
|
self._task_tag:str = f"{main_tag}.player"
|
|
257
269
|
if animation is not None and not self._set_animation(animation):
|
|
258
270
|
raise Exception("Invalid animation function provided.")
|
|
259
|
-
self.
|
|
271
|
+
self.__running:bool = True
|
|
260
272
|
|
|
261
273
|
def _set_animation(self, animation:callable) -> bool:
|
|
262
274
|
"""
|
|
@@ -289,7 +301,7 @@ class AnimationPlayer:
|
|
|
289
301
|
clear()
|
|
290
302
|
for data in self.animation():
|
|
291
303
|
# Check if animation has changed under the loop
|
|
292
|
-
if not self.
|
|
304
|
+
if not self.__running or self.animation != current_animation:
|
|
293
305
|
# Animation changed — break — clean and restart animation loop.
|
|
294
306
|
clear()
|
|
295
307
|
break
|
|
@@ -312,13 +324,15 @@ class AnimationPlayer:
|
|
|
312
324
|
Async task to play the current animation.
|
|
313
325
|
"""
|
|
314
326
|
with micro_task(tag=self._task_tag) as my_task:
|
|
315
|
-
while self.
|
|
327
|
+
while self.__running:
|
|
316
328
|
my_task.out = f"Play {self.animation.__name__} ({self._player_speed_ms}ms/frame)"
|
|
317
329
|
try:
|
|
318
330
|
await self._render(my_task)
|
|
319
331
|
except IndexError:
|
|
320
332
|
# Draw after generator exhausted and Restart animation if IndexError occurs
|
|
321
333
|
self.draw()
|
|
334
|
+
if not self.__loop:
|
|
335
|
+
break
|
|
322
336
|
await my_task.feed(sleep_ms=self._player_speed_ms)
|
|
323
337
|
my_task.out = "Restart animation"
|
|
324
338
|
except Exception as e:
|
|
@@ -326,12 +340,13 @@ class AnimationPlayer:
|
|
|
326
340
|
break
|
|
327
341
|
my_task.out = f"Animation stopped...{my_task.out}"
|
|
328
342
|
|
|
329
|
-
def control(self, play_speed_ms:int, bt_draw:bool=None, bt_size:int=None):
|
|
343
|
+
def control(self, play_speed_ms:int, bt_draw:bool=None, bt_size:int=None, loop:bool=None):
|
|
330
344
|
"""
|
|
331
345
|
Set/Get current play speed of the animation.
|
|
332
346
|
:param play_speed_ms: player loop speed in milliseconds.
|
|
333
347
|
:param bt_draw: batch drawing flag.
|
|
334
348
|
:param bt_size: batch drawing size.
|
|
349
|
+
:param loop: loop flag.
|
|
335
350
|
"""
|
|
336
351
|
if isinstance(play_speed_ms, int):
|
|
337
352
|
self._player_speed_ms = max(0, min(10000, int(play_speed_ms)))
|
|
@@ -339,17 +354,22 @@ class AnimationPlayer:
|
|
|
339
354
|
self.batch_draw = bt_draw
|
|
340
355
|
if isinstance(bt_size, int):
|
|
341
356
|
self._set_batch_size(bt_size)
|
|
357
|
+
if isinstance(loop, bool):
|
|
358
|
+
self.__loop = loop
|
|
342
359
|
return {"realtime": not self.batch_draw, "batched": self.batch_draw,
|
|
343
|
-
"size": self.__batch_size, "speed_ms": self._player_speed_ms
|
|
360
|
+
"size": self.__batch_size, "speed_ms": self._player_speed_ms,
|
|
361
|
+
"loop": self.__loop}
|
|
344
362
|
|
|
345
363
|
|
|
346
|
-
def play(self, animation=None, speed_ms=None, bt_draw=False, bt_size=None):
|
|
364
|
+
def play(self, animation=None, speed_ms=None, bt_draw=False, bt_size=None, loop=True):
|
|
347
365
|
"""
|
|
348
366
|
Play animation via generator function.
|
|
349
367
|
:param animation: Animation generator function.
|
|
350
368
|
:param speed_ms: Speed of the animation in milliseconds. (min.: 3ms)
|
|
351
369
|
:param bt_draw: batch drawing flag.
|
|
352
370
|
:param bt_size: batch drawing size.
|
|
371
|
+
:param loop: Loop the animation.
|
|
372
|
+
:return: Player settings.
|
|
353
373
|
"""
|
|
354
374
|
|
|
355
375
|
if animation is not None:
|
|
@@ -358,9 +378,9 @@ class AnimationPlayer:
|
|
|
358
378
|
if self.animation is None:
|
|
359
379
|
return "No animation to play"
|
|
360
380
|
# Handle player settings
|
|
361
|
-
settings = self.control(play_speed_ms=speed_ms, bt_draw=bt_draw, bt_size=bt_size)
|
|
381
|
+
settings = self.control(play_speed_ms=speed_ms, bt_draw=bt_draw, bt_size=bt_size, loop=loop)
|
|
362
382
|
# Ensure async loop set up correctly. (After stop operation, it is needed)
|
|
363
|
-
self.
|
|
383
|
+
self.__running = True
|
|
364
384
|
# [!] ASYNC TASK CREATION
|
|
365
385
|
raw_state:bool = micro_task(tag=self._task_tag, task=self._player())
|
|
366
386
|
state = "starting" if raw_state else "running"
|
|
@@ -371,7 +391,7 @@ class AnimationPlayer:
|
|
|
371
391
|
"""
|
|
372
392
|
Stop the animation.
|
|
373
393
|
"""
|
|
374
|
-
self.
|
|
394
|
+
self.__running = False
|
|
375
395
|
return "Stop animation player"
|
|
376
396
|
|
|
377
397
|
def update(self, *arg, **kwargs):
|
micrOS/source/Config.py
CHANGED
|
@@ -16,11 +16,11 @@ from re import search
|
|
|
16
16
|
from json import load, dump
|
|
17
17
|
from uos import remove
|
|
18
18
|
from utime import sleep
|
|
19
|
-
from Debug import DebugCfg, console_write,
|
|
19
|
+
from Debug import DebugCfg, console_write, syslog
|
|
20
20
|
try:
|
|
21
21
|
from microIO import set_pinmap
|
|
22
22
|
except:
|
|
23
|
-
|
|
23
|
+
syslog("[ERR] LogicalPins import: set_pinmap")
|
|
24
24
|
set_pinmap = None
|
|
25
25
|
|
|
26
26
|
|
|
@@ -109,7 +109,7 @@ class Data:
|
|
|
109
109
|
Data.write_cfg_file()
|
|
110
110
|
console_write("[CONF] Save conf successful")
|
|
111
111
|
except Exception as e:
|
|
112
|
-
|
|
112
|
+
syslog(f"[ERR] Save (__inject) conf failed: {e}")
|
|
113
113
|
finally:
|
|
114
114
|
del liveconf
|
|
115
115
|
|
|
@@ -127,7 +127,7 @@ class Data:
|
|
|
127
127
|
if nosafe:
|
|
128
128
|
break
|
|
129
129
|
sleep(0.2)
|
|
130
|
-
|
|
130
|
+
syslog(f'[ERR] read_cfg_file error: {e}')
|
|
131
131
|
# Return config cache
|
|
132
132
|
return conf
|
|
133
133
|
|
|
@@ -140,7 +140,7 @@ class Data:
|
|
|
140
140
|
dump(Data.CONFIG_CACHE, f)
|
|
141
141
|
break
|
|
142
142
|
except Exception as e:
|
|
143
|
-
|
|
143
|
+
syslog(f'[ERR] write_cfg_file {Data.CONFIG_PATH} (json): {e}')
|
|
144
144
|
sleep(0.2)
|
|
145
145
|
return True
|
|
146
146
|
|
|
@@ -217,7 +217,7 @@ def cfgget(key=None):
|
|
|
217
217
|
return Data.disk_keys(key)
|
|
218
218
|
return val
|
|
219
219
|
except Exception as e:
|
|
220
|
-
|
|
220
|
+
syslog(f'[ERR] cfgget {key} error: {e}')
|
|
221
221
|
return None
|
|
222
222
|
|
|
223
223
|
def cfgput(key, value, type_check=False):
|
|
@@ -242,7 +242,7 @@ def cfgput(key, value, type_check=False):
|
|
|
242
242
|
del value
|
|
243
243
|
return True
|
|
244
244
|
except Exception as e:
|
|
245
|
-
|
|
245
|
+
syslog(f'[ERR] cfgput {key} error: {e}')
|
|
246
246
|
return False
|
|
247
247
|
|
|
248
248
|
#################################################################
|
micrOS/source/Debug.py
CHANGED
|
@@ -6,9 +6,9 @@ micrOS Console and Log write interface implementations.
|
|
|
6
6
|
|
|
7
7
|
from machine import Pin
|
|
8
8
|
try:
|
|
9
|
-
from Logger import syslog
|
|
9
|
+
from Logger import syslog as logger_syslog
|
|
10
10
|
except:
|
|
11
|
-
|
|
11
|
+
logger_syslog = None
|
|
12
12
|
try:
|
|
13
13
|
from microIO import resolve_pin, pinmap_search, register_pin
|
|
14
14
|
except:
|
|
@@ -46,13 +46,13 @@ class DebugCfg:
|
|
|
46
46
|
# Set function callback for step function (simple led - blink)
|
|
47
47
|
DebugCfg.PLED_STEP = lambda: led_obj.value(not led_obj.value()) # # double-blink: return None
|
|
48
48
|
except Exception as e:
|
|
49
|
-
|
|
49
|
+
syslog(f"[PLED] led error: {e}")
|
|
50
50
|
elif callable(pled):
|
|
51
51
|
# [MODE] OVERRIDE PROGRESS LED WITH CUSTOM step FUNCTION
|
|
52
52
|
DebugCfg.PLED_STEP = pled
|
|
53
53
|
DebugCfg._auto_register_pin()
|
|
54
54
|
else:
|
|
55
|
-
|
|
55
|
+
syslog(f"[WARN] pled type not supported: {pled}")
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
@staticmethod
|
|
@@ -62,7 +62,7 @@ class DebugCfg:
|
|
|
62
62
|
if isinstance(pin, int):
|
|
63
63
|
register_pin('builtin', pin)
|
|
64
64
|
except Exception as e:
|
|
65
|
-
|
|
65
|
+
syslog(f"[ERR] pled pin registration: {e}", console=False)
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
@staticmethod
|
|
@@ -75,7 +75,7 @@ class DebugCfg:
|
|
|
75
75
|
if callable(DebugCfg.PLED_STEP):
|
|
76
76
|
return DebugCfg.PLED_STEP() # Run step function (return None: double-blink OR True: no d-b)
|
|
77
77
|
except Exception as e:
|
|
78
|
-
|
|
78
|
+
syslog(f"[PLED] step error: {e}")
|
|
79
79
|
return True
|
|
80
80
|
|
|
81
81
|
|
|
@@ -87,10 +87,10 @@ def console_write(msg):
|
|
|
87
87
|
if analog is None:
|
|
88
88
|
DebugCfg.step() # Double-blink
|
|
89
89
|
except Exception as e:
|
|
90
|
-
|
|
90
|
+
syslog(f"[ERR] console_write: {e}", console=False)
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
def
|
|
93
|
+
def syslog(data, console=True):
|
|
94
94
|
"""
|
|
95
95
|
:param data: msg string / data
|
|
96
96
|
:param console: activate console_write (default: True)
|
|
@@ -98,4 +98,4 @@ def errlog_add(data, console=True):
|
|
|
98
98
|
"""
|
|
99
99
|
if console:
|
|
100
100
|
console_write(data)
|
|
101
|
-
return False if
|
|
101
|
+
return False if logger_syslog is None else logger_syslog(data)
|
micrOS/source/Espnow.py
CHANGED
|
@@ -4,7 +4,7 @@ from Tasks import NativeTask, TaskBase, lm_exec, lm_is_loaded
|
|
|
4
4
|
import uasyncio as asyncio
|
|
5
5
|
from Network import get_mac
|
|
6
6
|
from Config import cfgget
|
|
7
|
-
from Debug import
|
|
7
|
+
from Debug import syslog
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
# ----------- PARSE AND RENDER MSG PROTOCOL --------------
|
|
@@ -14,7 +14,7 @@ def render_response(tid, oper, data, prompt) -> str:
|
|
|
14
14
|
Render ESPNow custom message (protocol)
|
|
15
15
|
"""
|
|
16
16
|
if oper not in ("REQ", "RSP"):
|
|
17
|
-
|
|
17
|
+
syslog(f"[ERR] espnow render_response, unknown oper: {oper}")
|
|
18
18
|
tmp = "{tid}|{oper}|{data}|{prompt}$"
|
|
19
19
|
tmp = tmp.replace("{tid}", str(tid))
|
|
20
20
|
tmp = tmp.replace("{oper}", str(oper))
|
|
@@ -68,7 +68,7 @@ class ResponseRouter:
|
|
|
68
68
|
# USE <tid> for proper session response mapping
|
|
69
69
|
router = ResponseRouter._routes.get(mac)
|
|
70
70
|
if router is None:
|
|
71
|
-
|
|
71
|
+
syslog(f"[WARN][ESPNOW] No response route for {mac}")
|
|
72
72
|
return
|
|
73
73
|
router.response = response
|
|
74
74
|
router._event.set()
|
|
@@ -157,7 +157,7 @@ class ESPNowSS:
|
|
|
157
157
|
if state:
|
|
158
158
|
await self.__asend_raw(mac, response)
|
|
159
159
|
else:
|
|
160
|
-
|
|
160
|
+
syslog(response)
|
|
161
161
|
except OSError as err:
|
|
162
162
|
# If the peer is not yet added, add it and retry.
|
|
163
163
|
if len(err.args) > 1 and err.args[1] == 'ESP_ERR_ESPNOW_NOT_FOUND':
|
|
@@ -166,10 +166,10 @@ class ESPNowSS:
|
|
|
166
166
|
if state:
|
|
167
167
|
await self.__asend_raw(mac, response)
|
|
168
168
|
else:
|
|
169
|
-
|
|
169
|
+
syslog(response)
|
|
170
170
|
else:
|
|
171
171
|
# Optionally handle or log other OSErrors here.
|
|
172
|
-
|
|
172
|
+
syslog(f"[ERR][NOW SERVER] {err}")
|
|
173
173
|
|
|
174
174
|
def start_server(self):
|
|
175
175
|
"""
|
micrOS/source/Files.py
CHANGED
|
@@ -111,9 +111,11 @@ def path_join(*parts):
|
|
|
111
111
|
# micrOS system file structure
|
|
112
112
|
class OSPath:
|
|
113
113
|
_ROOT = getcwd()
|
|
114
|
-
LOGS = path_join(_ROOT, '/logs') #
|
|
115
|
-
DATA = path_join(_ROOT,'/data') #
|
|
116
|
-
WEB = path_join(_ROOT,'/web') #
|
|
114
|
+
LOGS = path_join(_ROOT, '/logs') # Logs (.log)
|
|
115
|
+
DATA = path_join(_ROOT,'/data') # Application data (.dat, .cache, etc.)
|
|
116
|
+
WEB = path_join(_ROOT,'/web') # Web resources (.html, .css, .js, .json, etc.)
|
|
117
|
+
MODULES = path_join(_ROOT, '/modules') # Application modules (.mpy, .py) (todo)
|
|
118
|
+
CONFIG = path_join(_ROOT, '/config') # System configuration files (node_config.json, etc.)(todo)
|
|
117
119
|
|
|
118
120
|
@property
|
|
119
121
|
def ROOT(self):
|
micrOS/source/Hooks.py
CHANGED
|
@@ -19,7 +19,7 @@ Designed by Marcell Ban aka BxNxM
|
|
|
19
19
|
#################################################################
|
|
20
20
|
from Config import cfgget, cfgput
|
|
21
21
|
from microIO import detect_platform
|
|
22
|
-
from Debug import console_write,
|
|
22
|
+
from Debug import console_write, syslog
|
|
23
23
|
from Tasks import exec_lm_pipe
|
|
24
24
|
from Files import OSPath, is_dir
|
|
25
25
|
from uos import mkdir
|
|
@@ -76,9 +76,9 @@ def _init_micros_dirs():
|
|
|
76
76
|
if not is_dir(dir_path):
|
|
77
77
|
try:
|
|
78
78
|
mkdir(dir_path)
|
|
79
|
-
|
|
79
|
+
syslog(f"[BOOT] init dir: {dir_path}")
|
|
80
80
|
except Exception as e:
|
|
81
|
-
|
|
81
|
+
syslog(f"[ERR][BOOT] cannot init dir {dir_path}: {e}")
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
def _tune_queue_size():
|
|
@@ -137,7 +137,7 @@ def boot_cause():
|
|
|
137
137
|
reason = 4, "DSWakeUp"
|
|
138
138
|
elif reset_reason == SOFT_RESET:
|
|
139
139
|
reason = 5, "SoftReset"
|
|
140
|
-
|
|
140
|
+
syslog(f"[BOOT] info: {reason[1]}")
|
|
141
141
|
return reason
|
|
142
142
|
|
|
143
143
|
|
|
@@ -151,6 +151,6 @@ def enableESPNow() -> str:
|
|
|
151
151
|
verdict = ESPNowSS().start_server()
|
|
152
152
|
console_write(f"[TASK] Start ESPNow-InterCon server: {verdict}")
|
|
153
153
|
except Exception as e:
|
|
154
|
-
|
|
154
|
+
syslog(f"[ERR] Start ESPNow-InterCon server: {e}")
|
|
155
155
|
return str(e)
|
|
156
156
|
return "ESPNow disabled"
|
micrOS/source/InterConnect.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from socket import getaddrinfo, SOCK_STREAM
|
|
2
2
|
from re import compile
|
|
3
3
|
from uasyncio import open_connection
|
|
4
|
-
from Debug import
|
|
4
|
+
from Debug import syslog
|
|
5
5
|
from Config import cfgget
|
|
6
6
|
from Server import Server
|
|
7
7
|
from Tasks import NativeTask
|
|
@@ -41,7 +41,7 @@ class InterCon:
|
|
|
41
41
|
host = addr_info[-1][4][0]
|
|
42
42
|
except OSError as e:
|
|
43
43
|
Server.reply_all(f"[intercon] NoHost: {e}")
|
|
44
|
-
|
|
44
|
+
syslog(f"[intercon] send_cmd {host} oserr: {e}")
|
|
45
45
|
return ''
|
|
46
46
|
else:
|
|
47
47
|
# Restore IP from cache by hostname
|
|
@@ -55,7 +55,7 @@ class InterCon:
|
|
|
55
55
|
output = await self.__run_command(cmd, hostname)
|
|
56
56
|
except OSError as e:
|
|
57
57
|
Server.reply_all(f"[intercon] NoHost: {e}")
|
|
58
|
-
|
|
58
|
+
syslog(f"[intercon] send_cmd {host} oserr: {e}")
|
|
59
59
|
output = None
|
|
60
60
|
finally:
|
|
61
61
|
if self.writer:
|
|
@@ -69,7 +69,7 @@ class InterCon:
|
|
|
69
69
|
# None: ServerBusy(or \0) or Prompt mismatch (auto delete cached IP), STR: valid comm. output
|
|
70
70
|
return output
|
|
71
71
|
else:
|
|
72
|
-
|
|
72
|
+
syslog(f"[ERR][intercon] Invalid host: {host}")
|
|
73
73
|
return ''
|
|
74
74
|
|
|
75
75
|
async def __run_command(self, cmd:list, hostname:str):
|
|
@@ -103,7 +103,7 @@ class InterCon:
|
|
|
103
103
|
await self.writer.drain()
|
|
104
104
|
data, prompt = await self.__receive_data(prompt=prompt)
|
|
105
105
|
except Exception as e:
|
|
106
|
-
|
|
106
|
+
syslog(f'[intercon][ERR] Auth: {e}')
|
|
107
107
|
data = 'AuthFailed'
|
|
108
108
|
if 'AuthOk' in data:
|
|
109
109
|
return True # AuthOk
|
micrOS/source/Interrupts.py
CHANGED
|
@@ -19,7 +19,7 @@ Reference: https://docs.micropython.org/en/latest/library/machine.Pin.html
|
|
|
19
19
|
from machine import Pin
|
|
20
20
|
from utime import ticks_ms, ticks_diff
|
|
21
21
|
from Config import cfgget
|
|
22
|
-
from Debug import console_write,
|
|
22
|
+
from Debug import console_write, syslog
|
|
23
23
|
from Tasks import exec_lm_pipe_schedule
|
|
24
24
|
from microIO import resolve_pin
|
|
25
25
|
if cfgget('cron'):
|
|
@@ -157,7 +157,7 @@ def initEventIRQs():
|
|
|
157
157
|
try:
|
|
158
158
|
return resolve_pin(_p)
|
|
159
159
|
except Exception as e:
|
|
160
|
-
|
|
160
|
+
syslog(f'[ERR][!] EVENT {_p} IO error: {e}')
|
|
161
161
|
return None
|
|
162
162
|
|
|
163
163
|
# Load External IRQ (1-4) execution data set from node config
|
micrOS/source/LM_dashboard_be.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from Common import web_endpoint, syslog
|
|
1
|
+
from Common import web_dir, web_endpoint, syslog
|
|
2
2
|
|
|
3
3
|
ENDPOINT_INITED = False
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ def load():
|
|
|
8
8
|
|
|
9
9
|
def _dashboard_clb():
|
|
10
10
|
try:
|
|
11
|
-
with open('dashboard.html', 'r') as html:
|
|
11
|
+
with open(web_dir('dashboard.html'), 'r') as html:
|
|
12
12
|
html_content = html.read()
|
|
13
13
|
return 'text/html', html_content
|
|
14
14
|
except Exception as e:
|