Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 1.5.0-rc.3 Release Notes

Fixed a critical bug where the firmware could never connect to LCG, and addressed code correctness issues (variable initialization and type casting) along with compiler warning cleanups.

# Version 1.5.0-rc.2 Release Notes

This release candidate focuses on **E-Stop reliability**, **rate limiting behavior**, and **general internal cleanup and correctness improvements**.
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.5.0-rc.2",
"version": "1.5.0-rc.3",
"private": true,
"type": "module",
"scripts": {
Expand Down
34 changes: 20 additions & 14 deletions include/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,23 @@ constexpr const char* openshockPathToFileName(const char (&path)[N]) {

#define OS_PANIC_PRINT(TAG, format, ...) OS_LOGE(TAG, "PANIC: " format, ##__VA_ARGS__)

#define OS_PANIC(TAG, format, ...) \
OS_PANIC_PRINT(TAG, format ", restarting in 5 seconds...", ##__VA_ARGS__); \
vTaskDelay(pdMS_TO_TICKS(5000)); \
esp_restart()

#define OS_PANIC_OTA(TAG, format, ...) \
OS_PANIC_PRINT(TAG, format ", invalidating update partition and restarting in 5 seconds...", ##__VA_ARGS__); \
vTaskDelay(pdMS_TO_TICKS(5000)); \
esp_ota_mark_app_invalid_rollback_and_reboot(); \
esp_restart()

#define OS_PANIC_INSTANT(TAG, format, ...) \
OS_PANIC_PRINT(TAG, format, ##__VA_ARGS__); \
esp_restart()
#define OS_PANIC(TAG, format, ...) \
{ \
OS_PANIC_PRINT(TAG, format ", restarting in 5 seconds...", ##__VA_ARGS__); \
vTaskDelay(pdMS_TO_TICKS(5000)); \
esp_restart(); \
}

#define OS_PANIC_OTA(TAG, format, ...) \
{ \
OS_PANIC_PRINT(TAG, format ", invalidating update partition and restarting in 5 seconds...", ##__VA_ARGS__); \
vTaskDelay(pdMS_TO_TICKS(5000)); \
esp_ota_mark_app_invalid_rollback_and_reboot(); \
esp_restart(); \
}

#define OS_PANIC_INSTANT(TAG, format, ...) \
{ \
OS_PANIC_PRINT(TAG, format, ##__VA_ARGS__); \
esp_restart(); \
}
5 changes: 3 additions & 2 deletions include/TinyVec.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "Common.h"
#include "Logging.h"

#include <cstdint>
#include <cstdlib>
Expand Down Expand Up @@ -69,10 +70,10 @@ class TinyVec {
void reserve(SizeType new_cap)
{
if (new_cap <= _cap) return;
if (sizeof(T) && new_cap > std::numeric_limits<SizeType>::max() / sizeof(T)) throw std::bad_alloc();
if (sizeof(T) && new_cap > std::numeric_limits<SizeType>::max() / sizeof(T)) OS_PANIC_INSTANT("TVEC", "Cannot allocate a buffer of given size!");

void* newbuf = malloc(size_t(new_cap) * sizeof(T));
if (!newbuf) throw std::bad_alloc();
if (!newbuf) OS_PANIC_INSTANT("TVEC", "Could not allocate a buffer of given size!");
if (_data) {
memcpy(newbuf, _data, size_t(_len) * sizeof(T));
free(_data);
Expand Down
2 changes: 1 addition & 1 deletion include/radio/rmt/Sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace OpenShock::Rmt {
m_size = 0;
m_transmitEnd = 0;
m_shockerId = 0;
m_shockerModel = (ShockerModelType)0;
m_shockerModel = static_cast<ShockerModelType>(0);
}

rmt_data_t* m_data;
Expand Down
23 changes: 14 additions & 9 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ platform = espressif32 @ 6.12.0
board = az-delivery-devkit-v4 ; Overridden per board
framework = arduino

; Most warnings here are commented out because the compiler detects warnings outside own code, if we can disable external files for warnings that would be amazing!
build_flags =
-std=c++2a
-std=gnu++2a
-fno-exceptions
-DCONFIG_ASYNC_TCP_QUEUE_SIZE=256
build_unflags =
-std=gnu++11

; Most warnings here are commented out because the compiler detects warnings outside own code, build_src_flags is meant to only be for our code but doesnt seem to work in this instance...
build_src_flags =
-Wall
-Wextra
;-Wpedantic
;-Werror
;-Wcast-align
;-Wcast-qual
;-Wctor-dtor-privacy
Expand All @@ -29,23 +36,21 @@ build_flags =
-Wlogical-op
;-Wmissing-declarations
-Wmissing-include-dirs
;-Wnoexcept
-Wnoexcept
;-Wold-style-cast
;-Woverloaded-virtual
;-Wredundant-decls
;-Wshadow
;-Wsign-conversion
;-Wsign-promo
;-Wstrict-null-sentinel
;-Wstrict-overflow=5
-Wsign-promo
-Wstrict-null-sentinel
-Wstrict-overflow=5
-Wswitch-default
;-Wundef
;-Werror
-Wno-unused
-Wno-unknown-pragmas
-DCONFIG_ASYNC_TCP_QUEUE_SIZE=256
build_unflags =
-std=gnu++11
;-Weffc++

lib_deps =
https://github.com/google/flatbuffers#8b02fe6178427b96aea25396b53ea4ae8cadd7d8
https://github.com/OpenShock/ESPAsyncWebServer#469816c6bd287e3ecdda9e519c2532db019aa3c1
Expand Down
2 changes: 1 addition & 1 deletion scripts/embed_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ def print_dump(name: str, map: Mapping[str, str | int | bool]) -> None:
cpp_defines = serialize_cpp_defines(cpp_defines)

print('Build type: ' + pio_build_type)
print('Build defines: ' + str(cpp_defines))

# Set PIO variables.
env['BUILD_TYPE'] = pio_build_type
env['BUILD_FLAGS'] = remaining_build_flags
env.Append(CPPDEFINES=list(cpp_defines.items()))
env.Append(CXXFLAGS=['-fno-rtti', '-fno-threadsafe-statics', '-fno-use-cxa-atexit'])

# Rename the firmware.bin to app.bin.
env.Replace(PROGNAME='app')
Expand Down
5 changes: 4 additions & 1 deletion src/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ bool _internalSetKeepAliveEnabled(bool enabled)
OS_LOGV(TAG, "Disabling keep-alive task");
if (s_keepAliveTaskHandle != nullptr && s_keepAliveQueue != nullptr) {
// Wait for the task to stop
KnownShocker cmd {.killTask = true};
KnownShocker cmd;
memset(&cmd, 0, sizeof(cmd));
cmd.killTask = true;

while (eTaskGetState(s_keepAliveTaskHandle) != eDeleted) {
vTaskDelay(pdMS_TO_TICKS(10));

Expand Down
4 changes: 2 additions & 2 deletions src/GatewayConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ bool StartConnectingToLCG()
return false;
}

OS_LOGD(TAG, "Connecting to LCG endpoint { host: '%s', port: %hu, path: '%s' } in country %s", response.data.host.c_str(), response.data.port, response.data.path.c_str(), response.data.country.c_str());
OS_LOGI(TAG, "Connecting to LCG endpoint { host: '%s', port: %hu, path: '%s' } in country %s", response.data.host.c_str(), response.data.port, response.data.path.c_str(), response.data.country.c_str());
s_wsClient->connect(response.data.host, response.data.port, response.data.path);

return true;
Expand All @@ -283,7 +283,7 @@ void GatewayConnectionManager::Update()
}

// Fetch hub info
if (!FetchHubInfo(std::move(authToken))) {
if (!FetchHubInfo(authToken)) {
return;
}

Expand Down
7 changes: 5 additions & 2 deletions src/radio/RFTransmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ void RFTransmitter::destroy()
OS_LOGD(TAG, "[pin-%hhi] Stopping task", m_txPin);

// Wait for the task to stop
Command cmd {.flags = kFlagDeleteTask};
Command cmd;
memset(&cmd, 0, sizeof(cmd));
cmd.flags = kFlagDeleteTask;

while (eTaskGetState(m_taskHandle) != eDeleted) {
vTaskDelay(pdMS_TO_TICKS(10));

Expand Down Expand Up @@ -183,7 +186,7 @@ static void writeSequences(rmt_obj_t* rmt_handle, std::vector<Rmt::Sequence>& se
rmtWriteBlocking(rmt_handle, seq->payload(), seq->size());
} else {
// Remove command if it has sent out its termination sequence for long enough
if (timeToLive + kTerminatorDurationMs <= 0) {
if (timeToLive <= -kTerminatorDurationMs) {
seq = sequences.erase(seq);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/serial/SerialInputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const char* const TAG = "SerialInputHandler";

namespace std {
struct hash_ci {
std::size_t operator()(std::string_view str) const
std::size_t operator()(std::string_view str) const noexcept
{
std::size_t hash = 7;

Expand Down
2 changes: 1 addition & 1 deletion src/serialization/JsonAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ bool JsonAPI::ParseAssignLcgJsonResponse(int code, const cJSON* root, JsonAPI::A
out = {};

out.host = host->valuestring;
out.port = (uint16_t)portInt;
out.port = static_cast<uint16_t>(portInt);
out.path = path->valuestring;
out.country = country->valuestring;

Expand Down
Loading