Distinguish serial index from mask (#21287)
This commit is contained in:
@ -1067,7 +1067,7 @@ void GcodeSuite::process_subcommands_now(char * gcode) {
|
||||
static millis_t next_busy_signal_ms = 0;
|
||||
if (!autoreport_paused && host_keepalive_interval && busy_state != NOT_BUSY) {
|
||||
if (PENDING(ms, next_busy_signal_ms)) return;
|
||||
PORT_REDIRECT(SERIAL_ALL);
|
||||
PORT_REDIRECT(SerialMask::All);
|
||||
switch (busy_state) {
|
||||
case IN_HANDLER:
|
||||
case IN_PROCESS:
|
||||
|
@ -52,7 +52,7 @@ void GcodeSuite::M118() {
|
||||
while (*p == ' ') ++p;
|
||||
}
|
||||
|
||||
PORT_REDIRECT(WITHIN(port, 0, NUM_SERIAL) ? (port ? SERIAL_PORTMASK(port - 1) : SERIAL_ALL) : multiSerial.portMask);
|
||||
PORT_REDIRECT(WITHIN(port, 0, NUM_SERIAL) ? (port ? SERIAL_PORTMASK(port - 1) : SerialMask::All) : multiSerial.portMask);
|
||||
|
||||
if (hasE) SERIAL_ECHO_START();
|
||||
if (hasA) SERIAL_ECHOPGM("//");
|
||||
|
@ -240,7 +240,7 @@ void GCodeQueue::RingBuffer::ok_to_send() {
|
||||
CommandLine &command = commands[index_r];
|
||||
#if HAS_MULTI_SERIAL
|
||||
const serial_index_t serial_ind = command.port;
|
||||
if (serial_ind < 0) return;
|
||||
if (!serial_ind.valid()) return; // Optimization here, skip processing if it's not going anywhere
|
||||
PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command
|
||||
#endif
|
||||
if (command.skip_ok) return;
|
||||
@ -264,15 +264,15 @@ void GCodeQueue::RingBuffer::ok_to_send() {
|
||||
*/
|
||||
void GCodeQueue::flush_and_request_resend(const serial_index_t serial_ind) {
|
||||
#if HAS_MULTI_SERIAL
|
||||
if (serial_ind < 0) return; // Never mind. Command came from SD or Flash Drive
|
||||
if (!serial_ind.valid()) return; // Optimization here, skip if the command came from SD or Flash Drive
|
||||
PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command
|
||||
#endif
|
||||
SERIAL_FLUSH();
|
||||
SERIAL_ECHOPGM(STR_RESEND);
|
||||
SERIAL_ECHOLN(serial_state[serial_ind].last_N + 1);
|
||||
SERIAL_ECHOLN(serial_state[serial_ind.index].last_N + 1);
|
||||
}
|
||||
|
||||
inline bool serial_data_available(uint8_t index) {
|
||||
inline bool serial_data_available(serial_index_t index) {
|
||||
const int a = SERIAL_IMPL.available(index);
|
||||
#if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE)
|
||||
if (a > RX_BUFFER_SIZE - 2) {
|
||||
@ -290,15 +290,15 @@ inline bool any_serial_data_available() {
|
||||
return true;
|
||||
}
|
||||
|
||||
inline int read_serial(const uint8_t index) { return SERIAL_IMPL.read(index); }
|
||||
inline int read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); }
|
||||
|
||||
void GCodeQueue::gcode_line_error(PGM_P const err, const serial_index_t serial_ind) {
|
||||
PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ECHOLNPAIR_P(err, serial_state[serial_ind].last_N);
|
||||
SERIAL_ECHOLNPAIR_P(err, serial_state[serial_ind.index].last_N);
|
||||
while (read_serial(serial_ind) != -1) { /* nada */ } // Clear out the RX buffer. Why don't use flush here ?
|
||||
flush_and_request_resend(serial_ind);
|
||||
serial_state[serial_ind].count = 0;
|
||||
serial_state[serial_ind.index].count = 0;
|
||||
}
|
||||
|
||||
FORCE_INLINE bool is_M29(const char * const cmd) { // matches "M29" & "M29 ", but not "M290", etc
|
||||
|
@ -79,13 +79,13 @@ public:
|
||||
|
||||
void commit_command(bool skip_ok
|
||||
#if HAS_MULTI_SERIAL
|
||||
, serial_index_t serial_ind=-1
|
||||
, serial_index_t serial_ind = serial_index_t()
|
||||
#endif
|
||||
);
|
||||
|
||||
bool enqueue(const char* cmd, bool skip_ok = true
|
||||
#if HAS_MULTI_SERIAL
|
||||
, serial_index_t serial_ind=-1
|
||||
, serial_index_t serial_ind = serial_index_t()
|
||||
#endif
|
||||
);
|
||||
|
||||
@ -197,7 +197,7 @@ public:
|
||||
/**
|
||||
* (Re)Set the current line number for the last received command
|
||||
*/
|
||||
static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port()].last_N = n; }
|
||||
static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -82,7 +82,7 @@ void GcodeSuite::M1001() {
|
||||
|
||||
// Announce SD file completion
|
||||
{
|
||||
PORT_REDIRECT(SERIAL_ALL);
|
||||
PORT_REDIRECT(SerialMask::All);
|
||||
SERIAL_ECHOLNPGM(STR_FILE_PRINTED);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user