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

Add support for M575 #14757

Merged
merged 7 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/HAL/HAL_LINUX/include/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ class HalSerial {

HalSerial() { host_connected = true; }

void begin(int32_t baud) {
}
void begin(int32_t baud) { }

void end() { }

int peek() {
uint8_t value;
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/HAL/HAL_LPC1768/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class MarlinSerial : public HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE> {
{
}

void end() { }

#if ENABLED(EMERGENCY_PARSER)
bool recv_callback(const char c) override {
emergency_parser.update(emergency_state, c);
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/HAL/shared/Marduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#undef M_PI // Redefined by all
#undef _BV // Redefined by some
#undef sq // Redefined by teensy3/wiring.h
#undef SBI // Redefined by arduino/const_functions.h
#undef CBI // Redefined by arduino/const_functions.h

#include <Arduino.h> // NOTE: If included earlier then this line is a NOOP

Expand Down
74 changes: 74 additions & 0 deletions Marlin/src/gcode/config/M575.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#include "../../inc/MarlinConfig.h"

#if ENABLED(BAUD_RATE_GCODE)

#include "../gcode.h"

/**
* M575 - Change serial baud rate
*
* P<index> - Serial port index. Omit for all.
* B<baudrate> - Baud rate (bits per second)
*/
void GcodeSuite::M575() {
const int32_t baud = parser.ulongval('B');
switch (baud) {
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_START();
SERIAL_ECHOLNPAIR(" Serial "
#if NUM_SERIAL > 1
, '0',
#else
"0"
#endif
" baud rate set to ", baud
);
}
#if NUM_SERIAL > 1
const bool set1 = (port == -99 || port == 1);
if (set1) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(" Serial ", '1', " baud rate set to ", baud);
}
#endif

SERIAL_FLUSH();

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

#if NUM_SERIAL > 1
if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); }
#endif

} break;
default: SERIAL_ECHO_MSG("?(B)aud rate is implausible.");
}
}

#endif // NUM_SERIAL > 0 && BAUD_RATE_GCODE
4 changes: 4 additions & 0 deletions Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 540: M540(); break; // M540: Set abort on endstop hit for SD printing
#endif

#if ENABLED(BAUD_RATE_GCODE)
case 575: M575(); break; // M575: Set serial baudrate
#endif

#if HAS_BED_PROBE
case 851: M851(); break; // M851: Set Z Probe Z Offset
#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,10 @@ class GcodeSuite {
static void M540();
#endif

#if ENABLED(BAUD_RATE_GCODE)
static void M575();
#endif

#if ENABLED(ADVANCED_PAUSE_FEATURE)
static void M600();
static void M603();
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -1738,3 +1738,7 @@
#define INIT_SDCARD_ON_BOOT
#endif
#endif

#if !NUM_SERIAL
#undef BAUD_RATE_GCODE
#endif
4 changes: 1 addition & 3 deletions buildroot/share/tests/LPC1768-tests
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ exec_test $1 $2 "Build Re-ARM Default Configuration"

restore_configs
opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB
opt_enable VIKI2 SDSUPPORT
opt_enable SERIAL_PORT2
opt_enable NEOPIXEL_LED
opt_enable VIKI2 SDSUPPORT SERIAL_PORT2 NEOPIXEL_LED BAUD_RATE_GCODE
opt_set NEOPIXEL_PIN P1_16
exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel"

