From 9cb32502686de8605404bb6e36b6605ee910a755 Mon Sep 17 00:00:00 2001 From: jacobperron Date: Fri, 12 Feb 2016 18:06:26 -0800 Subject: [PATCH] Expose functions for getting number of corrupt packets and total packets in Create class --- CMakeLists.txt | 7 ------- include/create/create.h | 8 ++++++++ include/create/serial.h | 4 ++-- src/create.cpp | 8 ++++++++ src/serial.cpp | 4 ++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index def8c81..036c026 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,6 @@ target_link_libraries(create ## Declare example executables add_executable(create_demo examples/create_demo.cpp) -add_executable(odom_test examples/odom_test.cpp) ## Specify libraries to link a library or executable target against target_link_libraries(create_demo @@ -30,13 +29,7 @@ target_link_libraries(create_demo create ) -target_link_libraries(odom_test - ${Boost_LIBRARIES} - create -) - ## Install -## I'm not familiar with install rules, do these make sense? install(TARGETS create DESTINATION lib) install(FILES include/create/create.h diff --git a/include/create/create.h b/include/create/create.h index 660e84f..31c9911 100644 --- a/include/create/create.h +++ b/include/create/create.h @@ -357,6 +357,14 @@ namespace create { /* Get the estimated velocity of Create based on wheel encoders. */ const create::Vel& getVel() const; + + /* Get the number of corrupt serial packets since first connecting to Create. + */ + uint64_t getNumCorruptPackets() const; + + /* Get the total number of serial packets (including corrupt packets) since first connecting to Create. + */ + uint64_t getTotalPackets() const; }; // end Create class } // namespace create diff --git a/include/create/serial.h b/include/create/serial.h index d339876..04b7006 100644 --- a/include/create/serial.h +++ b/include/create/serial.h @@ -97,8 +97,8 @@ namespace create { inline bool connected() const { return port.is_open(); }; bool send(const uint8_t* bytes, const uint32_t numBytes); bool sendOpcode(const Opcode& code); - uint64_t getNumCorruptPackets(); - uint64_t getNumTotalPackets(); + uint64_t getNumCorruptPackets() const; + uint64_t getTotalPackets() const; }; } // namespace create diff --git a/src/create.cpp b/src/create.cpp index bb99910..333184c 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -505,4 +505,12 @@ namespace create { return vel; } + uint64_t Create::getNumCorruptPackets() const { + return serial->getNumCorruptPackets(); + } + + uint64_t Create::getTotalPackets() const { + return serial->getTotalPackets(); + } + } // end namespace diff --git a/src/serial.cpp b/src/serial.cpp index ed2ba8d..89d16dd 100644 --- a/src/serial.cpp +++ b/src/serial.cpp @@ -239,11 +239,11 @@ namespace create { return send(&oc, 1); } - uint64_t Serial::getNumCorruptPackets() { + uint64_t Serial::getNumCorruptPackets() const { return corruptPackets; } - uint64_t Serial::getNumTotalPackets() { + uint64_t Serial::getTotalPackets() const { return totalPackets; } } // namespace create