Closed ralphwetzel closed 1 year ago
Thanks for the report. The documentation does seem to be ahead of the implementation. I've updated the implementation to relay the error and warning messages to the editor as you propose.
I also added a build configuration to control if messages should be sent to the editor. This avoids the overhead of constructing and sending messages that are unnecessary for the runtime itself. The MCU plug-in will probably always want to set that to true
. Currently it is always true
in manifest_runtime.json
to avoid breaking the MCU plug-in. Please let me know when you update the MCU plug-in set this itself so I can change the default to false
. (Thank you!)
I also added a build configuration to control if messages should be sent to the editor.
That's a good idea! Is my assumption correct, that the plugin is able to set this to true
by defining
"config": {
"noderedmcu": {
"editor": true
}
},
in a(ny) manifest.json
?
That's a good idea!
There's one further aspect to consider: My understanding is that trace.left
would be eliminated for release builds.
https://github.com/phoddie/node-red-mcu/blob/4bbf3635970e0c2e9fab1303d33b79874b8295ec/nodered.js#L146-L147
Those guards yet (e.g. line 146) will stay & consume resources. Is there a way (e.g. like a #pragma) that nodered2mcu
or another tool understands to remove them on demand?
...that the plugin is able to set this to true by defining ... in a(ny) manifest.json?
Yes, you can define this in any manifest.
My understanding is that trace.left would be eliminated for release builds
The call to trace.left
is skipped for any build that does not set config.noderedmcu.editor
to a truthy value.
Those guards yet (e.g. line 146) will stay & consume resources. Is there a way (e.g. like a #pragma) that nodered2mcu or another tool understands to remove them on demand?
Whey will use a small amount of byte code in flash and the if
will be evaluated at runtime. Both are fairly light, so that's a small concern. There are several ways that could be eliminated but none are trivial, so that feels like over-optimization at this stage.
Please let me know when you update the MCU plug-in set this itself so I can change the default to
false
. (Thank you!)
Done.
You may switch the flag to default state false
now.
Perfect. Thank you! I've committed the change to make the default false
.
Hello Peter! The node-red docu states that
Currently, those just
trace()
to the log window of xsbug:https://github.com/phoddie/node-red-mcu/blob/029cd1e6586435936b84ffe5c44e68ea9f4fc853/nodered.js#L336-L341
The plugin already understands a
warn
orerror
message in the following (standard) format (replaceerror
vswarn
twice fornode.warn
):I propose to add this functionality to
class Node
definition.-- R.