Expand Down
6 changes: 3 additions & 3 deletions buildroot/share/tests/LPC1769-tests
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ opt_enable VIKI2 SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \
Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \
Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE BAUD_RATE_GCODE \
LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA
opt_set GRID_MAX_POINTS_X 16
exec_test $1 $2 "Smoothieboard Many Features"
Expand All @@ -31,7 +31,7 @@ opt_enable COREYX USE_XMAX_PLUG DAC_MOTOR_CURRENT_DEFAULT \
AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 EEPROM_SETTINGS \
FILAMENT_LCD_DISPLAY FILAMENT_WIDTH_SENSOR FAN_SOFT_PWM \
SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER FAN_KICKSTART_TIME \
SD_ABORT_ON_ENDSTOP_HIT ADVANCED_OK GCODE_MACROS \
SD_ABORT_ON_ENDSTOP_HIT ADVANCED_OK GCODE_MACROS BAUD_RATE_GCODE \
VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS ACTION_ON_KILL \
EXTRA_FAN_SPEED FWRETRACT MENU_ADDAUTOSTART SDCARD_SORT_ALPHA
opt_set FAN_MIN_PWM 50
Expand All @@ -42,7 +42,7 @@ exec_test $1 $2 "Azteeg X5 MINI WIFI Many less common options"
restore_configs
use_example_configs delta/generic
opt_set MOTHERBOARD BOARD_COHESION3D_REMIX
opt_enable AUTO_BED_LEVELING_BILINEAR EEPROM_SETTINGS EEPROM_CHITCHAT
opt_enable AUTO_BED_LEVELING_BILINEAR EEPROM_SETTINGS EEPROM_CHITCHAT BAUD_RATE_GCODE
opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
opt_set X_DRIVER_TYPE TMC2130
opt_set Y_DRIVER_TYPE TMC2130
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/tests/STM32F1-tests
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ opt_set EXTRUDERS 2
opt_set SERIAL_PORT -1
opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT \
PAREN_COMMENTS GCODE_MOTION_MODES SINGLENOZZLE TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_PARK \
GCODE_MACROS NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE
BAUD_RATE_GCODE GCODE_MACROS NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE
exec_test $1 $2 "STM32F1R EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT PAREN_COMMENTS GCODE_MOTION_MODES"

# cleanup
Expand Down
1 change: 1 addition & 0 deletions buildroot/share/tests/alfawise_U20-tests
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set -e
use_example_configs Alfawise/U20
opt_set MOTHERBOARD BOARD_LONGER3D_LK
opt_set SERIAL_PORT 1
opt_enable BAUD_RATE_GCODE
exec_test $1 $2 "Full-featured U20 config"

# cleanup
Expand Down
1 change: 1 addition & 0 deletions buildroot/share/tests/black_stm32f407ve-tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
set -e

use_example_configs STM32/Black_STM32F407VET6
opt_enable BAUD_RATE_GCODE
exec_test $1 $2 "Full-featured Sample Black STM32F407VET6 config"

# cleanup
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/tests/esp32-tests
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -e

restore_configs
opt_set MOTHERBOARD BOARD_ESP32
opt_enable WIFISUPPORT GCODE_MACROS
opt_enable WIFISUPPORT GCODE_MACROS BAUD_RATE_GCODE
opt_set "WIFI_SSID \"ssid\""
opt_set "WIFI_PWD \"password\""
opt_set TX_BUFFER_SIZE 64
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/tests/linux_native-tests
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -e
restore_configs
opt_set MOTHERBOARD BOARD_LINUX_RAMPS
opt_set TEMP_SENSOR_BED 1
opt_enable PIDTEMPBED EEPROM_SETTINGS
opt_enable PIDTEMPBED EEPROM_SETTINGS BAUD_RATE_GCODE
exec_test $1 $2 "Linux with EEPROM"

# cleanup
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/tests/megaatmega2560-tests
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TE
NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \
AUTO_BED_LEVELING_LINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \
BACKLASH_COMPENSATION BACKLASH_GCODE \
BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE \
FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
PSU_CONTROL AUTO_POWER_CONTROL POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE \
SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER \
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/tests/teensy35-tests
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ opt_set TEMP_SENSOR_0 1
opt_set TEMP_SENSOR_1 5
opt_set TEMP_SENSOR_BED 1
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \
FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE \
FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \
FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \
Expand Down
3 changes: 3 additions & 0 deletions config/default/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/3DFabXYZ/Migbot/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/AlephObjects/TAZ4/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/Alfawise/U20/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/AliExpress/UM2pExt/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/Anet/A2/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/Anet/A2plus/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/Anet/A6/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/Anet/A8/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/Anet/A8plus/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/Anet/E16/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/AnyCubic/i3/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/ArmEd/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/BIBO/TouchX/cyclops/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
3 changes: 3 additions & 0 deletions config/examples/BIBO/TouchX/default/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@
//#define SERIAL_XON_XOFF
#endif

// Add M575 G-code to change the baud rate
//#define BAUD_RATE_GCODE

#if ENABLED(SDSUPPORT)
// Enable this option to collect and display the maximum
// RX queue usage after transferring a file to SD.
Expand Down
Loading