Skip to content

Commit

Permalink
Merge pull request #207 from es-ude/EOFLine
Browse files Browse the repository at this point in the history
refactor(clang): add EOF empty line
  • Loading branch information
DerDavidos authored Mar 15, 2024
2 parents 4792a64 + 6bfce06 commit 2fbe74b
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .asciidoctorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:toc: top
:icons: font
:source-highlighter: rouge
:imagesdir: {src-dir}/documentation/pics
:imagesdir: {src-dir}/documentation/pics
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Language: Cpp
IndentWidth: 4
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
#InsertBraces: true # available since llvm 15 (too new)
InsertNewlineAtEOF: true # 16
InsertBraces: true # 15
11 changes: 6 additions & 5 deletions .github/workflows/run_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ jobs:
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.PUSH_TOKEN }}
- name: Install clang-format
run: |
sudo apt update
sudo apt install -y clang-format
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "17"
directory: ${{ runner.temp }}/llvm
- name: Get C Files
run: |
echo SRC=$(git ls-tree --full-tree -r HEAD | grep -e "\.\(c\|h\)\$" | cut -f 2 | grep -v ^extern) >> $GITHUB_ENV
Expand All @@ -47,7 +48,7 @@ jobs:
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "refactor(beautify): ${{ github.head_ref }}"
commit_message: "style(all): apply clang-format to '${{ github.head_ref }}'"
commit_user_name: github-actions
commit_user_email: [email protected]
commit_author: github-actions <[email protected]>
Expand Down
Empty file removed .gitmodules
Empty file.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: no-commit-to-branch
stages: [ commit, manual ]
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
rev: v18.1.1
hooks:
- id: clang-format
stages: [ commit, manual ]
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@ NOTE: These submodules will automatically downloaded by CMake on initialization!
== Troubleshooting
* To generate a clean CMake Build without deleting and reinitializing the build directory run `cmake --build <build_dir> --target clean`.
* If the device doesn't connect to the wifi or mqtt broker make sure that you set up the correct credentials! (link:src/network/config/NetworkConfig.c[NetworkConfig.c])
* If the device doesn't connect to the wifi or mqtt broker make sure that you set up the correct credentials! (link:src/network/config/NetworkConfig.c[NetworkConfig.c])
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ module.exports = {
]
]
}
}
}
2 changes: 1 addition & 1 deletion documentation/SETUP_GUIDE.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ If the serial output is not initialized properly (see integration tests), the en
== Further Reading
* link:../README.adoc[README]
* link:../src/fpga/Vivado_Debugger.adoc[Debugging the FPGA]
* link:../src/fpga/Vivado_Debugger.adoc[Debugging the FPGA]
Binary file modified documentation/pics/dependencies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ nodeenv==1.8.0
platformdirs==4.0.0
pre-commit==3.5.0
PyYAML==6.0.1
virtualenv==20.24.7
virtualenv==20.24.7
2 changes: 1 addition & 1 deletion src/flash/Flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ static flashErrorCode_t flashEraseErrorOccurred(void) {
static void flashWaitForDone(void) {
while (flashReadStatusRegister() & 0x01) {}
}
/* endregion INTERNAL HEADER FUNCTIONS */
/* endregion INTERNAL HEADER FUNCTIONS */
6 changes: 3 additions & 3 deletions src/network/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The https://docs.espressif.com/projects/esp-at/en/release-v2.2.0.0_esp8266/AT_Co
The wifi library provided under link:wifi/[wifi] provides all required functions to connect to a local wifi network.

To connect to a network, the SSID and Password has to be passed to the library.
The CMake scripts will automatically create a `NetworkConfig.c` inside the project root directory.
The CMake scripts will automatically create a `NetworkConfig.c` inside the link:./config/[config folder].
When you want to use wifi capabilities you than have to add the `network_config` library to your source code.

.Example
Expand Down Expand Up @@ -85,7 +85,7 @@ To properly handle the received answer from the ESP32 module it is required to r
This handler is automatically set when the broker connection was successful.

To connect to a broker, the required credentials have to be passed to the library.
The CMake scripts will automatically create a `NetworkConfig.c` inside the project root directory.
The CMake scripts will automatically create a `NetworkConfig.c` inside the link:./config[config folder].
When you want to use mqtt capabilities you than have to add the `network_config` library to your source code.

IMPORTANT: The `clientId` of every device has to be different
Expand Down Expand Up @@ -136,4 +136,4 @@ create_enV5_executable(my-network-app)
----
====

CAUTION: When MQTT messages are sent to fast to the device, some messages will be dropped!
CAUTION: When MQTT messages are sent to fast to the device, some messages will be dropped!
33 changes: 5 additions & 28 deletions src/network/config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
IF(NOT WIFI_SSID)
SET(WIFI_SSID SSID)
ENDIF()
IF(NOT WIFI_PWD)
SET(WIFI_PWD PASSWORD)
ENDIF()
IF(NOT MQTT_HOST)
SET(MQTT_HOST 0.0.0.0)
ENDIF()
IF(NOT MQTT_PORT)
SET(MQTT_PORT 1883)
ENDIF()


if (NOT EXISTS ${CMAKE_SOURCE_DIR}/NetworkConfig.c)
file(WRITE ${CMAKE_SOURCE_DIR}/NetworkConfig.c "
#include \"Network.h\"
if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/NetworkConfig.c)
file(WRITE NetworkConfig.c "#include \"Network.h\"
#include \"MqttBroker.h\"
networkCredentials_t networkCredentials = {
.ssid = \"${WIFI_SSID}\",
.password = \"${WIFI_PWD}\"
};
mqttBrokerHost_t mqttHost = {
.ip = \"${MQTT_HOST}\",
.port = \"${MQTT_PORT}\",
.userID = \"${MQTT_USER}\",
.password = \"${MQTT_PWD}\"
};
networkCredentials_t networkCredentials = {.ssid = \"SSID\", .password = \"password\"};
mqttBrokerHost_t mqttHost = {.ip = \"0.0.0.0\", .port = \"1883\", .userID = \"\", .password = \"\"};
")
endif ()

add_library(network_config INTERFACE)
target_sources(network_config INTERFACE
${CMAKE_SOURCE_DIR}/NetworkConfig.c)
${CMAKE_CURRENT_LIST_DIR}/NetworkConfig.c)
target_link_libraries(network_config INTERFACE
espBroker_lib
network_lib)
2 changes: 1 addition & 1 deletion src/network/esp/Esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ bool espInternalSoftReset(void) {
return espErrorCode;
}

/* endregion */
/* endregion */
2 changes: 1 addition & 1 deletion src/rtos/FreeRtosSMP.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ prodding periodically from the tick interrupt. */
#endif
}
#endif
}
}
8 changes: 4 additions & 4 deletions src/rtos/FreeRtosTaskWrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

