Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter
- CitrineOS core extracted (CSMS OCPP 2.0.1) - OpenOCPP extracted (firmware OCPP 1.6J/2.0.1) - ShapeShifter library installed (pip install -e) - ShapeShifter specification extracted - EVerest extracted TODO updated with progress
This commit is contained in:
12
tools/EVerest-main/lib/everest/crc/CMakeLists.txt
Normal file
12
tools/EVerest-main/lib/everest/crc/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
add_library(everest_crc STATIC src/crc.cpp)
|
||||
add_library(everest::crc ALIAS everest_crc)
|
||||
ev_register_library_target(everest_crc)
|
||||
|
||||
target_include_directories(everest_crc
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
)
|
||||
|
||||
if (BUILD_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
@@ -0,0 +1,10 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#ifndef CRC_HPP
|
||||
#define CRC_HPP
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
std::uint16_t calculate_xModem_crc16(const std::vector<std::uint8_t>& message);
|
||||
#endif
|
||||
26
tools/EVerest-main/lib/everest/crc/src/crc.cpp
Normal file
26
tools/EVerest-main/lib/everest/crc/src/crc.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include <cstdint>
|
||||
#include <everest/crc/crc.hpp>
|
||||
|
||||
std::uint16_t calculate_xModem_crc16(const std::vector<std::uint8_t>& message) {
|
||||
std::uint16_t crc = 0;
|
||||
|
||||
if (message.size() < 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (const auto& message_item : message) {
|
||||
crc ^= static_cast<std::uint16_t>(message_item) << 8;
|
||||
for (std::uint16_t i = 0; i < 8; i++) {
|
||||
if (crc & 0x8000) {
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
} else {
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
16
tools/EVerest-main/lib/everest/crc/tests/CMakeLists.txt
Normal file
16
tools/EVerest-main/lib/everest/crc/tests/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
set(TEST_TARGET_NAME ${PROJECT_NAME}_crc_tests)
|
||||
|
||||
add_executable(${TEST_TARGET_NAME}
|
||||
crc_test.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${TEST_TARGET_NAME}
|
||||
PRIVATE
|
||||
GTest::gtest_main
|
||||
everest::crc
|
||||
)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(${TEST_TARGET_NAME})
|
||||
|
||||
ev_register_test_target(${TEST_TARGET_NAME})
|
||||
20
tools/EVerest-main/lib/everest/crc/tests/crc_test.cpp
Normal file
20
tools/EVerest-main/lib/everest/crc/tests/crc_test.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2020 - 2025 Pionix GmbH and Contributors to EVerest
|
||||
|
||||
#include <everest/crc/crc.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(CRC16_XModem, KnownVector) {
|
||||
std::vector<std::uint8_t> data{'1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||
EXPECT_EQ(calculate_xModem_crc16(data), 0x31C3);
|
||||
}
|
||||
|
||||
TEST(CRC16_XModem, EmptyInput) {
|
||||
std::vector<std::uint8_t> data{};
|
||||
EXPECT_EQ(calculate_xModem_crc16(data), 0x0000);
|
||||
}
|
||||
|
||||
TEST(CRC16_XModem, MultipleBytes) {
|
||||
std::vector<std::uint8_t> data{'E', 'V', 'E', 'R', 'E', 'S', 'T'};
|
||||
EXPECT_EQ(calculate_xModem_crc16(data), 0x4492);
|
||||
}
|
||||
Reference in New Issue
Block a user