Skip to content

Commit b4791f3

Browse files
ellenspthinkyhead
authored andcommitted
Meatpack::report_state on serial port init (MarlinFirmware#20903)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
1 parent 68af7a3 commit b4791f3

File tree

8 files changed

+13
-16
lines changed

8 files changed

+13
-16
lines changed

Marlin/src/core/serial.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PGMSTR(SP_X_STR, " X"); PGMSTR(SP_Y_STR, " Y"); PGMSTR(SP_Z_STR, " Z"); PGMST
3434
PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMSTR(SP_E_LBL, " E:");
3535

3636
#if HAS_MULTI_SERIAL
37-
int8_t serial_port_index = 0;
37+
serial_index_t serial_port_index = 0;
3838
#endif
3939

4040
void serialprintPGM(PGM_P str) {

Marlin/src/feature/meatpack.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ void MeatPack::reset_state() {
7474
second_char = 0;
7575
cmd_count = full_char_count = char_out_count = 0;
7676
TERN_(MP_DEBUG, chars_decoded = 0);
77-
report_state();
7877
}
7978

8079
/**
@@ -189,7 +188,7 @@ void MeatPack::report_state() {
189188
* Interpret a single character received from serial
190189
* according to the current meatpack state.
191190
*/
192-
void MeatPack::handle_rx_char(const uint8_t c) {
191+
void MeatPack::handle_rx_char(const uint8_t c, const serial_index_t serial_ind) {
193192
if (c == kCommandByte) { // A command (0xFF) byte?
194193
if (cmd_count) { // In fact, two in a row?
195194
cmd_is_next = true; // Then a MeatPack command follows
@@ -201,6 +200,7 @@ void MeatPack::handle_rx_char(const uint8_t c) {
201200
}
202201

203202
if (cmd_is_next) { // Were two command bytes received?
203+
PORT_REDIRECT(serial_ind);
204204
handle_command((MeatPack_Command)c); // Then the byte is a MeatPack command
205205
cmd_is_next = false;
206206
return;

Marlin/src/feature/meatpack.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class MeatPack {
101101

102102
// Pass in a character rx'd by SD card or serial. Automatically parses command/ctrl sequences,
103103
// and will control state internally.
104-
static void handle_rx_char(const uint8_t c);
104+
static void handle_rx_char(const uint8_t c, const serial_index_t serial_ind);
105105

106106
/**
107107
* After passing in rx'd char using above method, call this to get characters out.

Marlin/src/feature/spindle_laser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class SpindleLaser {
151151
#elif CUTTER_UNIT_IS(RPM)
152152
2
153153
#else
154-
#error "CUTTER_UNIT_IS(???)"
154+
#error "CUTTER_UNIT_IS(unknown)"
155155
#endif
156156
));
157157
}

Marlin/src/gcode/host/M118.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void GcodeSuite::M118() {
5353
}
5454

5555
#if HAS_MULTI_SERIAL
56-
const int8_t old_serial = serial_port_index;
56+
const serial_index_t old_serial = serial_port_index;
5757
if (WITHIN(port, 0, NUM_SERIAL))
5858
serial_port_index = (
5959
port == 0 ? SERIAL_BOTH

Marlin/src/gcode/queue.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@ class GCodeQueue {
5656
* The port that the command was received on
5757
*/
5858
#if HAS_MULTI_SERIAL
59-
static int16_t port[BUFSIZE];
59+
static serial_index_t port[BUFSIZE];
6060
#endif
61-
62-
static int16_t command_port() {
63-
return TERN0(HAS_MULTI_SERIAL, port[index_r]);
64-
}
61+
static inline serial_index_t command_port() { return TERN0(HAS_MULTI_SERIAL, port[index_r]); }
6562

6663
GCodeQueue();
6764

@@ -159,13 +156,13 @@ class GCodeQueue {
159156

160157
static void _commit_command(bool say_ok
161158
#if HAS_MULTI_SERIAL
162-
, int16_t p=-1
159+
, serial_index_t serial_ind=-1
163160
#endif
164161
);
165162

166163
static bool _enqueue(const char* cmd, bool say_ok=false
167164
#if HAS_MULTI_SERIAL
168-
, int16_t p=-1
165+
, serial_index_t serial_ind=-1
169166
#endif
170167
);
171168

@@ -181,7 +178,7 @@ class GCodeQueue {
181178
*/
182179
static bool enqueue_one(const char* cmd);
183180

184-
static void gcode_line_error(PGM_P const err, const int8_t pn);
181+
static void gcode_line_error(PGM_P const err, const serial_index_t serial_ind);
185182

186183
};
187184

Marlin/src/sd/cardreader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ void CardReader::fileHasFinished() {
12091209
uint8_t CardReader::auto_report_sd_interval = 0;
12101210
millis_t CardReader::next_sd_report_ms;
12111211
#if HAS_MULTI_SERIAL
1212-
int8_t CardReader::auto_report_port;
1212+
serial_index_t CardReader::auto_report_port;
12131213
#endif
12141214

12151215
void CardReader::auto_report_sd_status() {

Marlin/src/sd/cardreader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class CardReader {
268268
static uint8_t auto_report_sd_interval;
269269
static millis_t next_sd_report_ms;
270270
#if HAS_MULTI_SERIAL
271-
static int8_t auto_report_port;
271+
static serial_index_t auto_report_port;
272272
#endif
273273
#endif
274274

0 commit comments

Comments
 (0)