Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
RobertGawron committed Dec 22, 2024
1 parent de69101 commit fe5a2d9
Showing 19 changed files with 137 additions and 92 deletions.
65 changes: 57 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ jobs:

- name: Build and Push Docker Image
run: |
docker build -t ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }} -f DevOps/HwDev/Docker/Dockerfile .
docker build -t ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }} -f DevOps/Dockerfile .
docker push ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }}
# Parallel Jobs: Unit Tests, Code Coverage, etc.
@@ -115,7 +115,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: code-coverage-results
path: DevOps/HwDev/BuildArtifacts/CodeCoverage
path: DevOps/BuildArtifacts/CodeCoverage

- name: Clean up Docker containers
run: |
@@ -162,14 +162,14 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: docs-coverage-results
path: DevOps/HwDev/BuildArtifacts/DocsCoverage
path: DevOps/BuildArtifacts/DocsCoverage

- name: Clean up Docker containers
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml down
static-analysis:
name: Run Static Analysis
static-analysis-python:
name: Run Static Analysis (python)
runs-on: ubuntu-latest
needs: build
steps:
@@ -206,13 +206,62 @@ jobs:
set -e; \
cd /workspace/build && cmake .. && make pystatic"
- name: Upload Static Analysis Results
- name: Upload Static Analysis (Python) Results
if: always()
uses: actions/upload-artifact@v4
with:
name: static-analysis-results
path: DevOps/HwDev/BuildArtifacts/PythonStaticAnalysis
name: static-analysis-results-python
path: DevOps/BuildArtifacts/PythonStaticAnalysis

- name: Clean up Docker containers
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml down
static-analysis-c:
name: Run Static Analysis (cpp)
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull Docker Image
run: |
docker pull ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }}
docker tag ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }} hardwaredatalogger:latest
- name: Run Docker Compose
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d
- name: Run Static Analysis
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml exec -T dev bash -c "\
set -e; \
cd /workspace/build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_STANDARD=17 .. && make static"
- name: Upload Static Analysis Results
if: always()
uses: actions/upload-artifact@v4
with:
name: static-analysis-results-cpp
path: DevOps/BuildArtifacts/StaticAnalysis

