From b6b479404625a7bfde1752e6dad8c9e427688402 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Mon, 28 Nov 2016 03:16:23 +0900 Subject: [PATCH 01/27] Update text after to newer --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 712d429..f602ff8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ that suport ICS3.0 or newer serial communication. ex)[KRS series servo moters produced by KONDO KAGAKU co., ltd.](http://kondo-robot.com/product-category/servomotor/krs) ## Caution -1. This software require c++11 compiler. In ubuntu 14.04 or after version have compiler support c++11. +1. This software require c++11 compiler. In ubuntu 14.04 or newer version have compiler support c++11. 2. This software only support serial mode. You should lock the serial mode for never turn on PWM mode. 3. Linux need serial device that mounted for use it. `script/setup.sh` will mount it to `/dev/ttyUSB0`. From 0ddea15d2e44bf7cfeff84675d7e433b709287ba Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Wed, 30 Nov 2016 02:18:07 +0900 Subject: [PATCH 02/27] Rename headers for v1.4.0 --- include/{core.h => core.hpp} | 0 include/ics3/{angle.h => angle.hpp} | 2 +- include/ics3/{baudrate.h => baudrate.hpp} | 0 .../ics3/{check_invalid.h => check_invalid.hpp} | 0 include/ics3/{eepparam.h => eepparam.hpp} | 4 ++-- include/ics3/{eeprom.h => eeprom.hpp} | 2 +- include/ics3/ics | 16 ++++++++-------- include/ics3/{ics3.h => ics3.hpp} | 4 ++-- include/ics3/{id.h => id.hpp} | 0 include/ics3/{parameter.h => parameter.hpp} | 2 +- src/core.cpp | 2 +- src/ics3.cpp | 10 +++++----- 12 files changed, 21 insertions(+), 21 deletions(-) rename include/{core.h => core.hpp} (100%) rename include/ics3/{angle.h => angle.hpp} (99%) rename include/ics3/{baudrate.h => baudrate.hpp} (100%) rename include/ics3/{check_invalid.h => check_invalid.hpp} (100%) rename include/ics3/{eepparam.h => eepparam.hpp} (99%) rename include/ics3/{eeprom.h => eeprom.hpp} (98%) rename include/ics3/{ics3.h => ics3.hpp} (97%) rename include/ics3/{id.h => id.hpp} (100%) rename include/ics3/{parameter.h => parameter.hpp} (98%) diff --git a/include/core.h b/include/core.hpp similarity index 100% rename from include/core.h rename to include/core.hpp diff --git a/include/ics3/angle.h b/include/ics3/angle.hpp similarity index 99% rename from include/ics3/angle.h rename to include/ics3/angle.hpp index 5b6a9fb..dbbbd83 100644 --- a/include/ics3/angle.h +++ b/include/ics3/angle.hpp @@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef LIBICS3_ICS3_ANGLE_H #define LIBICS3_ICS3_ANGLE_H -#include "ics3/check_invalid.h" +#include "ics3/check_invalid.hpp" namespace ics { diff --git a/include/ics3/baudrate.h b/include/ics3/baudrate.hpp similarity index 100% rename from include/ics3/baudrate.h rename to include/ics3/baudrate.hpp diff --git a/include/ics3/check_invalid.h b/include/ics3/check_invalid.hpp similarity index 100% rename from include/ics3/check_invalid.h rename to include/ics3/check_invalid.hpp diff --git a/include/ics3/eepparam.h b/include/ics3/eepparam.hpp similarity index 99% rename from include/ics3/eepparam.h rename to include/ics3/eepparam.hpp index 5893d7a..683b39c 100644 --- a/include/ics3/eepparam.h +++ b/include/ics3/eepparam.hpp @@ -29,8 +29,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "ics3/baudrate.h" -#include "ics3/check_invalid.h" +#include "ics3/baudrate.hpp" +#include "ics3/check_invalid.hpp" namespace ics { diff --git a/include/ics3/eeprom.h b/include/ics3/eeprom.hpp similarity index 98% rename from include/ics3/eeprom.h rename to include/ics3/eeprom.hpp index cd1d49b..b9b4de1 100644 --- a/include/ics3/eeprom.h +++ b/include/ics3/eeprom.hpp @@ -29,7 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "ics3/eepparam.h" +#include "ics3/eepparam.hpp" namespace ics { diff --git a/include/ics3/ics b/include/ics3/ics index 4dde804..752cdc3 100644 --- a/include/ics3/ics +++ b/include/ics3/ics @@ -27,13 +27,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef LIBICS3_ICS3_ICS_H #define LIBICS3_ICS3_ICS_H -#include "ics3/angle.h" -#include "ics3/baudrate.h" -#include "ics3/check_invalid.h" -#include "ics3/eepparam.h" -#include "ics3/eeprom.h" -#include "ics3/ics3.h" -#include "ics3/id.h" -#include "ics3/parameter.h" +#include "ics3/angle.hpp" +#include "ics3/baudrate.hpp" +#include "ics3/check_invalid.hpp" +#include "ics3/eepparam.hpp" +#include "ics3/eeprom.hpp" +#include "ics3/ics3.hpp" +#include "ics3/id.hpp" +#include "ics3/parameter.hpp" #endif // LIBICS3_ICS3_ICS_H diff --git a/include/ics3/ics3.h b/include/ics3/ics3.hpp similarity index 97% rename from include/ics3/ics3.h rename to include/ics3/ics3.hpp index 84e17c9..4cc7702 100644 --- a/include/ics3/ics3.h +++ b/include/ics3/ics3.hpp @@ -30,8 +30,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "ics3/angle.h" -#include "ics3/baudrate.h" +#include "ics3/angle.hpp" +#include "ics3/baudrate.hpp" namespace ics { diff --git a/include/ics3/id.h b/include/ics3/id.hpp similarity index 100% rename from include/ics3/id.h rename to include/ics3/id.hpp diff --git a/include/ics3/parameter.h b/include/ics3/parameter.hpp similarity index 98% rename from include/ics3/parameter.h rename to include/ics3/parameter.hpp index 76035b1..c9fe643 100644 --- a/include/ics3/parameter.h +++ b/include/ics3/parameter.hpp @@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef LIBICS3_ICS3_PARAMETER_H #define LIBICS3_ICS3_PARAMETER_H -#include "ics3/check_invalid.h" +#include "ics3/check_invalid.hpp" namespace ics { diff --git a/src/core.cpp b/src/core.cpp index 8305360..5d9e477 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include // for open FLAGS #include // for tty checks -#include "core.h" +#include "core.hpp" ics::Core::Core(const std::string& path, speed_t baudrate) : fd {open(path.c_str(), O_RDWR | O_NOCTTY)}, diff --git a/src/ics3.cpp b/src/ics3.cpp index be7ddec..313362e 100644 --- a/src/ics3.cpp +++ b/src/ics3.cpp @@ -24,12 +24,12 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "ics3/ics3.h" +#include "ics3/ics3.hpp" -#include "core.h" -#include "ics3/eeprom.h" -#include "ics3/id.h" -#include "ics3/parameter.h" +#include "core.hpp" +#include "ics3/eeprom.hpp" +#include "ics3/id.hpp" +#include "ics3/parameter.hpp" static inline ics::Angle::rawType getReceiveAngle(const ics::Core::Container& rx) noexcept { From 8b74759badae7713c1f588621e94ca30efc2573b Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Wed, 30 Nov 2016 11:30:07 +0900 Subject: [PATCH 03/27] Sort forward declaration by alfabet --- include/ics3/ics3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ics3/ics3.h b/include/ics3/ics3.h index 84e17c9..c8fb329 100644 --- a/include/ics3/ics3.h +++ b/include/ics3/ics3.h @@ -37,9 +37,9 @@ namespace ics { // Forward declaration class Core; -class Parameter; class EepRom; class ID; +class Parameter; class ICS3 { From 1bdcefcb14224bcd79d130016b80321a962ac8e0 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Thu, 1 Dec 2016 10:53:02 +0900 Subject: [PATCH 04/27] Update test id to 0 --- test/integrate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integrate.cpp b/test/integrate.cpp index 0c2e6e8..d7c8215 100644 --- a/test/integrate.cpp +++ b/test/integrate.cpp @@ -140,7 +140,7 @@ TEST(AllTestInIntegrate, Parameter) { TEST(AllTestInIntegrate, ICS3) { constexpr auto path = "/dev/ttyUSB0"; constexpr auto baudrate = ics::Baudrate::RATE115200(); - constexpr ics::ID id {2}; + constexpr ics::ID id {0}; try { ics::ICS3 ics {path, baudrate}; testIcsMove(ics, id); From 0935a30ddfc606193650a9c34286bd178b2e7015 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 09:55:22 +0900 Subject: [PATCH 05/27] Change core interface for single thread only --- include/core.hpp | 2 +- src/core.cpp | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/core.hpp b/include/core.hpp index 440b246..23788b1 100644 --- a/include/core.hpp +++ b/include/core.hpp @@ -50,7 +50,7 @@ class Core Core(Core&&) noexcept; Core& operator=(Core&&) noexcept; - static std::shared_ptr getCore(const std::string&, speed_t); + static std::unique_ptr getCore(const std::string&, speed_t); void communicate(const Container&, Container&); void communicateID(const IDContainerTx&, IDContainerRx&); private: diff --git a/src/core.cpp b/src/core.cpp index 183e743..53c4394 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -33,6 +33,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "core.hpp" +template +inline std::unique_ptr make_unique(Args&&... args) +{ + return std::unique_ptr(new T(std::forward(args)...)); +} + ics::Core::Core(const std::string& path, speed_t baudrate) : fd {open(path.c_str(), O_RDWR | O_NOCTTY)}, oldTio {} @@ -81,16 +87,9 @@ ics::Core& ics::Core::operator=(Core&& rhs) noexcept return *this; } -std::shared_ptr ics::Core::getCore(const std::string& path, speed_t baudrate) +std::unique_ptr ics::Core::getCore(const std::string& path, speed_t baudrate) { - static std::unordered_map> cache; - auto objPtr = cache[path].lock(); // try get -// for (const auto& data : cache) if (data.second.expired()) cache.erase(data.first); // clean cashe //FIXME error code - if (!objPtr) { // get failed - objPtr = std::make_shared(path, baudrate); - cache[path] = objPtr; - } - return objPtr; + return make_unique(path, baudrate); } void ics::Core::communicate(const Container& tx, Container& rx) From d48280bcbfb7febff482211c343f12b91caa653b Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 09:56:39 +0900 Subject: [PATCH 06/27] Apply pointer type changed --- include/ics3/ics3.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ics3/ics3.hpp b/include/ics3/ics3.hpp index 357092e..d3fc1d1 100644 --- a/include/ics3/ics3.hpp +++ b/include/ics3/ics3.hpp @@ -54,7 +54,7 @@ class ICS3 ID getID(); void setID(const ID&); private: - std::shared_ptr core; + std::unique_ptr core; }; } From 400c5519ea5a3024e8eee40ee95e3d9b06217d18 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 10:25:27 +0900 Subject: [PATCH 07/27] Remove my make_unique function --- src/core.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index 53c4394..254ba7b 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -33,12 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "core.hpp" -template -inline std::unique_ptr make_unique(Args&&... args) -{ - return std::unique_ptr(new T(std::forward(args)...)); -} - ics::Core::Core(const std::string& path, speed_t baudrate) : fd {open(path.c_str(), O_RDWR | O_NOCTTY)}, oldTio {} @@ -89,7 +83,7 @@ ics::Core& ics::Core::operator=(Core&& rhs) noexcept std::unique_ptr ics::Core::getCore(const std::string& path, speed_t baudrate) { - return make_unique(path, baudrate); + return std::unique_ptr(path, baudrate); } void ics::Core::communicate(const Container& tx, Container& rx) From 31f27faf60d23ed3ef26f5120a12c1db13a297cf Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 10:29:16 +0900 Subject: [PATCH 08/27] Fix miss use constructor of unique_ptr --- src/core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.cpp b/src/core.cpp index 254ba7b..0d8ea6e 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -83,7 +83,7 @@ ics::Core& ics::Core::operator=(Core&& rhs) noexcept std::unique_ptr ics::Core::getCore(const std::string& path, speed_t baudrate) { - return std::unique_ptr(path, baudrate); + return std::unique_ptr {new Core {path, baudrate}}; } void ics::Core::communicate(const Container& tx, Container& rx) From cbcea6b1f0876344eb5df1828de6463b75b2a6ad Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 10:34:59 +0900 Subject: [PATCH 09/27] Revert "Fix miss use constructor of unique_ptr" This reverts commit 31f27faf60d23ed3ef26f5120a12c1db13a297cf. --- src/core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.cpp b/src/core.cpp index 0d8ea6e..254ba7b 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -83,7 +83,7 @@ ics::Core& ics::Core::operator=(Core&& rhs) noexcept std::unique_ptr ics::Core::getCore(const std::string& path, speed_t baudrate) { - return std::unique_ptr {new Core {path, baudrate}}; + return std::unique_ptr(path, baudrate); } void ics::Core::communicate(const Container& tx, Container& rx) From 7706574a849fa681bb0714f7ecde517b2f1fbb76 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 10:35:06 +0900 Subject: [PATCH 10/27] Revert "Remove my make_unique function" This reverts commit 400c5519ea5a3024e8eee40ee95e3d9b06217d18. --- src/core.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core.cpp b/src/core.cpp index 254ba7b..53c4394 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -33,6 +33,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "core.hpp" +template +inline std::unique_ptr make_unique(Args&&... args) +{ + return std::unique_ptr(new T(std::forward(args)...)); +} + ics::Core::Core(const std::string& path, speed_t baudrate) : fd {open(path.c_str(), O_RDWR | O_NOCTTY)}, oldTio {} @@ -83,7 +89,7 @@ ics::Core& ics::Core::operator=(Core&& rhs) noexcept std::unique_ptr ics::Core::getCore(const std::string& path, speed_t baudrate) { - return std::unique_ptr(path, baudrate); + return make_unique(path, baudrate); } void ics::Core::communicate(const Container& tx, Container& rx) From 6675027fd5c70731a38421b45247a1ced672acd4 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 10:39:40 +0900 Subject: [PATCH 11/27] Add destructor for unique_ptr --- include/ics3/ics3.hpp | 1 + src/ics3.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/ics3/ics3.hpp b/include/ics3/ics3.hpp index d3fc1d1..e4c399c 100644 --- a/include/ics3/ics3.hpp +++ b/include/ics3/ics3.hpp @@ -45,6 +45,7 @@ class ICS3 { public: explicit ICS3(const std::string&, const Baudrate& = Baudrate::RATE115200()); + ~ICS3() noexcept; Angle move(const ID&, Angle); Angle free(const ID&, Angle = Angle::newRadian()); Parameter get(const ID&, const Parameter&); diff --git a/src/ics3.cpp b/src/ics3.cpp index 313362e..50d67ea 100644 --- a/src/ics3.cpp +++ b/src/ics3.cpp @@ -46,6 +46,10 @@ ics::ICS3::ICS3(const std::string& path, const Baudrate& baudrate) { } +ics::ICS3::~ICS3() noexcept +{ +} + ics::Angle ics::ICS3::move(const ID& id, Angle angle) { static Core::Container tx(3), rx(6); // cache for runtime speed From 2ae157c4ae4c7ffd75ff17648852b3fe109105ee Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:00:49 +0900 Subject: [PATCH 12/27] Reformat core.hpp --- include/core.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/core.hpp b/include/core.hpp index 23788b1..4cc6e3d 100644 --- a/include/core.hpp +++ b/include/core.hpp @@ -55,7 +55,6 @@ class Core void communicateID(const IDContainerTx&, IDContainerRx&); private: void closeThis() const noexcept; - static termios getTermios() noexcept; int fd; From 1cf42d9b646bed3e824767bb30d925f670224cae Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:02:46 +0900 Subject: [PATCH 13/27] Reformat angle.hpp --- include/ics3/angle.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/ics3/angle.hpp b/include/ics3/angle.hpp index dbbbd83..fe0fd57 100644 --- a/include/ics3/angle.hpp +++ b/include/ics3/angle.hpp @@ -32,6 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace ics { class ICS3; + class Angle { friend ICS3; // for touch rawData From 215b2d1fb30c591bf65996012761700bc53b3c2f Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:05:44 +0900 Subject: [PATCH 14/27] Reformat eepparam.hpp --- include/ics3/eepparam.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/ics3/eepparam.hpp b/include/ics3/eepparam.hpp index 683b39c..40ac5c2 100644 --- a/include/ics3/eepparam.hpp +++ b/include/ics3/eepparam.hpp @@ -237,18 +237,18 @@ inline void EepParam::write(TargetContainer& dest) const noexcept } constexpr EepParam::EepParam( - size_type offset, - size_type length, - type min, - type max, - ValidChecker setFunc, - type data) -: offset(offset), - length(length), - min(min), - max(max), - setFunc(setFunc), - data(setFunc(data, min, max)) // throw std::invalid_argument, std::out_of_range + size_type offset, + size_type length, + type min, + type max, + ValidChecker setFunc, + type data) + : offset(offset), + length(length), + min(min), + max(max), + setFunc(setFunc), + data(setFunc(data, min, max)) // throw std::invalid_argument, std::out_of_range { } From 5740548df812cdda2012ec6e609719ef74424260 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:06:14 +0900 Subject: [PATCH 15/27] Reformat constructor of Angle --- include/ics3/angle.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ics3/angle.hpp b/include/ics3/angle.hpp index fe0fd57..dbfd266 100644 --- a/include/ics3/angle.hpp +++ b/include/ics3/angle.hpp @@ -123,8 +123,8 @@ inline void Angle::setRaw(rawType raw) } constexpr Angle::Angle(type calibration, type angle) -: rawData {checkValidAngle(castToRaw(calibration, angle))}, // throw std::out_of_range - rawCalibration {calibration} + : rawData {checkValidAngle(castToRaw(calibration, angle))}, // throw std::out_of_range + rawCalibration {calibration} { } From 11e68d192094ee09fb672297cf76c8e10ae806c5 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:06:42 +0900 Subject: [PATCH 16/27] Reformat constructor of Baudrate --- include/ics3/baudrate.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ics3/baudrate.hpp b/include/ics3/baudrate.hpp index af5d626..c0cff0d 100644 --- a/include/ics3/baudrate.hpp +++ b/include/ics3/baudrate.hpp @@ -69,8 +69,8 @@ constexpr speed_t Baudrate::getSpeed() const noexcept } constexpr Baudrate::Baudrate(type romdata, speed_t baudrate) noexcept -: romdata {romdata}, - baudrate {baudrate} + : romdata {romdata}, + baudrate {baudrate} { } } From da8cd1c44567cac3b7fe9d3fd1d2fa30b182e0d2 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:07:33 +0900 Subject: [PATCH 17/27] Reformat eeprom.hpp --- include/ics3/eeprom.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ics3/eeprom.hpp b/include/ics3/eeprom.hpp index b9b4de1..367c826 100644 --- a/include/ics3/eeprom.hpp +++ b/include/ics3/eeprom.hpp @@ -69,7 +69,7 @@ inline void EepRom::write(Iter&& dest) const } inline EepRom::EepRom(const Container& src) -: data(src) // for Ubuntu14.04 compiler + : data(src) // for Ubuntu14.04 compiler { } } From c5a2d400e177c15a4f3042edb990c68712ae4e34 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:09:51 +0900 Subject: [PATCH 18/27] Reformat header file of Angle --- include/ics3/angle.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/ics3/angle.hpp b/include/ics3/angle.hpp index dbfd266..49eb29c 100644 --- a/include/ics3/angle.hpp +++ b/include/ics3/angle.hpp @@ -39,6 +39,7 @@ class Angle public: using rawType = uint16_t; using type = double; + static constexpr Angle newDegree(type = 0.0); static constexpr Angle newRadian(type = 0.0); static constexpr Angle newSameUnit(const Angle&, type = 0.0); @@ -50,6 +51,7 @@ class Angle Angle(const Angle&) noexcept = default; Angle& operator=(const Angle&) noexcept; + constexpr type get() const noexcept; constexpr operator type() const noexcept; void set(type); @@ -58,6 +60,7 @@ class Angle void setRaw(rawType); private: constexpr Angle(type, type); // non explicit, user cannot touch this + static constexpr rawType castToRaw(type, type) noexcept; static constexpr rawType checkValidAngle(rawType); From dac47908239c70da150b90c6631eb440f888717b Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:10:33 +0900 Subject: [PATCH 19/27] Reformat declaration of Baudrate --- include/ics3/baudrate.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/ics3/baudrate.hpp b/include/ics3/baudrate.hpp index c0cff0d..f702767 100644 --- a/include/ics3/baudrate.hpp +++ b/include/ics3/baudrate.hpp @@ -35,9 +35,11 @@ class Baudrate { public: using type = uint8_t; + static constexpr Baudrate RATE115200() noexcept; //static constexpr Baudrate RATE625000() noexcept; //static constexpr Baudrate RATE1250000() noexcept; + constexpr type get() const noexcept; constexpr operator type() const noexcept; constexpr speed_t getSpeed() const noexcept; From b2374ba7008647d58e9a51949c3036ac6309f291 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:11:49 +0900 Subject: [PATCH 20/27] Reformat declaration of EepParam --- include/ics3/eepparam.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/ics3/eepparam.hpp b/include/ics3/eepparam.hpp index 40ac5c2..dfb24dc 100644 --- a/include/ics3/eepparam.hpp +++ b/include/ics3/eepparam.hpp @@ -41,6 +41,7 @@ class EepParam using TargetContainer = std::array; using size_type = TargetContainer::size_type; using ValidChecker = type (&)(type, type, type); + enum Flag : type { REVERSE = 0x01, @@ -86,6 +87,7 @@ class EepParam type, ValidChecker, type); + static constexpr type checkValidRange(type, type, type); static constexpr type checkValidEvenRange(type, type, type); static constexpr type checkValidFlag(type, type, type); From ac71755a6ba437f15f691bd3f19a4c7d279942a6 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:12:39 +0900 Subject: [PATCH 21/27] Reformat declaration of ICS3 --- include/ics3/ics3.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/ics3/ics3.hpp b/include/ics3/ics3.hpp index e4c399c..6bf62bf 100644 --- a/include/ics3/ics3.hpp +++ b/include/ics3/ics3.hpp @@ -46,6 +46,7 @@ class ICS3 public: explicit ICS3(const std::string&, const Baudrate& = Baudrate::RATE115200()); ~ICS3() noexcept; + Angle move(const ID&, Angle); Angle free(const ID&, Angle = Angle::newRadian()); Parameter get(const ID&, const Parameter&); From 31dc7eaa548025ed12f7d353ea2c67f7b3dfcdd5 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:13:18 +0900 Subject: [PATCH 22/27] Reformat id.hpp --- include/ics3/id.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/ics3/id.hpp b/include/ics3/id.hpp index d490abd..177441d 100644 --- a/include/ics3/id.hpp +++ b/include/ics3/id.hpp @@ -35,7 +35,9 @@ class ID { public: using type = uint8_t; + constexpr ID(type); // ID is non explicit constructor because only do check limit + constexpr type get() const noexcept; constexpr operator type() const noexcept; private: @@ -43,7 +45,7 @@ class ID }; constexpr ID::ID(type id) -: data {id < 32 ? id : throw std::invalid_argument {"invalid ID: must be 0 <= id <= 31"}} + : data {id < 32 ? id : throw std::invalid_argument {"invalid ID: must be 0 <= id <= 31"}} { } From 4d53d4a1d5a60f300b857e602742e1d8b73622b2 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:14:00 +0900 Subject: [PATCH 23/27] Reformat parameter.hpp --- include/ics3/parameter.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/ics3/parameter.hpp b/include/ics3/parameter.hpp index c9fe643..58530b4 100644 --- a/include/ics3/parameter.hpp +++ b/include/ics3/parameter.hpp @@ -35,6 +35,7 @@ class Parameter { public: using type = uint8_t; + static constexpr Parameter stretch(type = 30); static constexpr Parameter speed(type = 127); static constexpr Parameter current(type = 63); @@ -107,10 +108,10 @@ constexpr Parameter::type Parameter::getSubcommand() const noexcept } constexpr Parameter::Parameter(type sc, type min, type max, type defaultData) -: sc {sc}, - min {min}, - max {max}, - data {checkValidRange(defaultData, min, max)} + : sc {sc}, + min {min}, + max {max}, + data {checkValidRange(defaultData, min, max)} { } } From 0b805fda9fba45b08746c8f16100c1528c06afeb Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:14:48 +0900 Subject: [PATCH 24/27] Reformat declaration of Core --- include/core.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/core.hpp b/include/core.hpp index 4cc6e3d..3bb5237 100644 --- a/include/core.hpp +++ b/include/core.hpp @@ -43,6 +43,7 @@ class Core using Container = std::vector; using IDContainerTx = std::array; using IDContainerRx = std::array; + explicit Core(const std::string&, speed_t); // touch by only libics3 ~Core() noexcept; Core(const Core&) = delete; @@ -51,10 +52,12 @@ class Core Core& operator=(Core&&) noexcept; static std::unique_ptr getCore(const std::string&, speed_t); + void communicate(const Container&, Container&); void communicateID(const IDContainerTx&, IDContainerRx&); private: void closeThis() const noexcept; + static termios getTermios() noexcept; int fd; From 92f32eca83137e66d5cd748fe0a177353d36f322 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:15:40 +0900 Subject: [PATCH 25/27] Reformat constructor of Core --- src/core.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index 53c4394..c9c2bdd 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -40,8 +40,8 @@ inline std::unique_ptr make_unique(Args&&... args) } ics::Core::Core(const std::string& path, speed_t baudrate) -: fd {open(path.c_str(), O_RDWR | O_NOCTTY)}, - oldTio {} + : fd {open(path.c_str(), O_RDWR | O_NOCTTY)}, + oldTio {} { if (fd < 0) throw std::runtime_error {"Cannot open deveice"}; @@ -70,8 +70,8 @@ ics::Core::~Core() noexcept } ics::Core::Core(Core&& rhs) noexcept -: fd {rhs.fd}, - oldTio(rhs.oldTio) // for Ubuntu14.04 compiler + : fd {rhs.fd}, + oldTio(rhs.oldTio) // for Ubuntu14.04 compiler { rhs.fd = -1; } From 54137aa437c85716b004f63fc57a1b6c41e678ec Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:15:51 +0900 Subject: [PATCH 26/27] Reformat constructor of ICS3 --- src/ics3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ics3.cpp b/src/ics3.cpp index 50d67ea..451a25b 100644 --- a/src/ics3.cpp +++ b/src/ics3.cpp @@ -42,7 +42,7 @@ static inline ics::Core::value_type getCmd(const ics::Core::value_type head, con } ics::ICS3::ICS3(const std::string& path, const Baudrate& baudrate) -: core {Core::getCore(path, baudrate.getSpeed())} // throw std::invalid_argument, std::runtime_error + : core {Core::getCore(path, baudrate.getSpeed())} // throw std::invalid_argument, std::runtime_error { } From eb307941b75febc05f926ac774efa0f88fcbec10 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 27 Jan 2017 11:22:37 +0900 Subject: [PATCH 27/27] Register v1.4.0 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1f2a2e..449fe35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 2.8.12.1) project(ics3 C CXX) set(PROJECT_VER_MAJOR 1) -set(PROJECT_VER_MINOR 3) -set(PROJECT_VER_PATCH 2) +set(PROJECT_VER_MINOR 4) +set(PROJECT_VER_PATCH 0) set(PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") set(PROJECT_APIVER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}")