Skip to content

Commit

Permalink
please install the editorconfig plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 18, 2021
1 parent 205ed9b commit 08adacf
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 18 deletions.
1 change: 0 additions & 1 deletion Marlin/src/HAL/LPC1768/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "../../inc/MarlinConfigPre.h"
#include "MarlinSerial.h"


#if ANY_SERIAL_IS(0)
MarlinSerial _MSerial(LPC_UART0);
MSerialT MSerial(true, _MSerial);
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/LPC1768/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class MarlinSerial : public HardwareSerial<RX_BUFFER_SIZE, TX_BUFFER_SIZE> {
#endif
};

// On LPC176x framework, HardwareSerial does not implement the same interface as Arduino's Serial, so overloads
// of 'available' and 'read' method are not used in this multiple inheritance scenario.
// Instead, use a ForwardSerial here that'll adapt the interface
// On LPC176x framework, HardwareSerial does not implement the same interface as Arduino's Serial, so overloads
// of 'available' and 'read' method are not used in this multiple inheritance scenario.
// Instead, use a ForwardSerial here that'll adapt the interface
typedef ForwardSerial0Type<MarlinSerial> MSerialT;
extern MSerialT MSerial;
extern MSerialT MSerial1;
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/core/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMST
MeatpackSerial<decltype(_SERIAL_IMPL)> mpSerial(false, _SERIAL_IMPL);
#endif


void serialprintPGM(PGM_P str) {
while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c);
}
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/core/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ extern uint8_t marlin_debug_flags;
#define SERIAL_IMPL _SERIAL_IMPL
#endif


#define SERIAL_OUT(WHAT, V...) (void)SERIAL_IMPL.WHAT(V)

#define PORT_REDIRECT(p) _PORT_REDIRECT(1,p)
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/core/serial_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct ConditionalSerial : public SerialBase< ConditionalSerial<SerialT> > {
int read(uint8_t ) { return (int)out.read(); }
bool available() { return (bool)out.available(); }
int read() { return (int)out.read(); }


ConditionalSerial(bool & conditionVariable, SerialT & out, const bool e) : BaseClassT(e), condition(conditionVariable), out(out) {}
};
Expand All @@ -99,7 +99,7 @@ struct ForwardSerial : public SerialBase< ForwardSerial<SerialT> > {
bool connected() { return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; }
void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); }

bool available(uint8_t) { return (bool)out.available(); }
bool available(uint8_t) { return (bool)out.available(); }
int read(uint8_t) { return (int)out.read(); }
bool available() { return (bool)out.available(); }
int read() { return (int)out.read(); }
Expand Down Expand Up @@ -242,4 +242,4 @@ struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset>
#endif

// Used in multiple places
typedef int8_t serial_index_t;
typedef int8_t serial_index_t;
12 changes: 6 additions & 6 deletions Marlin/src/feature/meatpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,22 @@ struct MeatpackSerial : public SerialBase <MeatpackSerial < SerialT >> {
bool connected() { return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; }
void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); }

bool available(uint8_t index) {
bool available(uint8_t index) {
// There is a potential issue here with multiserial, since it'll return its decoded buffer whatever the serial index here.
// So, instead of doing MeatpackSerial<MultiSerial<...>> we should do MultiSerial<MeatpackSerial<...>, MeatpackSerial<...>>
// TODO, let's fix this later on
return charCount > 0 || (bool)out.available(index);
return charCount > 0 || (bool)out.available(index);
}
int readImpl(uint8_t index) {
// DITTO
// DITTO
if (charCount > 0) return serialBuffer[sizeof(serialBuffer) - (charCount--)];

int r = out.read(index);
if (r == -1) return r;

meatpack.handle_rx_char((uint8_t)r, index);
charCount = meatpack.get_result_char(serialBuffer);
return serialBuffer[sizeof(serialBuffer) - (charCount--)];
charCount = meatpack.get_result_char(serialBuffer);
return serialBuffer[sizeof(serialBuffer) - (charCount--)];
}

int read(uint8_t index) { return readImpl(index); }
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/gcode/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ void GCodeQueue::get_serial_commands() {
#endif
}


const char serial_char = (char)c;

if (ISEOL(serial_char)) {
Expand Down Expand Up @@ -586,7 +585,7 @@ void GCodeQueue::get_serial_commands() {
}
else
process_stream_char(serial_char, serial_input_state[p], serial_line_buffer[p], serial_count[p]);

} // NUM_SERIAL loop
} // queue has space, serial has data
}
Expand Down Expand Up @@ -702,5 +701,4 @@ void GCodeQueue::advance() {
// The queue may be reset by a command handler or by code invoked by idle() within a handler
--length;
if (++index_r >= BUFSIZE) index_r = 0;

}

0 comments on commit 08adacf

Please sign in to comment.