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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ __pycache__/
.env
/public
*.cpython*
.github/*.md
5 changes: 1 addition & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: gitlab-registry.cern.ch/linuxsupport/alma9-base:latest
image: gitlab-registry.cern.ch/linuxsupport/alma10-base:latest

stages:
- unstagged
Expand All @@ -11,9 +11,6 @@ include:
rules:
- if: $CI_PIPELINE_SOURCE == "api" # Source Github-Gitlab bridge
- if: $PIPELINE == "normal"
- local: ci/gitlab/docker.yml
rules:
- if: $DOCKER_GENERATION == "true"

# Empty job, as gitlab-ci requires at least one job
empty:
Expand Down
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ repos:
- id: clang-format
args: ["-style=Google"]
- id: cppcheck
args: ["--check-level=exhaustive"]
- id: cpplint
args: ["--filter=-legal/copyright"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
Expand All @@ -29,7 +30,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/psf/black
rev: 24.4.2
rev: 25.12.0
hooks:
- id: black

Expand Down
46 changes: 27 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

include_directories(src/include
${PROJECT_BINARY_DIR}/src/include/)
include_directories(
src/include
${PROJECT_BINARY_DIR}/src/include/
)

include(cmake/version.cmake)

Expand All @@ -23,16 +25,17 @@ set(SOURCES

include(cmake/env.cmake)


set(VENDOR_SOURCES
src/main/CanVendorAnagate.cpp
)

if (UNIX)
include(cmake/libsocketcan.cmake)
include_directories(${LIBSOCKETCAN_INCLUDE_DIR})
list(APPEND VENDOR_SOURCES
src/main/CanVendorSocketCan.cpp
src/main/CanVendorSocketCanSystec.cpp
)
src/main/CanVendorSocketCan.cpp
src/main/CanVendorSocketCanSystec.cpp
)
endif()

if (NOT DEFINED CAN_MODULE_MAIN_ONLY)
Expand All @@ -44,31 +47,36 @@ endif()

include(cmake/anagate.cmake)


add_library(CanModuleMain ${SOURCES} ${VENDOR_SOURCES})
target_include_directories(CanModuleMain PUBLIC ${LOGIT_INCLUDE} ${anagate_SOURCE_DIR}/)

target_include_directories(CanModuleMain PUBLIC
${LOGIT_INCLUDE}
${anagate_SOURCE_DIR}/
)

if (UNIX)
target_link_libraries(CanModuleMain PUBLIC
${anagate_SOURCE_DIR}/Linux64/CentOS_9/libCANDLLStaticRelease64.a
${anagate_SOURCE_DIR}/Linux64/CentOS_9/libAnaGateStaticRelease.a
${anagate_SOURCE_DIR}/Linux64/CentOS_9/libAnaGateExtStaticRelease.a
socketcan)
${anagate_SOURCE_DIR}/Linux64/CentOS_9/libCANDLLStaticRelease64.a
${anagate_SOURCE_DIR}/Linux64/CentOS_9/libAnaGateStaticRelease.a
${anagate_SOURCE_DIR}/Linux64/CentOS_9/libAnaGateExtStaticRelease.a
libsocketcan
)
else()
target_link_libraries(CanModuleMain PUBLIC
${anagate_SOURCE_DIR}/Win64/AnaGateCanDll64.lib)
file(COPY "${anagate_SOURCE_DIR}/Win64/AnaGateCan64.dll" DESTINATION "${CMAKE_BINARY_DIR}/Release")
${anagate_SOURCE_DIR}/Win64/AnaGateCanDll64.lib
)
file(COPY "${anagate_SOURCE_DIR}/Win64/AnaGateCan64.dll"
DESTINATION "${CMAKE_BINARY_DIR}/Release")
endif()

# Treat warnings as errors
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(CanModuleMain PRIVATE -Wall -Wextra -Werror)
target_compile_options(CanModuleMain PRIVATE -Wall -Wextra -Werror)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# target_compile_options(CanModuleMain PRIVATE /W4 /WX)
# I need to disable that feature due to a macro redefinition
# in the header of Anagate software
# Disabled because of AnaGate macro redefinition issues
endif()

if (NOT DEFINED CAN_MODULE_MAIN_ONLY)
# Build Python Support and Google Unit Tests
include(cmake/pybind11.cmake)
include(cmake/gtest.cmake)
endif()
19 changes: 0 additions & 19 deletions ci/docker/alma9/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions ci/docker/alma9/trigger

This file was deleted.

5 changes: 0 additions & 5 deletions ci/docker/w2022/Dockerfile

This file was deleted.

24 changes: 0 additions & 24 deletions ci/docker/w2022/install.ps1

This file was deleted.

2 changes: 0 additions & 2 deletions ci/docker/w2022/trigger

This file was deleted.

25 changes: 0 additions & 25 deletions ci/gitlab/docker.yml

This file was deleted.

11 changes: 7 additions & 4 deletions ci/gitlab/normal.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
variables:
ALMA_LATEST_IMAGE: "gitlab-registry.cern.ch/quasar-team/images/alma-10-build:latest"

Compile on Windows:
stage: unstagged
image: $CI_REGISTRY_IMAGE/win2022-build:latest
Expand All @@ -13,7 +16,7 @@ Compile on Windows:

Compile on Linux:
stage: unstagged
image: $CI_REGISTRY_IMAGE/alma9-build:latest
image: $ALMA_LATEST_IMAGE
script:
- cmake -B build
- cmake --build build --config Release
Expand All @@ -34,7 +37,7 @@ Google Tests on Windows:

Google Tests on Linux:
stage: unstagged
image: $CI_REGISTRY_IMAGE/alma9-build:latest
image: $ALMA_LATEST_IMAGE
needs:
- Compile on Linux
script:
Expand Down Expand Up @@ -62,14 +65,14 @@ Pytest on Linux:

Run Sanity Checks:
stage: unstagged
image: $CI_REGISTRY_IMAGE/alma9-build:latest
image: $ALMA_LATEST_IMAGE
script:
- pip install pre-commit
- pre-commit run --all-files

Update Documentation Website:
stage: unstagged
image: $CI_REGISTRY_IMAGE/alma9-build:latest
image: $ALMA_LATEST_IMAGE
script:
- |
curl -X POST \
Expand Down
34 changes: 34 additions & 0 deletions cmake/libsocketcan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FetchContent_Declare(
libsocketcan
GIT_REPOSITORY https://github.com/linux-can/libsocketcan.git
GIT_TAG v0.0.12
DOWNLOAD_EXTRACT_TIMESTAMP True
)

FetchContent_MakeAvailable(libsocketcan)

set(LIBSOCKETCAN_INCLUDE_DIR ${libsocketcan_SOURCE_DIR}/include)

set(LIBSOCKETCAN_LIB ${libsocketcan_SOURCE_DIR}/src/.libs/libsocketcan.a)

add_custom_command(
OUTPUT ${LIBSOCKETCAN_LIB}
WORKING_DIRECTORY ${libsocketcan_SOURCE_DIR}
COMMAND bash autogen.sh
COMMAND bash configure --enable-static --disable-shared CFLAGS=-fPIC CXXFLAGS=-fPIC
COMMAND make
DEPENDS ${libsocketcan_SOURCE_DIR}
)

add_library(libsocketcan STATIC IMPORTED GLOBAL)

set_target_properties(libsocketcan PROPERTIES
IMPORTED_LOCATION ${LIBSOCKETCAN_LIB}
INTERFACE_INCLUDE_DIRECTORIES ${LIBSOCKETCAN_INCLUDE_DIR}
)

add_custom_target(libsocketcan_build ALL
DEPENDS ${LIBSOCKETCAN_LIB}
)

add_dependencies(libsocketcan libsocketcan_build)
1 change: 1 addition & 0 deletions src/include/CanDerivedStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SRC_INCLUDE_CANDERIVEDSTATS_H_

#include <chrono>
#include <cstdint>
#include <deque>
#include <numeric>

Expand Down
5 changes: 3 additions & 2 deletions src/include/CanDeviceConfiguration.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SRC_INCLUDE_CANDEVICECONFIGURATION_H_
#define SRC_INCLUDE_CANDEVICECONFIGURATION_H_

#include <cstdint>
#include <iostream>
#include <optional>
#include <string>
Expand Down Expand Up @@ -97,7 +98,7 @@ struct CanDeviceConfiguration {
std::string to_string() const noexcept;
};

std::ostream &operator<<(std::ostream &os,
const CanDeviceConfiguration &config) noexcept;
std::ostream& operator<<(std::ostream& os,
const CanDeviceConfiguration& config) noexcept;

#endif // SRC_INCLUDE_CANDEVICECONFIGURATION_H_
1 change: 1 addition & 0 deletions src/include/CanDiagnostics.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SRC_INCLUDE_CANDIAGNOSTICS_H_
#define SRC_INCLUDE_CANDIAGNOSTICS_H_

#include <cstdint>
#include <iomanip>
#include <iostream>
#include <optional>
Expand Down
1 change: 1 addition & 0 deletions src/include/CanFrame.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SRC_INCLUDE_CANFRAME_H_
#define SRC_INCLUDE_CANFRAME_H_

#include <cstdint>
#include <stdexcept>
#include <string>
#include <vector>
Expand Down
9 changes: 5 additions & 4 deletions src/include/CanVendorAnagate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SRC_INCLUDE_CANVENDORANAGATE_H_
#define SRC_INCLUDE_CANVENDORANAGATE_H_

#include <cstdint>
#include <map>
#include <mutex> //NOLINT

Expand All @@ -17,22 +18,22 @@
* information.
*/
struct CanVendorAnagate : CanDevice {
friend void anagate_receive(AnaInt32 nIdentifier, const char *pcBuffer,
friend void anagate_receive(AnaInt32 nIdentifier, const char* pcBuffer,
AnaInt32 nBufferLen, AnaInt32 nFlags,
AnaInt32 hHandle) noexcept;

explicit CanVendorAnagate(const CanDeviceArguments &configuration);
explicit CanVendorAnagate(const CanDeviceArguments& configuration);
inline ~CanVendorAnagate() override { vendor_close(); }

private:
CanReturnCode vendor_open() noexcept override;
CanReturnCode vendor_close() noexcept override;
CanReturnCode vendor_send(const CanFrame &frame) noexcept override;
CanReturnCode vendor_send(const CanFrame& frame) noexcept override;
CanDiagnostics vendor_diagnostics() noexcept override;

void print_anagate_error(AnaUInt32 r) noexcept;
static std::mutex m_handles_lock;
static std::map<int, CanVendorAnagate *> m_handles;
static std::map<int, CanVendorAnagate*> m_handles;

AnaInt32 m_handle{0};
};
Expand Down
4 changes: 2 additions & 2 deletions src/include/CanVendorLoopback.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CanVendorLoopback : CanDevice {
* which contains configuration parameters for the CAN device.
*/
inline explicit CanVendorLoopback(
const CanDeviceArguments &configuration) noexcept
const CanDeviceArguments& configuration) noexcept
: CanDevice("loopback", configuration) {}

private:
Expand All @@ -34,7 +34,7 @@ struct CanVendorLoopback : CanDevice {
inline CanReturnCode vendor_close() noexcept override {
return CanReturnCode::success;
}
CanReturnCode vendor_send(const CanFrame &frame) noexcept override;
CanReturnCode vendor_send(const CanFrame& frame) noexcept override;
inline CanDiagnostics vendor_diagnostics() noexcept override {
return CanDiagnostics{};
}
Expand Down
Loading