static void freeRtosTaskWrapperInternalInvokeTaskCode(void *p_taskCode) {
TaskCodeFunc taskCode = (TaskCodeFunc)p_taskCode;
if (taskCode)
if (taskCode) {
taskCode();
else {
} else {
PRINT("Invoking failed: taskCode not set to Function pointer");
}
vTaskDelete(NULL);
Expand All @@ -31,9 +31,9 @@ void freeRtosTaskWrapperRegisterTask(TaskCodeFunc taskCode, const char *taskName
}

void freeRtosTaskWrapperTaskSleep(int timeInMs) {
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED)
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
sleep_for_ms(timeInMs);
else {
} else {
// vTaskDelay does not support delaying less than typically 10ms
if (timeInMs < 10) {
timeInMs = 10;
Expand Down
2 changes: 1 addition & 1 deletion test/hardware/TestFlash/HardwaretestFlash.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ int main() {
PRINT("Waiting ...");
}
}
}
}
9 changes: 6 additions & 3 deletions test/hardware/TestNetworking/HardwaretestDurability.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@ float measureValue(pac193xSensorConfiguration_t sensor, pac193xChannel_t channel
}

void setTwinID(char *newTwinID) {
if (newTwinID == twinID)
if (newTwinID == twinID) {
return;
if (newTwinID != NULL)
}
if (newTwinID != NULL) {
free(twinID);
}
twinID = malloc(strlen(newTwinID) + 1);
strcpy(twinID, newTwinID);
}

void twinsIsOffline(posting_t posting) {
if (strstr(posting.data, ";1") != NULL)
if (strstr(posting.data, ";1") != NULL) {
return;
}
PRINT("Twin offline");

for (int i = 0; i < receivers_count; ++i) {
Expand Down
8 changes: 5 additions & 3 deletions test/hardware/TestNetworking/HardwaretestPublishSensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ void init(void) {

i2c_set_baudrate(i2c1, 2000000);
errorCode = adxl345bInit(i2c1, ADXL345B_I2C_ALTERNATE_ADDRESS);
if (errorCode == ADXL345B_NO_ERROR)
if (errorCode == ADXL345B_NO_ERROR) {
PRINT("Initialised ADXL345B.");
else
} else {
PRINT("Initialise ADXL345B failed; adxl345b_ERROR: %02X", errorCode);
}

// create FreeRTOS task queue
freeRtosQueueWrapperCreate();
Expand Down Expand Up @@ -188,8 +189,9 @@ bool getAndPublishSRamValue(char *dataID) {
}

bool getAndPublishWifiValue(char *dataID) {
if (!wifiReceiver.newValue)
if (!wifiReceiver.newValue) {
return false;
}
protocolPublishData(dataID, wifiReceiver.value);
wifiReceiver.newValue = false;
return true;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/UnittestFpgaConfigurationHandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ int main() {
RUN_TEST(test_downloadViaHttpOrderCorrect);

return UNITY_END();
}
}
2 changes: 1 addition & 1 deletion test/unit/dummies/pico/include/pico/stdio_usb.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <stdbool.h>

void stdio_usb_init();
bool stdio_usb_connected();
bool stdio_usb_connected();
2 changes: 1 addition & 1 deletion test/unit/dummies/pico/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ bool stdio_usb_connected() {
}
char getchar_timeout_us(uint32_t timeout) {
return '\0';
}
}
2 changes: 1 addition & 1 deletion test/unit/dummies/rtos/FreeRtosSemaphoreWrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ bool SemaphoreGiveFromISR(Semaphore semaphore) {

bool SemaphoreTake(Semaphore semaphore, int timeoutMs) {
return true;
}
}

0 comments on commit 2fbe74b

Please sign in to comment.