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

Fix exception related to ENABLE_CMD_EXECUTOR definition #1668

Merged
merged 1 commit into from
Apr 15, 2019
Merged
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
Fix exception related to ENABLE_CMD_EXECUTOR definition
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.
mikee47 committed Apr 13, 2019
commit dbb5013c96bac1f539e1575f09093bc0e8a33c8a
6 changes: 1 addition & 5 deletions Sming/SmingCore/HardwareSerial.h
Original file line number Diff line number Diff line change
@@ -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,
@@ -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;