Skip to content

Commit

Permalink
Merge branch 'lts-develop/4.2.x' into lts-master/4.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
slav-at-attachix committed Oct 17, 2022
2 parents 0cb78da + 4cf5a69 commit e3f51c9
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 22 deletions.
10 changes: 7 additions & 3 deletions Sming/Arch/Esp32/Components/esp32/src/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ void esp_init_wifi()

void main(void*)
{
assert(esp_task_wdt_init(WDT_TIMEOUT_MS, true) == ESP_OK);
assert(esp_task_wdt_add(NULL) == ESP_OK);
assert(esp_task_wdt_status(NULL) == ESP_OK);
auto err = esp_task_wdt_init(CONFIG_ESP_TASK_WDT_TIMEOUT_S, true);
(void)err;
assert(err == ESP_OK);
err = esp_task_wdt_add(nullptr);
assert(err == ESP_OK);
err = esp_task_wdt_status(nullptr);
assert(err == ESP_OK);

hw_timer_init();

Expand Down
1 change: 1 addition & 0 deletions Sming/Arch/Esp8266/Components/driver/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ void smg_uart_uninit(smg_uart_t* uart)
break;
}

uartInstances[uart->uart_nr] = nullptr;
delete uart->rx_buffer;
delete uart->tx_buffer;
delete uart;
Expand Down
1 change: 1 addition & 0 deletions Sming/Arch/Host/Components/driver/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ void smg_uart_uninit(smg_uart_t* uart)
smg_uart_set_debug(UART_NO);
}

uartInstances[uart->uart_nr] = nullptr;
delete uart->rx_buffer;
delete uart->tx_buffer;
delete uart;
Expand Down
4 changes: 3 additions & 1 deletion Sming/Core/Data/Stream/LimitedMemoryStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ bool LimitedMemoryStream::moveString(String& s)
sizeOk = false;
}

assert(s.setBuffer({buffer, capacity, size - 1}));
bool res = s.setBuffer({buffer, capacity, size - 1});
(void)res;
assert(res);

owned = false;
buffer = nullptr;
Expand Down
4 changes: 3 additions & 1 deletion Sming/Core/Data/Stream/MemoryDataStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ bool MemoryDataStream::moveString(String& s)
bool sizeOk = ensureCapacity(size + 1);

// If we couldn't reallocate for the NUL terminator, drop the last character
assert(s.setBuffer({buffer, capacity, sizeOk ? size : size - 1}));
bool res = s.setBuffer({buffer, capacity, sizeOk ? size : size - 1});
(void)res;
assert(res);

buffer = nullptr;
readPos = 0;
Expand Down
13 changes: 6 additions & 7 deletions Sming/Core/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ HardwareSerial::~HardwareSerial()
#endif
}

void HardwareSerial::begin(uint32_t baud, SerialConfig config, SerialMode mode, uint8_t txPin, uint8_t rxPin)
bool HardwareSerial::begin(uint32_t baud, SerialConfig config, SerialMode mode, uint8_t txPin, uint8_t rxPin)
{
end();

if(uartNr < 0)
return;
if(uartNr < 0) {
return false;
}

smg_uart_config_t cfg = {
.uart_nr = (uint8_t)uartNr,
Expand All @@ -48,6 +49,8 @@ void HardwareSerial::begin(uint32_t baud, SerialConfig config, SerialMode mode,
};
uart = smg_uart_init_ex(cfg);
updateUartCallback();

return uart != nullptr;
}

void HardwareSerial::end()
Expand All @@ -56,10 +59,6 @@ void HardwareSerial::end()
return;
}

if(smg_uart_get_debug() == uartNr) {
smg_uart_set_debug(UART_NO);
}

smg_uart_uninit(uart);
uart = nullptr;
}
Expand Down
18 changes: 11 additions & 7 deletions Sming/Core/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ class HardwareSerial : public ReadWriteStream

/** @brief Initialise the serial port
* @param baud BAUD rate of the serial port (Default: 9600)
* @retval bool true on success
*/
void begin(uint32_t baud = 9600)
bool begin(uint32_t baud = 9600)
{
begin(baud, SERIAL_8N1, SERIAL_FULL, 1);
return begin(baud, SERIAL_8N1, SERIAL_FULL, 1);
}

