@@ -8,9 +8,14 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) | |||
find_package(Threads REQUIRED) | |||
add_executable(lfr_uart uart_communication.cpp) | |||
add_executable(lfr_uart uart_communication.cpp uart_communication_main.cpp) | |||
add_library(lfr_uart_lib uart_communication.cpp) | |||
target_link_libraries( lfr_uart Threads::Threads) | |||
target_link_libraries( lfr_uart_lib Threads::Threads) | |||
target_include_directories(lfr_uart PUBLIC .) | |||
target_include_directories(lfr_uart_lib PUBLIC .) | |||
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) | |||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) |
@@ -133,20 +133,4 @@ void LFR_UART::closeSerialPort() { | |||
this->closeFile(); | |||
} | |||
int main(void) { | |||
printf("Starting the loopback application...\r\n"); | |||
LFR_UART uartCommunicator; | |||
uartCommunicator.sendTelegram(-1.0, -0.99, 0.99, 1.0); | |||
double buffer[4] = {0.0, 0.0, 0.0, 0.0}; | |||
sleep(1); | |||
if(uartCommunicator.readTelegram(buffer)){ | |||
for(int i = 0; i < 4; i++) { | |||
std::cout << buffer[i] << " "; | |||
} | |||
} | |||
else { | |||
std::cout<<"ne"; | |||
} | |||
return 0; | |||
} | |||
@@ -0,0 +1,19 @@ | |||
#include "uart_communication.h" | |||
int main(void) { | |||
printf("Starting the loopback application...\r\n"); | |||
LFR_UART uartCommunicator; | |||
uartCommunicator.sendTelegram(-1.0, -0.99, 0.99, 1.0); | |||
double buffer[4] = {0.0, 0.0, 0.0, 0.0}; | |||
sleep(1); | |||
if(uartCommunicator.readTelegram(buffer)){ | |||
for(int i = 0; i < 4; i++) { | |||
std::cout << buffer[i] << " "; | |||
} | |||
} | |||
else { | |||
std::cout<<"ne"; | |||
} | |||
return 0; | |||
} |