MCPcopy Create free account
hub / github.com/bdring/FluidNC / gcode_comment_msg

Function gcode_comment_msg

FluidNC/src/GCode.cpp:107–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107static void gcode_comment_msg(const char* comment) {
108 if (gc_state.skip_blocks) {
109 return;
110 }
111
112 const size_t msglen = 128;
113 char msg[msglen];
114 size_t offset = strlen("MSG_");
115 size_t index;
116 if (strstr(comment, "MSG")) {
117 log_info("MSG," << &comment[offset]);
118 return;
119 }
120 offset = strlen("PRINT,"); // Same length as DEBUG,
121 bool isdebug = strncasecmp(comment, "DEBUG,", offset) == 0;
122 if (isdebug || strncasecmp(comment, "PRINT,", offset) == 0) {
123 const char* format = "%lf";
124 size_t msgindex = 0;
125 size_t len = strlen(comment);
126 for (index = offset; index < len; ++index) {
127 char c = comment[index];
128 if (c == '%') {
129 if (!decode_format_string(comment, index, len, format)) {
130 msg[msgindex++] = c;
131 }
132 } else if (c == '#') {
133 float number;
134 if (read_number(comment, index, number)) {
135 msgindex += snprintf(&msg[msgindex], msglen - msgindex, format, number);
136 } else {
137 msg[msgindex++] = c;
138 }
139 } else {
140 msg[msgindex++] = c;
141 }
142 }
143 msg[msgindex] = '\0';
144 if (isdebug) {
145 log_debug("DEBUG," << msg);
146 } else {
147 log_info("PRINT," << msg);
148 }
149 }
150}
151
152static std::optional<WaitOnInputMode> validate_wait_on_input_mode_value(objnum_t);
153static Error gc_wait_on_input(bool is_digital, objnum_t input_number, WaitOnInputMode mode, float timeout);

Callers 1

collapseGCodeFunction · 0.85

Calls 3

strncasecmpFunction · 0.85
decode_format_stringFunction · 0.85
read_numberFunction · 0.85

Tested by

no test coverage detected