Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meatpack::report_state on serial port init #20903

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use 'p' for port index
thinkyhead committed Jan 28, 2021
commit eea496725c212192f1c8a5aef448287b143fdfe6
28 changes: 14 additions & 14 deletions Marlin/src/gcode/queue.cpp
Original file line number Diff line number Diff line change
@@ -473,13 +473,13 @@ void GCodeQueue::get_serial_commands() {
* Loop while serial characters are incoming and the queue is not full
*/
while (length < BUFSIZE && serial_data_available()) {
LOOP_L_N(i, NUM_SERIAL) {
LOOP_L_N(p, NUM_SERIAL) {

const int c = read_serial(i);
const int c = read_serial(p);
if (c < 0) continue;

#if ENABLED(MEATPACK)
meatpack.handle_rx_char(uint8_t(c),i);
meatpack.handle_rx_char(uint8_t(c), p);
char c_res[2] = { 0, 0 };
const uint8_t char_count = meatpack.get_result_char(c_res);
#else
@@ -492,10 +492,10 @@ void GCodeQueue::get_serial_commands() {
if (ISEOL(serial_char)) {

// Reset our state, continue if the line was empty
if (process_line_done(serial_input_state[i], serial_line_buffer[i], serial_count[i]))
if (process_line_done(serial_input_state[p], serial_line_buffer[p], serial_count[p]))
continue;

char* command = serial_line_buffer[i];
char* command = serial_line_buffer[p];

while (*command == ' ') command++; // Skip leading spaces
char *npos = (*command == 'N') ? command : nullptr; // Require the N parameter to start the line
@@ -511,25 +511,25 @@ void GCodeQueue::get_serial_commands() {

const long gcode_N = strtol(npos + 1, nullptr, 10);

if (gcode_N != last_N[i] + 1 && !M110)
return gcode_line_error(PSTR(STR_ERR_LINE_NO), i);
if (gcode_N != last_N[p] + 1 && !M110)
return gcode_line_error(PSTR(STR_ERR_LINE_NO), p);

char *apos = strrchr(command, '*');
if (apos) {
uint8_t checksum = 0, count = uint8_t(apos - command);
while (count) checksum ^= command[--count];
if (strtol(apos + 1, nullptr, 10) != checksum)
return gcode_line_error(PSTR(STR_ERR_CHECKSUM_MISMATCH), i);
return gcode_line_error(PSTR(STR_ERR_CHECKSUM_MISMATCH), p);
}
else
return gcode_line_error(PSTR(STR_ERR_NO_CHECKSUM), i);
return gcode_line_error(PSTR(STR_ERR_NO_CHECKSUM), p);

last_N[i] = gcode_N;
last_N[p] = gcode_N;
}
#if ENABLED(SDSUPPORT)
// Pronterface "M29" and "M29 " has no line number
else if (card.flag.saving && !is_M29(command))
return gcode_line_error(PSTR(STR_ERR_NO_CHECKSUM), i);
return gcode_line_error(PSTR(STR_ERR_NO_CHECKSUM), p);
#endif

//
@@ -547,7 +547,7 @@ void GCodeQueue::get_serial_commands() {
#if ENABLED(BEZIER_CURVE_SUPPORT)
case 5:
#endif
PORT_REDIRECT(i); // Reply to the serial port that sent the command
PORT_REDIRECT(p); // Reply to the serial port that sent the command
SERIAL_ECHOLNPGM(STR_ERR_STOPPED);
LCD_MESSAGEPGM(MSG_STOPPED);
break;
@@ -569,9 +569,9 @@ void GCodeQueue::get_serial_commands() {
#endif

// Add the command to the queue
_enqueue(serial_line_buffer[i], true
_enqueue(serial_line_buffer[p], true
#if HAS_MULTI_SERIAL
, i
, p
#endif
);
}