Use PGM_P for PSTR pointers (#11977)
This commit is contained in:
@@ -108,7 +108,7 @@ void ac_cleanup(
|
||||
#endif
|
||||
}
|
||||
|
||||
void print_signed_float(const char * const prefix, const float &f) {
|
||||
void print_signed_float(PGM_P const prefix, const float &f) {
|
||||
SERIAL_PROTOCOLPGM(" ");
|
||||
serialprintPGM(prefix);
|
||||
SERIAL_PROTOCOLCHAR(':');
|
||||
@@ -517,7 +517,7 @@ void GcodeSuite::G33() {
|
||||
}
|
||||
|
||||
// Report settings
|
||||
const char* checkingac = PSTR("Checking... AC");
|
||||
PGM_P checkingac = PSTR("Checking... AC");
|
||||
serialprintPGM(checkingac);
|
||||
if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
|
||||
if (set_up) SERIAL_PROTOCOLPGM(" (SET-UP)");
|
||||
@@ -705,7 +705,7 @@ void GcodeSuite::G33() {
|
||||
}
|
||||
}
|
||||
else { // dry run
|
||||
const char *enddryrun = PSTR("End DRY-RUN");
|
||||
PGM_P enddryrun = PSTR("End DRY-RUN");
|
||||
serialprintPGM(enddryrun);
|
||||
SERIAL_PROTOCOL_SP(35);
|
||||
SERIAL_PROTOCOLPGM("std dev:");
|
||||
|
@@ -50,8 +50,8 @@
|
||||
*
|
||||
* Also, there are two support functions that can be called from a developer's C code.
|
||||
*
|
||||
* uint16_t check_for_free_memory_corruption(const char * const ptr);
|
||||
* void M100_dump_routine(const char * const title, const char *start, const char *end);
|
||||
* uint16_t check_for_free_memory_corruption(PGM_P const ptr);
|
||||
* void M100_dump_routine(PGM_P const title, const char *start, const char *end);
|
||||
*
|
||||
* Initial version by Roxy-3D
|
||||
*/
|
||||
@@ -80,7 +80,7 @@ char* top_of_stack() {
|
||||
// Count the number of test bytes at the specified location.
|
||||
inline int32_t count_test_bytes(const char * const ptr) {
|
||||
for (uint32_t i = 0; i < 32000; i++)
|
||||
if (((char) ptr[i]) != TEST_BYTE)
|
||||
if (char(ptr[i]) != TEST_BYTE)
|
||||
return i - 1;
|
||||
|
||||
return -1;
|
||||
@@ -136,8 +136,9 @@ inline int32_t count_test_bytes(const char * const ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
void M100_dump_routine(const char * const title, const char *start, const char *end) {
|
||||
SERIAL_ECHOLN(title);
|
||||
void M100_dump_routine(PGM_P const title, const char *start, const char *end) {
|
||||
serialprintPGM(title);
|
||||
SERIAL_EOL();
|
||||
//
|
||||
// Round the start and end locations to produce full lines of output
|
||||
//
|
||||
@@ -148,8 +149,8 @@ inline int32_t count_test_bytes(const char * const ptr) {
|
||||
|
||||
#endif // M100_FREE_MEMORY_DUMPER
|
||||
|
||||
inline int check_for_free_memory_corruption(const char * const title) {
|
||||
SERIAL_ECHO(title);
|
||||
inline int check_for_free_memory_corruption(PGM_P const title) {
|
||||
serialprintPGM(title);
|
||||
|
||||
char *ptr = END_OF_HEAP(), *sp = top_of_stack();
|
||||
int n = sp - ptr;
|
||||
@@ -171,7 +172,7 @@ inline int check_for_free_memory_corruption(const char * const title) {
|
||||
// idle();
|
||||
safe_delay(20);
|
||||
#if ENABLED(M100_FREE_MEMORY_DUMPER)
|
||||
M100_dump_routine(" Memory corruption detected with sp<Heap\n", (char*)0x1B80, (char*)0x21FF);
|
||||
M100_dump_routine(PSTR(" Memory corruption detected with sp<Heap\n"), (char*)0x1B80, (char*)0x21FF);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -239,7 +240,7 @@ inline void free_memory_pool_report(char * const ptr, const int32_t size) {
|
||||
SERIAL_ECHOPAIR("\nLargest free block is ", max_cnt);
|
||||
SERIAL_ECHOLNPAIR(" bytes at ", hex_address(max_addr));
|
||||
}
|
||||
SERIAL_ECHOLNPAIR("check_for_free_memory_corruption() = ", check_for_free_memory_corruption("M100 F "));
|
||||
SERIAL_ECHOLNPAIR("check_for_free_memory_corruption() = ", check_for_free_memory_corruption(PSTR("M100 F ")));
|
||||
}
|
||||
|
||||
#if ENABLED(M100_FREE_MEMORY_CORRUPTOR)
|
||||
|
@@ -38,7 +38,7 @@ void GcodeSuite::M111() {
|
||||
#endif
|
||||
;
|
||||
|
||||
static const char* const debug_strings[] PROGMEM = {
|
||||
static PGM_P const debug_strings[] PROGMEM = {
|
||||
str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
, str_debug_32
|
||||
|
@@ -170,7 +170,7 @@ void GcodeSuite::dwell(millis_t time) {
|
||||
// Placeholders for non-migrated codes
|
||||
//
|
||||
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
||||
extern void M100_dump_routine(const char * const title, const char *start, const char *end);
|
||||
extern void M100_dump_routine(PGM_P const title, const char *start, const char *end);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -700,7 +700,7 @@ void GcodeSuite::process_next_command() {
|
||||
SERIAL_ECHOLN(current_command);
|
||||
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
||||
SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
|
||||
M100_dump_routine(" Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
|
||||
M100_dump_routine(PSTR(" Command Queue:"), (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -714,14 +714,14 @@ void GcodeSuite::process_next_command() {
|
||||
* Run a series of commands, bypassing the command queue to allow
|
||||
* G-code "macros" to be called from within other G-code handlers.
|
||||
*/
|
||||
void GcodeSuite::process_subcommands_now_P(const char *pgcode) {
|
||||
void GcodeSuite::process_subcommands_now_P(PGM_P pgcode) {
|
||||
// Save the parser state
|
||||
char * const saved_cmd = parser.command_ptr;
|
||||
|
||||
// Process individual commands in string
|
||||
while (pgm_read_byte_near(pgcode)) {
|
||||
// Break up string at '\n' delimiters
|
||||
const char *delim = strchr_P(pgcode, '\n');
|
||||
PGM_P const delim = strchr_P(pgcode, '\n');
|
||||
size_t len = delim ? delim - pgcode : strlen_P(pgcode);
|
||||
char cmd[len + 1];
|
||||
strncpy_P(cmd, pgcode, len);
|
||||
|
@@ -295,7 +295,7 @@ public:
|
||||
static void process_next_command();
|
||||
|
||||
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
||||
static void process_subcommands_now_P(const char *pgcode);
|
||||
static void process_subcommands_now_P(PGM_P pgcode);
|
||||
#endif
|
||||
|
||||
FORCE_INLINE static void home_all_axes() { G28(true); }
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTENDED_CAPABILITIES_REPORT)
|
||||
static void cap_line(const char * const name, bool ena=false) {
|
||||
static void cap_line(PGM_P const name, bool ena=false) {
|
||||
SERIAL_PROTOCOLPGM("Cap:");
|
||||
serialprintPGM(name);
|
||||
SERIAL_CHAR(':');
|
||||
|
@@ -258,7 +258,7 @@ public:
|
||||
FORCE_INLINE static char temp_units_code() {
|
||||
return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C';
|
||||
}
|
||||
FORCE_INLINE static const char* temp_units_name() {
|
||||
FORCE_INLINE static PGM_P temp_units_name() {
|
||||
return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
|
||||
}
|
||||
static inline float to_temp_units(const float &f) {
|
||||
|
@@ -84,7 +84,7 @@ bool send_ok[BUFSIZE];
|
||||
* Used by Marlin internally to ensure that commands initiated from within
|
||||
* are enqueued ahead of any pending serial or sd card commands.
|
||||
*/
|
||||
static const char *injected_commands_P = NULL;
|
||||
static PGM_P injected_commands_P = NULL;
|
||||
|
||||
void queue_setup() {
|
||||
// Send "ok" after commands by default
|
||||
@@ -181,7 +181,7 @@ static bool drain_injected_commands_P() {
|
||||
* Aborts the current queue, if any.
|
||||
* Note: drain_injected_commands_P() must be called repeatedly to drain the commands afterwards
|
||||
*/
|
||||
void enqueue_and_echo_commands_P(const char * const pgcode) {
|
||||
void enqueue_and_echo_commands_P(PGM_P const pgcode) {
|
||||
injected_commands_P = pgcode;
|
||||
(void)drain_injected_commands_P(); // first command executed asap (when possible)
|
||||
}
|
||||
@@ -197,7 +197,7 @@ void enqueue_and_echo_commands_P(const char * const pgcode) {
|
||||
/**
|
||||
* Enqueue from program memory and return only when commands are actually enqueued
|
||||
*/
|
||||
void enqueue_and_echo_commands_now_P(const char * const pgcode) {
|
||||
void enqueue_and_echo_commands_now_P(PGM_P const pgcode) {
|
||||
enqueue_and_echo_commands_P(pgcode);
|
||||
while (drain_injected_commands_P()) idle();
|
||||
}
|
||||
@@ -249,7 +249,7 @@ void flush_and_request_resend() {
|
||||
ok_to_send();
|
||||
}
|
||||
|
||||
void gcode_line_error(const char* err, uint8_t port) {
|
||||
void gcode_line_error(PGM_P err, uint8_t port) {
|
||||
SERIAL_ERROR_START_P(port);
|
||||
serialprintPGM_P(port, err);
|
||||
SERIAL_ERRORLN_P(port, gcode_LastN);
|
||||
|
@@ -90,7 +90,7 @@ void ok_to_send();
|
||||
* Aborts the current queue, if any.
|
||||
* Note: drain_injected_commands_P() must be called repeatedly to drain the commands afterwards
|
||||
*/
|
||||
void enqueue_and_echo_commands_P(const char * const pgcode);
|
||||
void enqueue_and_echo_commands_P(PGM_P const pgcode);
|
||||
|
||||
/**
|
||||
* Enqueue with Serial Echo
|
||||
@@ -109,7 +109,7 @@ bool enqueue_and_echo_command(const char* cmd);
|
||||
/**
|
||||
* Enqueue from program memory and return only when commands are actually enqueued
|
||||
*/
|
||||
void enqueue_and_echo_commands_now_P(const char * const cmd);
|
||||
void enqueue_and_echo_commands_now_P(PGM_P const cmd);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user