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

M575: Fix port number output, '0' was port 48 #22553

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Changes from all commits
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
20 changes: 13 additions & 7 deletions Marlin/src/gcode/config/M575.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,25 @@ void GcodeSuite::M575() {
case 2400: case 9600: case 19200: case 38400: case 57600:
case 115200: case 250000: case 500000: case 1000000: {
const int8_t port = parser.intval('P', -99);
const bool set0 = (port == -99 || port == 0);
if (set0) SERIAL_ECHO_MSG(" Serial ", '0', " baud rate set to ", baud);
const bool set1 = (port == -99 || port == 0);
if (set1) SERIAL_ECHO_MSG(" Serial ", AS_CHAR('0'), " baud rate set to ", baud);
#if HAS_MULTI_SERIAL
const bool set1 = (port == -99 || port == 1);
if (set1) SERIAL_ECHO_MSG(" Serial ", '1', " baud rate set to ", baud);
const bool set2 = (port == -99 || port == 1);
if (set2) SERIAL_ECHO_MSG(" Serial ", AS_CHAR('1'), " baud rate set to ", baud);
#ifdef SERIAL_PORT_3
const bool set3 = (port == -99 || port == 2);
if (set3) SERIAL_ECHO_MSG(" Serial ", AS_CHAR('2'), " baud rate set to ", baud);
#endif
#endif

SERIAL_FLUSH();

if (set0) { MYSERIAL1.end(); MYSERIAL1.begin(baud); }

if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); }
#if HAS_MULTI_SERIAL
if (set1) { MYSERIAL2.end(); MYSERIAL2.begin(baud); }
if (set2) { MYSERIAL2.end(); MYSERIAL2.begin(baud); }
#ifdef SERIAL_PORT_3
if (set3) { MYSERIAL3.end(); MYSERIAL3.begin(baud); }
#endif
#endif

} break;
Expand Down