Fix PROGMEM addressing in debug.h
I hate when the compiler doesn't check something what it normally does: `pgm_read_byte` is more than happy with a parameter (*str), which reads an address at a location where *str points to - which is obviously not the intent.pull/126/head
parent
236a40c6ef
commit
f18ff63cf7
|
|
@ -22,12 +22,12 @@ const char hal[] PROGMEM = "hal:";
|
|||
#endif
|
||||
|
||||
void dbg_usart(const char *layer_P, const char *s) {
|
||||
hu::usart1.puts_P(layer_P);
|
||||
hu::usart1.WriteS_P(layer_P);
|
||||
hu::usart1.puts(s);
|
||||
}
|
||||
|
||||
void dbg_usart_P(const char *layer_P, const char *s_P) {
|
||||
hu::usart1.puts_P(layer_P);
|
||||
hu::usart1.WriteS_P(layer_P);
|
||||
hu::usart1.puts_P(s_P);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,18 +65,26 @@ void USART::Flush() {
|
|||
// the hardware finished tranmission (TXC is set).
|
||||
}
|
||||
|
||||
void USART::puts(const char *str) {
|
||||
while (*str) {
|
||||
void USART::WriteS(const char *str) {
|
||||
while (*str != 0) {
|
||||
Write(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
void USART::WriteS_P(const char *str_P) {
|
||||
char c = 0;
|
||||
while ((c = pgm_read_byte(str_P++)) != 0) {
|
||||
Write(c);
|
||||
}
|
||||
}
|
||||
|
||||
void USART::puts(const char *str) {
|
||||
WriteS(str);
|
||||
Write('\n');
|
||||
}
|
||||
|
||||
void USART::puts_P(const char *str) {
|
||||
char c;
|
||||
while ((c = pgm_read_byte(*str++)) != 0) {
|
||||
Write(c);
|
||||
}
|
||||
void USART::puts_P(const char *str_P) {
|
||||
WriteS_P(str_P);
|
||||
Write('\n');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,12 +45,19 @@ public:
|
|||
|
||||
/// @param c character to be pushed into the TX buffer (to be sent)
|
||||
void Write(uint8_t c);
|
||||
/// @param str pointer to a string in RAM to be pushed byte-by-byte into the TX buffer (to be sent)
|
||||
/// No NL character is appended
|
||||
void WriteS(const char *str);
|
||||
/// @param str pointer to a string in PROGMEM to be pushed byte-by-byte into the TX buffer (to be sent)
|
||||
/// No NL character is appended
|
||||
void WriteS_P(const char *str_P);
|
||||
|
||||
/// @param str c string to be sent. NL is appended
|
||||
/// Works on RAM strings
|
||||
void puts(const char *str);
|
||||
/// @param str c string to be sent. NL is appended
|
||||
/// Works on PROGMEM strings
|
||||
void puts_P(const char *str);
|
||||
void puts_P(const char *str_P);
|
||||
/// @returns true if there is at least one byte free in the TX buffer (i.e. some space to add a character to be sent)
|
||||
bool CanWrite() const {
|
||||
return !tx_buf.full();
|
||||
|
|
|
|||
Loading…
Reference in New Issue