Closed skasti closed 1 month ago
please move substitute_parameters() to the same #if #endif block where read_parameter () is located and mark it as static
please move substitute_parameters() to the same #if #endif block where read_parameter () is located and mark it as static
Hm, read_parameter
seems to be in the #if #endif block for NGC_EXPRESSIONS_ENABLE
. Does this mean I should put this feature behind that flag, and not NGC_PARAMETERS_ENABLE
?
I would have thought that NGC_PARAMETERS_ENABLE
would be more appropriate for both of these functions, since they revolve around parameters and not expressions? Though I do see that a sub-section of read_parameters
does call ngc_eval_expression
π€
Will put my stuff in the NGC_EXPRESSIONS_ENABLE-block for now, since that is at least consistent
FYI NGC_PARAMETERS_ENABLE was added to have basic support for G65 (with no parameter passing) for the 128K STM32F1xx MCUs, this since adding expressions would otherwise overflow flash. Perhaps a bad choice of name for the symbol... Anyway if NGC_EXPRESSIONS_ENABLE is true NGC_PARAMETERS_ENABLE will always be as well.
FYI NGC_PARAMETERS_ENABLE was added to have basic support for G65 (with no parameter passing) for the 128K STM32F1xx MCUs, this since adding expressions would otherwise overflow flash. Perhaps a bad choice of name for the symbol... Anyway if NGC_EXPRESSIONS_ENABLE is true NGC_PARAMETERS_ENABLE will always be as well.
Aaah, that makes senseπ I thought maybe parameters might have been a thing outside of using expressions/G65, so that you could have used them in "normal" g-code somehow.
FYI you introduced a memory leak in MSG substitution... I will fix this in the next commit and add also support for PRINT messages and formatting of values.
Oh no, I am so sorry! π Please point out how, if possible, so I can hopefully learn π
if(message && *message == NULL && !strncmp(comment, "(MSG,", 5) && (*message = malloc(len))) {
This line allocates memory for a copy of the MSG message, and your code in substitute_parameters()
overwrites the *message pointer without freeing the already allocated memory. I changed the code to not allocate memory initally when expressions is enabled.
ah, I did not notice that this line did any memory allocation. I thought it only did the same thing as the debug-one π I guess then the #else-block needs to include that malloc in order to work properly?
In many cases it is necessary to communicate something to an operator which contains a dynamic value, and being able to use the MSG comments for this seems natural.
The reason for not using DEBUG comments is that those are used for debugging, and create a lot of noise for the operator. So the operator should be able to disable DEBUG output and still get the messages they need
Example output with debug output enabled:
Example output with debug output disabled:
P200 is a macro that finds an available slot in my tool rack, tells the operator to put it there, and assigns the tool to the slot so that it knows where to find it.