Testing comm variables settings. Added in32 functions; Some fixes to ej and jv

This commit is contained in:
Alden Hart
2016-12-12 15:56:52 -05:00
parent 6722e1fa99
commit d17d59c7bb
8 changed files with 103 additions and 64 deletions
-2
View File
@@ -166,10 +166,8 @@ stat_t hw_get_fb(nvObj_t *nv);
stat_t hw_get_fv(nvObj_t *nv);
stat_t hw_get_hp(nvObj_t *nv);
stat_t hw_get_hv(nvObj_t *nv);
stat_t hw_get_fbs(nvObj_t *nv);
stat_t hw_get_fbc(nvObj_t *nv);
stat_t hw_get_hv(nvObj_t *nv);
stat_t hw_get_id(nvObj_t *nv);
#ifdef __TEXT_MODE
+6 -3
View File
@@ -356,12 +356,15 @@ stat_t set_flu(nvObj_t *nv); // set floating point number
void process_incoming_float(nvObj_t *nv); // pre-process outgoing float values for units and illegal values
void process_outgoing_float(nvObj_t *nv); // pre-process incoming float values for canonical units
stat_t get_float(nvObj_t *nv, const float value); // boilerplate for retrieving raw floating point value
stat_t set_float(nvObj_t *nv, float &value); // boilerplate for setting a floating point value w/conversion
stat_t get_float(nvObj_t *nv, const float value); // boilerplate for retrieving raw floating point value
stat_t set_float(nvObj_t *nv, float &value); // boilerplate for setting a floating point value w/conversion
stat_t set_float_range(nvObj_t *nv, float &value, float low, float high);
stat_t get_int(nvObj_t *nv, const uint8_t value); // boilerplate for retrieving an integer value
stat_t get_int(nvObj_t *nv, const uint8_t value); // boilerplate for retrieving 8 bit integer value
stat_t set_int(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high);
stat_t get_int32(nvObj_t *nv, const uint32_t value); // boilerplate for retrieving 32 bit integer value
stat_t set_int32(nvObj_t *nv, uint32_t &value, uint32_t low, uint32_t high);
stat_t get_string(nvObj_t *nv, const char *str);
+37 -9
View File
@@ -639,11 +639,11 @@ const cfgItem_t cfgArray[] = {
#ifdef __TEXT_MODE
{ "sys","tv", _fipn, 0, tx_print_tv, txt_get_tv, txt_set_tv, (float *)&cs.null, TEXT_VERBOSITY },
#endif
{ "sys","ej", _fipn, 0, js_print_ej, get_ui8, js_set_ej,(float *)&cs.comm_mode, COMM_MODE },
{ "sys","jv", _fipn, 0, js_print_jv, get_ui8, js_set_jv,(float *)&js.json_verbosity, JSON_VERBOSITY },
{ "sys","qv", _fipn, 0, qr_print_qv, get_ui8, set_0123, (float *)&qr.queue_report_verbosity, QUEUE_REPORT_VERBOSITY },
{ "sys","sv", _fipn, 0, sr_print_sv, get_ui8, set_012, (float *)&sr.status_report_verbosity,STATUS_REPORT_VERBOSITY },
{ "sys","si", _fipn, 0, sr_print_si, get_int32,sr_set_si, (float *)&sr.status_report_interval, STATUS_REPORT_INTERVAL_MS },
{ "sys","ej", _fipn, 0, js_print_ej, js_get_ej, js_set_ej, (float *)&cs.null, COMM_MODE },
{ "sys","jv", _fipn, 0, js_print_jv, js_get_jv, js_set_jv, (float *)&cs.null, JSON_VERBOSITY },
{ "sys","qv", _fipn, 0, qr_print_qv, qr_get_qv, qr_set_qv, (float *)&cs.null, QUEUE_REPORT_VERBOSITY },
{ "sys","sv", _fipn, 0, sr_print_sv, sr_get_sv, sr_set_sv, (float *)&cs.null, STATUS_REPORT_VERBOSITY },
{ "sys","si", _fipn, 0, sr_print_si, sr_get_si, sr_set_si, (float *)&cs.null, STATUS_REPORT_INTERVAL_MS },
// Gcode defaults
// NOTE: The ordering within the gcode defaults is important for token resolution. gc must follow gco
@@ -1082,8 +1082,10 @@ stat_t set_float_range(nvObj_t *nv, float &value, float low, float high) {
}
/*
* get_int() - boilerplate for retrieving an integer value
* set_int() - boilerplate for setting an integer value with range checking
* get_int() - boilerplate for retrieving 8 bit integer value
* set_int() - boilerplate for setting 8 bit integer value with range checking
* get_int32() - boilerplate for retrieving 32 bit integer value
* set_int32() - boilerplate for setting 32 bit integer value with range checking
*/
stat_t get_int(nvObj_t *nv, const uint8_t value) {
@@ -1097,13 +1099,39 @@ stat_t set_int(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high) {
char msg[64];
if (nv->value < low) {
sprintf(msg, "Input is less than minimum value %d", (int)low);
sprintf(msg, "Input is less than minimum value %d", low);
nv_add_conditional_message(msg);
nv->valuetype = TYPE_NULL;
return (STAT_INPUT_LESS_THAN_MIN_VALUE);
}
if (nv->value > high) {
sprintf(msg, "Input is more than maximum value %d", (int)high);
sprintf(msg, "Input is more than maximum value %d", high);
nv_add_conditional_message(msg);
nv->valuetype = TYPE_NULL;
return (STAT_INPUT_EXCEEDS_MAX_VALUE);
}
value = nv->value; // note: valuetype = TYPE_INT already set
return (STAT_OK);
}
stat_t get_int32(nvObj_t *nv, const uint32_t value) {
nv->value = value;
nv->valuetype = TYPE_INT;
return STAT_OK;
}
stat_t set_int32(nvObj_t *nv, uint32_t &value, uint32_t low, uint32_t high) {
char msg[64];
if (nv->value < low) {
sprintf(msg, "Input is less than minimum value %lu", low);
nv_add_conditional_message(msg);
nv->valuetype = TYPE_NULL;
return (STAT_INPUT_LESS_THAN_MIN_VALUE);
}
if (nv->value > high) {
sprintf(msg, "Input is more than maximum value %lu", high);
nv_add_conditional_message(msg);
nv->valuetype = TYPE_NULL;
return (STAT_INPUT_EXCEEDS_MAX_VALUE);
+3 -3
View File
@@ -61,10 +61,10 @@ typedef struct controllerSingleton { // main TG controller struct
uint32_t led_blink_rate; // used to flash indicator LED
// communications state variables
// cs.comm_mode is the setting for the communications more
// js.json_mode is the actual current mode (see also js.json_now)
// cs.comm_mode is the setting for the communications mode
// js.json_mode is the actual current mode
commMode comm_mode; // ej: 0=text mode sticky, 1=JSON mode sticky, 2=auto mode
commMode comm_request_mode; // mode of request (may be different thatn the setting)
commMode comm_request_mode; // mode of request (may be different than the setting)
// controller serial buffers
char *bufp; // pointer to primary or secondary in buffer
+27 -22
View File
@@ -97,7 +97,7 @@ void json_parser(char *str)
if (status == STAT_COMPLETE) { // skip the print if returning from something that already did it.
return;
}
nv_print_list(status, TEXT_NO_PRINT, JSON_RESPONSE_FORMAT);
nv_print_list(status, TEXT_MULTILINE_FORMATTED, JSON_RESPONSE_FORMAT);
sr_request_status_report(SR_REQUEST_TIMED); // generate incremental status report to show any changes
}
@@ -609,12 +609,36 @@ void json_print_response(uint8_t status)
***********************************************************************************/
/*
* js_set_jv()
* js_get_ej() - get JSON communications mode
* js_set_ej() - set JSON communications mode
*
* This one is a bit different:
* - cs.comm_mode is the setting for the *communications mode* (persistent)
* - js.json_mode is the actual current mode
*
* If comm_mode is set to TEXT_MORE (0) or JSON_MODE (1) then json_mode should also be changed
* If comm_mode is set to AUTO_MORE (0) then json_mode should not be changed
*/
stat_t js_get_ej(nvObj_t *nv) { return(get_int(nv, cs.comm_mode)); }
stat_t js_set_ej(nvObj_t *nv)
{
ritorno (set_int(nv, (uint8_t &)cs.comm_mode, TEXT_MODE, AUTO_MODE));
if (commMode(nv->value) < AUTO_MODE) { // set json_mode to 0 or 1, but don't change it if comm_mode == 2
js.json_mode = commMode(nv->value);
}
return (STAT_OK);
}
/*
* js_get_jv() - get JSON verbosity
* js_set_jv() - set JSON verbosity and related flags
*/
stat_t js_get_jv(nvObj_t *nv) { return(get_int(nv, js.json_verbosity)); }
stat_t js_set_jv(nvObj_t *nv)
{
ritorno (set_int(nv, (uint8_t &)js.json_verbosity, 0, JV_MAX_VALUE));
ritorno (set_int(nv, (uint8_t &)js.json_verbosity, JV_SILENT, JV_MAX_VALUE));
js.echo_json_footer = false;
js.echo_json_messages = false;
@@ -636,25 +660,6 @@ stat_t js_set_jv(nvObj_t *nv)
return(STAT_OK);
}
/*
* js_set_ej() - set JSON communications mode
*/
stat_t js_set_ej(nvObj_t *nv)
{
// ritorno (set_int(nv, cs.comm_mode, TEXT_MODE, AUTO_MODE));
if ((nv->value < TEXT_MODE) || (nv->value > AUTO_MODE)) {
nv->valuetype = TYPE_NULL;
return (STAT_INPUT_VALUE_RANGE_ERROR);
}
// set json_mode to 0 or 1, but don't change it if comm_mode == 2
if (commMode(nv->value) < AUTO_MODE) {
js.json_mode = commMode(nv->value);
}
return (set_ui8(nv));
}
/***********************************************************************************
* TEXT MODE SUPPORT
* Functions to print variables from the cfgArray table
+5 -3
View File
@@ -50,9 +50,9 @@ typedef enum {
JV_VERBOSE, // [5] returns footer, messages, config commands, gcode blocks
JV_EXCEPTIONS, // [6] returns only on messages, configs, and non-zero status
JV_STATUS, // [7] returns status and any messages in abbreviated format
JV_STATUS_COUNT, // [8] returns status, count and messages in abbreviated format
JV_MAX_VALUE
JV_STATUS_COUNT // [8] returns status, count and messages in abbreviated format
} jsonVerbosity;
#define JV_MAX_VALUE JV_STATUS_COUNT
typedef enum { // json output print modes
JSON_NO_PRINT = 0, // don't print anything if you find yourself in JSON mode
@@ -88,8 +88,10 @@ void json_print_object(nvObj_t *nv);
void json_print_response(uint8_t status);
void json_print_list(stat_t status, uint8_t flags);
stat_t js_set_jv(nvObj_t *nv);
stat_t js_get_ej(nvObj_t *nv);
stat_t js_set_ej(nvObj_t *nv);
stat_t js_get_jv(nvObj_t *nv);
stat_t js_set_jv(nvObj_t *nv);
#ifdef __TEXT_MODE
+17 -22
View File
@@ -412,41 +412,33 @@ static uint8_t _populate_filtered_status_report()
/*
* Wrappers and Setters - for calling from nvArray table
*
* sr_get() - run status report
* sr_set() - set status report elements
* sr_set_si() - set status report interval
* sr_get() - run status report
* sr_set() - set status report elements
* sr_get_sv() - get status report verbosity
* sr_set_sv() - set status report verbosity
* sr_get_si() - get status report interval
* sr_set_si() - set status report interval
*/
stat_t sr_get(nvObj_t *nv)
{
return (_populate_unfiltered_status_report());
}
stat_t sr_get(nvObj_t *nv) { return (_populate_unfiltered_status_report()); }
stat_t sr_set(nvObj_t *nv) { return (sr_set_status_report(nv)); }
stat_t sr_set(nvObj_t *nv)
{
return (sr_set_status_report(nv));
}
stat_t sr_set_si(nvObj_t *nv)
{
if (nv->value < STATUS_REPORT_MIN_MS) {
nv->value = STATUS_REPORT_MIN_MS;
}
set_int32(nv);
return(STAT_OK);
}
stat_t sr_get_sv(nvObj_t *nv) { return(get_int(nv, (uint8_t &)sr.status_report_verbosity)); }
stat_t sr_set_sv(nvObj_t *nv) { return(set_int(nv, (uint8_t &)sr.status_report_verbosity, SR_OFF, SR_VERBOSE)); }
stat_t sr_get_si(nvObj_t *nv) { return(get_int32(nv, sr.status_report_interval)); }
stat_t sr_set_si(nvObj_t *nv) { return(set_int32(nv, sr.status_report_interval, STATUS_REPORT_MIN_MS, STATUS_REPORT_MAX_MS)); }
/*********************
* TEXT MODE SUPPORT *
*********************/
#ifdef __TEXT_MODE
static const char fmt_si[] = "[si] status interval%14d ms\n";
static const char fmt_sv[] = "[sv] status report verbosity%6d [0=off,1=filtered,2=verbose]\n";
static const char fmt_si[] = "[si] status interval%14d ms\n";
void sr_print_sr(nvObj_t *nv) { _populate_unfiltered_status_report();}
void sr_print_si(nvObj_t *nv) { text_print(nv, fmt_si);}
void sr_print_sv(nvObj_t *nv) { text_print(nv, fmt_sv);}
void sr_print_si(nvObj_t *nv) { text_print(nv, fmt_si);}
#endif // __TEXT_MODE
@@ -595,6 +587,9 @@ stat_t qo_get(nvObj_t *nv)
return (STAT_OK);
}
stat_t qr_get_qv(nvObj_t *nv) { return(get_int(nv, (uint8_t &)qr.queue_report_verbosity)); }
stat_t qr_set_qv(nvObj_t *nv) { return(set_int(nv, (uint8_t &)qr.queue_report_verbosity, QR_OFF, QR_TRIPLE)); }
/*****************************************************************************
* JOB ID REPORTS
*
Executable → Regular
+8
View File
@@ -36,6 +36,7 @@
#define SR_THROTTLE_COUNT 4 // scale back filtered SR's during time-constrained intervals
#define MIN_ARC_QR_INTERVAL 200 // minimum interval between QRs during arc generation (in system ticks)
#define STATUS_REPORT_MAX_MS (MAX_LONG/1000)
typedef enum { // status report enable, verbosity and request type
SR_OFF = 0, // no reports
@@ -112,6 +113,10 @@ stat_t sr_run_text_status_report(void);
stat_t sr_get(nvObj_t *nv);
stat_t sr_set(nvObj_t *nv);
stat_t sr_get_sv(nvObj_t *nv);
stat_t sr_set_sv(nvObj_t *nv);
stat_t sr_get_si(nvObj_t *nv);
stat_t sr_set_si(nvObj_t *nv);
void qr_init_queue_report(void);
@@ -125,6 +130,9 @@ stat_t qr_get(nvObj_t *nv);
stat_t qi_get(nvObj_t *nv);
stat_t qo_get(nvObj_t *nv);
stat_t qr_get_qv(nvObj_t *nv);
stat_t qr_set_qv(nvObj_t *nv);
#ifdef __TEXT_MODE
void sr_print_sr(nvObj_t *nv);