From 5e6952d6fb16673819590a2494c86e78952ff3bc Mon Sep 17 00:00:00 2001 From: Peter O'Hanley Date: Thu, 3 Jan 2019 14:19:21 -0600 Subject: [PATCH] Fix blip-test and click-test compilation #6 --- CMakeLists.txt | 17 ++++++++--------- test/blip-test.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37cd449..8ff101d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,12 +32,11 @@ add_executable(monitor EXCLUDE_FROM_ALL test/monitor.cpp test/test_util.c src/sp target_link_libraries(monitor spiproto pthread) target_include_directories(monitor PUBLIC src/ PUBLIC test/) -#TODO can only run on linux -#click-test: test/click-test.cpp libspiproto.a spi_chunks.o test/test_util.o spi_proto_util.o -# #g++ $(CFLAGS) -o click-test test/click-test.cpp -std=c++14 -pthread spi_chunks.o test/test_util.o spi_proto_util.o -L. -lspiproto -I. -Isrc -# g++ test/click-test.cpp src/spi_proto_master.cpp src/spi_chunks.cpp -std=c++14 -pthread -x c src/binary_semaphore.c -x c src/spi_proto.c -I. -Isrc/ -x c src/crc16.c -x c src/spi_remote_host.c -o click-test -g - -#TODO can only run on linux -#blip-test: test/blip-test.cpp libspiproto.a spi_chunks.o test/test_util.o spi_proto_util.o -# #g++ $(CFLAGS) -o blip-test test/blip-test.cpp -std=c++14 -pthread spi_chunks.o test/test_util.o spi_proto_util.o -L. -lspiproto -I. -Isrc -# g++ test/blip-test.cpp src/spi_proto_master_datagram.cpp src/spi_chunks.cpp -std=c++14 -pthread -x c src/binary_semaphore.c -x c src/spi_proto.c -I. -Isrc/ -x c src/crc16.c -x c src/spi_remote_host.c -o blip-test -g +#these two can only be built on linux +add_executable(click-test EXCLUDE_FROM_ALL test/click-test.cpp src/spi_proto_master.cpp src/spi_chunks.cpp src/binary_semaphore.c src/spi_proto.c src/crc16.c src/spi_remote_host.c) +target_link_libraries(click-test spiproto pthread) +target_include_directories(click-test PUBLIC src/ PUBLIC test/) + +add_executable(blip-test test/blip-test.cpp src/spi_proto_master_datagram.cpp src/spi_chunks.cpp src/binary_semaphore.c src/spi_proto.c src/crc16.c src/spi_remote_host.c) +target_link_libraries(blip-test spiproto pthread) +target_include_directories(blip-test PUBLIC src/ PUBLIC test/) diff --git a/test/blip-test.cpp b/test/blip-test.cpp index e987ed1..19b1a1c 100644 --- a/test/blip-test.cpp +++ b/test/blip-test.cpp @@ -1,5 +1,5 @@ -//g++ click-test.cpp spi_proto_master.cpp spi_proto_lib/spi_chunks.cpp -std=c++14 -pthread -x c binary_semaphore.c -x c spi_proto_lib/spi_proto.c -I. -Ispi_proto_lib/ -x c crc16.c -x c spi_remote_host.c -o click -g //causes solenoids to click in strobing sequence. Remote API test +//use with HeartrateLED k66f code. #include #include "spi_datagram.h" @@ -19,7 +19,12 @@ dummy_callback(struct spi_packet *p) /* If we linked with this function and the k66f code simply echoed our * messages, this would receive arguments where p->msg[0] was alternately 60 * and 120. + * Here we print out the received bytes in hex. */ + for (int i = 0; i < sizeof(struct spi_packet); i++) { + printf("%02x ", ((unsigned char *)p)[i]); + } + puts(""); } void (*spi_callback)(struct spi_packet *p) = dummy_callback;