Skip to content

Commit

Permalink
Merge branch 'master' into strcpy-replace
Browse files Browse the repository at this point in the history
  • Loading branch information
BLuedtke committed Nov 26, 2024
2 parents a239870 + 5f27c61 commit 54204af
Show file tree
Hide file tree
Showing 14 changed files with 654 additions and 782 deletions.
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ doc/
*.o
*.a
.idea/
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
.DS_Store
**/.vscode
**/.cache
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,25 @@ IF (${BIDIB_USE_TESTS})

# Physical test

ADD_EXECUTABLE(swtbahn-standard-testsuite test test/physical/swtbahn-standard/main.c test/physical/swtbahn-standard/testsuite.c)
ADD_EXECUTABLE(swtbahn-standard-testsuite test test/physical/swtbahn-standard/main.c test/physical/swtbahn-standard/testsuite.c test/physical/test_common.c)
TARGET_LINK_LIBRARIES(swtbahn-standard-testsuite glib-2.0 pthread yaml bidib_static)

ADD_EXECUTABLE(swtbahn-full-testsuite test test/physical/swtbahn-full/main.c test/physical/swtbahn-full/testsuite.c)
ADD_EXECUTABLE(swtbahn-full-testsuite test test/physical/swtbahn-full/main.c test/physical/swtbahn-full/testsuite.c test/physical/test_common.c)
TARGET_LINK_LIBRARIES(swtbahn-full-testsuite glib-2.0 pthread yaml bidib_static)

ENDIF(${BIDIB_USE_TESTS})


# - - - - - - - - - - - - -
# UNINSTALL DEFINITION
# - - - - - - - - - - - - -

if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
21 changes: 21 additions & 0 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif()

file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
endforeach()
2 changes: 1 addition & 1 deletion src/highlevel/bidib_highlevel_setter.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ int bidib_set_signal(const char *signal, const char *aspect) {
aspect_port_value = &g_array_index(aspect_mapping->port_values,
t_bidib_dcc_aspect_port_value, k);
params.data = (uint8_t) (aspect_port_value->port & 0x1F);
params.data = params.data | (uint8_t) (aspect_port_value->value | (1 << 5));
params.data = params.data | (uint8_t) (aspect_port_value->value << 5);
params.data = params.data | (dcc_mapping->extended_accessory << 7);
bidib_send_cs_accessory_intern(tmp_addr, params, action_id);
}
Expand Down
1 change: 1 addition & 0 deletions src/state/bidib_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ void bidib_state_reset(void) {
train_state->on_track = false;
train_state->orientation = BIDIB_TRAIN_ORIENTATION_LEFT;
train_state->set_speed_step = 0;
train_state->detected_kmh_speed = 0;
train_state->set_is_forwards = true;
train_state->ack = BIDIB_DCC_ACK_PENDING;
for (size_t j = 0; j < train_state->peripherals->len; j++) {
Expand Down
6 changes: 4 additions & 2 deletions test/physical/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ physical
| |-- main.c
| |-- testsuite.c
| '-- testsuite.h
'-- Readme.md
|-- Readme.md
|-- test_common.c
'-- test_common.h
```

## Test Cases
Expand Down Expand Up @@ -45,7 +47,7 @@ physical
Drives two user-defined trains along the track segments.

For the SWTbahn Full, the first train must be facing clockwise on track segment `T58`,
and the second train must be facing clockwise on track segment `T46`.
and the second train must be facing clockwise on track segment `T78a`.


For a given SWTbahn platform, its points and signals are retrieved using the
Expand Down
8 changes: 4 additions & 4 deletions test/physical/swtbahn-full/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ int main(int argc, char **argv) {
return 0;
}

// if (bidib_start_serial("/dev/tty.usbserial-AK06U8H7", "../../swtbahn-cli/configurations/swtbahn-full/", 0)) {
//if (bidib_start_serial("/dev/tty.usbserial-AK06U8H7", "../../swtbahn-cli/configurations/swtbahn-full/", 0)) {
if (bidib_start_serial("/dev/ttyUSB0", "../../swtbahn-cli/configurations/swtbahn-full", 0)) {
printf("testsuite: libbidib failed to start\n");
return 0;
} else {
printf("Started Serial");
printf("testsuite: libbidib started\n");
}
sleep(2); // Wait for the points to finish switching to their default positions.

Expand All @@ -74,7 +74,7 @@ int main(int argc, char **argv) {
const int repetitions = atoi(argv[2]);
switch (atoi(argv[1])) {
case 1:
//bidib_set_track_output_state_all(BIDIB_CS_OFF);
bidib_set_track_output_state_all(BIDIB_CS_OFF);
for (int i = 0; i < repetitions; i++) {
testsuite_case_pointParallel(result);
}
Expand Down Expand Up @@ -168,7 +168,7 @@ void printWelcome() {
"* SWTbahn-testsuite *",
"* *",
"************************",
"* UniBa-SWT-2022 *",
"* UniBa-SWT-2023 *",
"************************",
""
};
Expand Down
Loading

0 comments on commit 54204af

Please sign in to comment.