void json_parser(char *str) { stat_t status = _json_parser_kernal(str); if (status == STAT_COMPLETE) return; // skip the print if returning from something at already did it. nv_print_list(status, TEXT_NO_PRINT, JSON_RESPONSE_FORMAT); sr_request_status_report(SR_REQUEST_TIMED); // generate incremental status report to show any changes }
static stat_t _homing_error_exit(int8_t axis, stat_t status) { // Generate the warning message. Since the error exit returns via the homing callback // - and not the main controller - it requires its own display processing nv_reset_nv_list(); if (axis == -2) { nv_add_conditional_message((const char_t *)"Homing error - Bad or no axis(es) specified");; } else { char message[NV_MESSAGE_LEN]; sprintf_P(message, PSTR("Homing error - %c axis settings misconfigured"), cm_get_axis_char(axis)); nv_add_conditional_message((char_t *)message); } nv_print_list(STAT_HOMING_CYCLE_FAILED, TEXT_INLINE_VALUES, JSON_RESPONSE_FORMAT); _homing_finalize_exit(axis); return (STAT_HOMING_CYCLE_FAILED); // homing state remains HOMING_NOT_HOMED }
static stat_t _probing_error_exit(int8_t axis) { // Generate the warning message. Since the error exit returns via the probing callback // - and not the main controller - it requires its own display processing nv_reset_nv_list(); if (axis == -2) { nv_add_conditional_message((const char *)"Probing error - invalid probe destination"); } else { char msg[NV_MESSAGE_LEN]; sprintf_P(msg, PSTR("Probing error - %c axis cannot move during probing"), cm_get_axis_char(axis)); nv_add_conditional_message(msg); } nv_print_list(STAT_PROBE_CYCLE_FAILED, TEXT_INLINE_VALUES, JSON_RESPONSE_FORMAT); // clean up and exit _probe_restore_settings(); return (STAT_PROBE_CYCLE_FAILED); }
/****************************************************************************** * text_parser() - update a config setting from a text block (text mode) * _text_parser_kernal() - helper for above * * Use cases handled: * - $xfr=1200 set a parameter (strict separators)) * - $xfr 1200 set a parameter (relaxed separators) * - $xfr display a parameter * - $x display a group * - ? generate a status report (multiline format) */ stat_t text_parser(char_t *str) { nvObj_t *nv = nv_reset_nv_list(); // returns first object in the body stat_t status = STAT_OK; // trap special displays if (str[0] == '?') { // handle status report case sr_run_text_status_report(); return (STAT_OK); } if (str[0] == 'H') { // print help screens help_general((nvObj_t *)NULL); return (STAT_OK); } // pre-process the command if ((str[0] == '$') && (str[1] == NUL)) { // treat a lone $ as a sys request strcat(str,"sys"); } // parse and execute the command (only processes 1 command per line) ritorno(_text_parser_kernal(str, nv)); // run the parser to decode the command if ((nv->valuetype == TYPE_NULL) || (nv->valuetype == TYPE_PARENT)) { if (nv_get(nv) == STAT_COMPLETE){ // populate value, group values, or run uber-group displays return (STAT_OK); // return for uber-group displays so they don't print twice } } else { // process SET and RUN commands if (cm.machine_state == MACHINE_ALARM) return (STAT_MACHINE_ALARMED); status = nv_set(nv); // set (or run) single value if (status == STAT_OK) { nv_persist(nv); // conditionally persist depending on flags in array } } nv_print_list(status, TEXT_MULTILINE_FORMATTED, JSON_RESPONSE_FORMAT); // print the results return (status); }