/**
Expand All @@ -142,10 +143,11 @@ class HardwareSerial : public ReadWriteStream
* even (E), and no (N) parity, and 1 or 2 stop bits.
* To set the desired mode, call Serial.begin(baudrate, SERIAL_8N1),
* Serial.begin(baudrate, SERIAL_6E2), etc.
* @retval bool true on success
*/
void begin(uint32_t baud, SerialConfig config)
bool begin(uint32_t baud, SerialConfig config)
{
begin(baud, config, SERIAL_FULL, 1);
return begin(baud, config, SERIAL_FULL, 1);
}

/**
Expand All @@ -156,10 +158,11 @@ class HardwareSerial : public ReadWriteStream
* To set the desired mode, call Serial.begin(baudrate, SERIAL_8N1),
* Serial.begin(baudrate, SERIAL_6E2), etc.
* @param mode specifies if the UART supports receiving (RX), transmitting (TX) or both (FULL) operations
* @retval bool true on success
*/
void begin(uint32_t baud, SerialConfig config, SerialMode mode)
bool begin(uint32_t baud, SerialConfig config, SerialMode mode)
{
begin(baud, config, mode, 1);
return begin(baud, config, mode, 1);
}

/**
Expand All @@ -169,8 +172,9 @@ class HardwareSerial : public ReadWriteStream
* @param mode
* @param txPin Can specify alternate pin for TX
* @param rxPin
* @retval bool true on success
*/
void begin(uint32_t baud, SerialConfig config, SerialMode mode, uint8_t txPin, uint8_t rxPin = UART_PIN_DEFAULT);
bool begin(uint32_t baud, SerialConfig config, SerialMode mode, uint8_t txPin, uint8_t rxPin = UART_PIN_DEFAULT);

/**
* @brief De-inits the current UART if it is already used
Expand Down
2 changes: 1 addition & 1 deletion Sming/Wiring/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ void String::remove(size_t index, size_t count)
}
char* writeTo = buffer() + index;
len -= count;
memcpy(writeTo, writeTo + count, len - index);
memmove(writeTo, writeTo + count, len - index);
setlen(len);
}

Expand Down
2 changes: 1 addition & 1 deletion Sming/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ endif
# Convert Windows paths to POSIX paths
DEBUG_VARS += OS
ifeq ($(OS),Windows_NT)
FixPath = $(subst //,/,$(subst \,/,$(addprefix /,$(subst :,,$1))))
FixPath = $(if $(findstring :,$1),$(subst //,/,$(subst \,/,/$(subst :,,$1))),$(abspath $1))
else
FixPath = $1
endif
Expand Down
3 changes: 2 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ COMPONENT_RULE := __no_build__
COMPONENT_NAME := $1
COMPONENT_PATH := $2
COMPONENT_VARS :=
COMPONENT_RELINK_VARS :=
CONFIG_VARS :=
RELINK_VARS :=
CACHE_VARS :=
Expand All @@ -206,7 +207,7 @@ DOXYGEN_INPUT += $$(addprefix $2/,$$(COMPONENT_DOXYGEN_INPUT))
DOXYGEN_INCLUDE_PATH += $$(addprefix $2/,$$(COMPONENT_DOXYGEN_INCLUDE))
DOXYGEN_PREDEFINED += $$(COMPONENT_DOXYGEN_PREDEFINED)
#
COMPONENT_ENVVARS := $$(sort $$(COMPONENT_VARS) $$(CONFIG_VARS) $$(RELINK_VARS) $$(CACHE_VARS) $$(DEBUG_VARS))
COMPONENT_ENVVARS := $$(sort $$(COMPONENT_VARS) $$(COMPONENT_RELINK_VARS) $$(CONFIG_VARS) $$(RELINK_VARS) $$(CACHE_VARS) $$(DEBUG_VARS))
CMP_$2_ENVVARS := $$(COMPONENT_ENVVARS)

CMP_$2_DEPENDS := $$(COMPONENT_DEPENDS)
Expand Down
7 changes: 7 additions & 0 deletions tests/HostTests/modules/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ class StreamTest : public TestGroup
REQUIRE(Resource::image_png == s);
}

TEST_CASE("readString (PR #2468)")
{
FSTR::Stream stream(FS_abstract);
String s = stream.readString(0x10000);
REQUIRE(s == FS_abstract);
}

TEST_CASE("ChunkedStream / StreamTransformer")
{
DEFINE_FSTR_LOCAL(FS_INPUT, "Some test data");
Expand Down

0 comments on commit e3f51c9

Please sign in to comment.