- name: Clean up Docker containers
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml down
27 changes: 0 additions & 27 deletions Documentation/Manuals/SetupDockerContainers.md
Original file line number Diff line number Diff line change
@@ -36,30 +36,3 @@ When finished, shut down the Docker container:
docker-compose down --remove-orphans
```

## Docker Image for Raspberry Pi Development

### Build the Image

In the main directory (HardwareDataLogger), run the following command to build the image:

```
docker-compose build raspberry-logger
```

### Running the Docker Image

Start the Docker image:

```
docker-compose up raspberry-logger -d
```

Log into the Docker image:

```
docker-compose exec raspberry-logger bash
```

### Cross-Platform Usage

For cross-platform usage, use Buildx to produce a multi-arch image.
2 changes: 1 addition & 1 deletion Simulation/FirmwarePCSimulator/PythonStaticAnalysis.cmake
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ file(MAKE_DIRECTORY ${PYTHON_REPORT_DIR})
# Add a custom target for Python static analysis
add_custom_target(pystatic
COMMAND bash -c " \
/workspace/Simulation/FirmwarePCSimulator/PythonStaticAnalysis.sh"
source /workspace/Simulation/FirmwarePCSimulator/PythonStaticAnalysis.sh"
COMMENT "Running Python static analysis with Prospector and generating reports..."
VERBATIM
)
10 changes: 5 additions & 5 deletions Simulation/FirmwarePCSimulator/data_visualization_widget.py
Original file line number Diff line number Diff line change
@@ -24,16 +24,16 @@ def __init__(self):

self.setLayout(self.layout)

def update_pulse_counters(self, timestamp, values):
def update_pulse_counters(self, timestamp, new_values):
"""
Update the graph with new pulse counter values.
:param timestamp: The timestamp of the update.
:param values: A list of pulse counter values.
:param new_values: A list of pulse counter values.
"""
# Append new data to the storage
self.time_stamps.append(timestamp)
for i, value in enumerate(values):
for i, value in enumerate(new_values):
self.pulse_counters[i].append(value)

# Ensure the time series does not grow indefinitely (optional)
@@ -45,8 +45,8 @@ def update_pulse_counters(self, timestamp, values):

# Clear and plot new data
self.ax.clear()
for i, values in self.pulse_counters.items():
self.ax.plot(self.time_stamps, values, label=f"Pulse Counter {i + 1}")
for i, counter_values in self.pulse_counters.items():
self.ax.plot(self.time_stamps, counter_values, label=f"Pulse Counter {i + 1}")

self.ax.set_title("Pulse Counter Values Over Time")
self.ax.set_xlabel("Time")
2 changes: 2 additions & 0 deletions Simulation/FirmwarePCSimulator/main.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
from main_window import MainWindow
from simulation import Simulation


def main() -> None:
"""
Entry point for the application. Initializes the PyQt application,
@@ -19,5 +20,6 @@ def main() -> None:
# Start the application's event loop
sys.exit(app.exec())


if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions Simulation/FirmwarePCSimulator/main_window.py
Original file line number Diff line number Diff line change
@@ -94,9 +94,9 @@ def on_measurement_update(self, values):
Handle updates from the MeasurementDataInputWidget sliders.
:param values: List of current slider values.
"""
timestamp = "{:%Y-%m-%d %H:%M:%S}".format(datetime.now())
message = "Simulated pulse counter values: " + ", ".join(f"{value}" for value in values)
timestamp = f"{datetime.now():%Y-%m-%d %H:%M:%S}"
message = f"Simulated pulse counter values: {', '.join(str(value) for value in values)}"
self.log_tabs.add_log(LogTabID.PULSE_COUNTER, timestamp, message)

self.data_visualization_tab.update_pulse_counters(timestamp, values)
self.simulation.update_pulse_counters(values)
1 change: 1 addition & 0 deletions Software/CStaticAnalysis.cmake
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ add_custom_target(static
--disable clang-diagnostic-weak-vtables
--disable altera-id-dependent-backward-branch
--disable bugprone-easily-swappable-parameters
--disable clang-diagnostic-covered-switch-default
COMMENT "Running CodeChecker analysis..."
VERBATIM
)
Original file line number Diff line number Diff line change
@@ -28,14 +28,12 @@ namespace BusinessLogic

namespace
{

// Define a constant for maximum displays, change if needed
constexpr std::size_t MAX_MUI_AMOUNT = 1u;
std::array<DisplayMapEntry, MAX_MUI_AMOUNT> muiMap{};

constexpr std::size_t LabelTextBufferSize = 10;
char labelTextBuffer[LabelTextBufferSize];

}

uint8_t device1_printLastReading(mui_t *muiHandler, uint8_t muiMessage)
@@ -75,6 +73,8 @@ namespace BusinessLogic

DisplayMapEntry *findEntryByMui(mui_t *muiHandler)
{
// The std::find_if function returns an iterator, which is an object (not a raw pointer) in modern STL containers.
// codechecker_suppress [readability-qualified-auto]
auto it = std::find_if(
muiMap.begin(),
muiMap.end(),
4 changes: 2 additions & 2 deletions Software/STM32F103RBTx/Application/Device/Inc/Display.hpp
Original file line number Diff line number Diff line change
@@ -89,12 +89,12 @@ namespace Device
* This method sets up the `u8g2` library with the appropriate callbacks and parameters
* for the ST7735 display hardware.
*
* @param u8g2 Pointer to the `u8g2_t` structure representing the library context.
* @param u8g2Handler Pointer to the `u8g2_t` structure representing the library context.
* @param rotation Pointer to a `u8g2_cb_t` structure specifying the display rotation.
* @param byte_cb Byte callback function for communication with the display.
* @param gpio_and_delay_cb GPIO and delay callback function for controlling hardware signals.
*/
static void u8g2_Setup_st7735(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
static void u8g2_Setup_st7735(u8g2_t *u8g2Handler, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);

/// Reference to the display driver used for managing display operations.
Driver::IDisplayDriver &displayDriver;
51 changes: 28 additions & 23 deletions Software/STM32F103RBTx/Application/Device/Src/Display.cpp
Original file line number Diff line number Diff line change
@@ -124,50 +124,53 @@ namespace Device

case U8X8_MSG_DISPLAY_DRAW_TILE:
{
const u8x8_tile_t *tile = static_cast<u8x8_tile_t *>(argPtr);
const u8x8_tile_t *tiles = static_cast<u8x8_tile_t *>(argPtr);

for (std::uint8_t t = 0; t < argInt; t++)
{
const std::uint8_t tile_x_start = tile->x_pos * TILE_PIXEL_HEIGHT; // Starting x position in pixels
const std::uint8_t tile_y_start = tile->y_pos * TILE_PIXEL_HEIGHT; // Starting y position in pixels
// lib api, can't change it
// codechecker_suppress [clang-diagnostic-unsafe-buffer-usage]
const u8x8_tile_t &tile = tiles[t]; // Access the current tile safely using an index

// printf("tile_x_start x=%d, y=%d\n", tile_x_start, tile_y_start);
const std::uint8_t tile_x_start = tile.x_pos * TILE_PIXEL_HEIGHT; // Starting x position in pixels
const std::uint8_t tile_y_start = tile.y_pos * TILE_PIXEL_HEIGHT; // Starting y position in pixels

// Treat each byte as a column of 8 vertical pixels.
for (std::uint8_t col = 0; col < 120; col++)
constexpr std::uint8_t len = 120; // todo think about it
for (std::uint8_t col = 0; col < len; col++)
{
const std::uint8_t col_data = tile->tile_ptr[col]; // This is a vertical column
// lib api, can't change it
// codechecker_suppress [clang-diagnostic-unsafe-buffer-usage]
const std::uint8_t col_data = tile.tile_ptr[col]; // This is a vertical column
for (std::uint8_t bit = 0; bit < TILE_PIXEL_HEIGHT; bit++)
{
Driver::DisplayPixelColor::PixelColor color = Driver::DisplayPixelColor::getColor(0x00, 0x00, 0x00);
const std::uint8_t x = tile_x_start + col;
const std::uint8_t y = tile_y_start + bit;

if (col_data & (1 << bit))
if ((col_data & (1 << bit)) != 0)
{
// Now (col, bit) corresponds to (x, y) pixel offsets within the tile:
// x = tile_x_start + col
// y = tile_y_start + bit
// printf("Pixel ON at x=%d, y=%d\n", tile_x_start + col, tile_y_start + bit);
color = Driver::DisplayPixelColor::getColor(DEFAULT_COLOR_RED, DEFAULT_COLOR_GREEN, DEFAULT_COLOR_BLUE);
}

displayDriver.setPixel(x, y, color);
}
}

tile++;
}
}
break;

case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
case U8X8_MSG_DISPLAY_REFRESH:
{
}
break;

/*
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
case U8X8_MSG_DISPLAY_REFRESH:
{
}
break;
*/

default:
{
// printf("Unhandled message: %d\n", msg);
@@ -178,7 +181,7 @@ namespace Device
return U8G2_STATUS_OK;
}

void Display::u8g2_Setup_st7735(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
void Display::u8g2_Setup_st7735(u8g2_t *u8g2Handler, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
// Calculate the number of tile rows needed for 128x128 resolution.
// Each tile is 8 pixels high, so for a 128-pixel height:
@@ -188,7 +191,9 @@ namespace Device
// Each tile is 8 pixels wide * 1 byte (8 bits) = 8 bytes per tile.
// For 16 rows and 16 tiles per row:
// Total buffer size = 16 rows * 16 tiles/row * 8 bytes/tile = 2048 bytes.
std::uint8_t *buf = static_cast<std::uint8_t *>(malloc(128 * tile_buf_height));
constexpr std::size_t len = 128;
std::uint8_t *buf = static_cast<std::uint8_t *>(malloc(
len * static_cast<std::size_t>(tile_buf_height)));

if (buf == nullptr)
{
@@ -198,11 +203,11 @@ namespace Device

// Setup the display with the appropriate parameters.
// Note that this is u8g2 macro so I cant modify it to avoid warning
// codechecker_suppress [mold-style-cast, cppcheck-cstyleCast]
u8g2_SetupDisplay(u8g2, trampolineU8x8DSt7735, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
// codechecker_suppress [mold-style-cast, cppcheck-cstyleCast, clang-diagnostic-old-style-cast]
u8g2_SetupDisplay(u8g2Handler, trampolineU8x8DSt7735, u8x8_cad_001, byte_cb, gpio_and_delay_cb);

// Configure the buffer and the rendering method (vertical top to bottom).
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
u8g2_SetupBuffer(u8g2Handler, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}

Display::Display(Driver::IDisplayDriver &_displayDriver) : displayDriver(_displayDriver)
4 changes: 4 additions & 0 deletions Software/STM32F103RBTx/Application/Device/Src/Keyboard.cpp
Original file line number Diff line number Diff line change
@@ -82,6 +82,10 @@ namespace Device
// default:
// If there are other states or error conditions, handle them here
break;
default:
{
}
break;
}

keyActionState[i] = nextState;
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ namespace Device

const Driver::UartExchangeStatus driverStatus = driver.transmit(
data.data(),
currentDataPosition,
static_cast<std::uint16_t>(currentDataPosition),
Driver::IUartDriver::MaxDelay);

status = (driverStatus == Driver::UartExchangeStatus::Ok);
Original file line number Diff line number Diff line change
@@ -61,7 +61,8 @@ namespace Driver
if (isInState(DriverState::State::Running))
{
// Use std::find_if to locate the key configuration in the array
// Use std::find_if to locate the key configuration in the array
// The std::find_if function returns an iterator, which is an object (not a raw pointer) in modern STL containers.
// codechecker_suppress [readability-qualified-auto]
auto it = std::find_if(
keyState.begin(),
keyState.end(),
Loading

0 comments on commit fe5a2d9

Please sign in to comment.