Skip to content

Commit

Permalink
Fix exception related to ENABLE_CMD_EXECUTOR definition (#1668)
Browse files Browse the repository at this point in the history
If framework is built with `ENABLE_CMD_EXECUTOR` disabled (0), but application is built with it enabled, serial receive causes an exception.
This happens because the member data for `HardwareSerial` gets shifted by 4 bytes, so `uart` becomes invalid (we get `options` instead, usually 1).

It is safer to always build with `HardwareSerial::commandExecutor` included.
  • Loading branch information
mikee47 authored and slaff committed Apr 15, 2019
1 parent 0bbe6b2 commit 4311a9c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions Sming/SmingCore/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ typedef Delegate<void(Stream& source, char arrivedChar, uint16_t availableCharsC
*/
typedef Delegate<void(HardwareSerial& serial)> TransmitCompleteDelegate;

#if ENABLE_CMD_EXECUTOR
class CommandExecutor;
#endif

enum SerialConfig {
SERIAL_5N1 = UART_5N1,
Expand Down Expand Up @@ -438,9 +436,7 @@ class HardwareSerial : public ReadWriteStream
int uartNr = -1;
TransmitCompleteDelegate transmitComplete = nullptr; ///< Callback for transmit completion
StreamDataReceivedDelegate HWSDelegate = nullptr; ///< Callback for received data
#if ENABLE_CMD_EXECUTOR
CommandExecutor* commandExecutor = nullptr; ///< Callback for command execution (received data)
#endif
CommandExecutor* commandExecutor = nullptr; ///< Callback for command execution (received data)
uart_t* uart = nullptr;
uart_options_t options = _BV(UART_OPT_TXWAIT);
size_t txSize = DEFAULT_TX_BUFFER_SIZE;
Expand Down

0 comments on commit 4311a9c

Please sign in to comment.