From 6d25ad3ce74678b1e6b34e83730570be37369548 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 4 Nov 2016 21:28:54 +0900 Subject: [PATCH 01/19] Order my includes by alfabet --- include/ics3/eepparam.hpp | 2 +- src/ics3.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ics3/eepparam.hpp b/include/ics3/eepparam.hpp index 0db67a0..7cb56cf 100644 --- a/include/ics3/eepparam.hpp +++ b/include/ics3/eepparam.hpp @@ -1,8 +1,8 @@ #ifndef LIBICS3_ICS3_EEPPARAM_H_ #define LIBICS3_ICS3_EEPPARAM_H_ -#include"ics3/check_invalid.hpp" #include"ics3/baudrate.hpp" +#include"ics3/check_invalid.hpp" #include diff --git a/src/ics3.cpp b/src/ics3.cpp index 864b031..0e40fff 100644 --- a/src/ics3.cpp +++ b/src/ics3.cpp @@ -2,8 +2,8 @@ #include"core.hpp" #include"ics3/eeprom.hpp" -#include"ics3/parameter.hpp" #include"ics3/id.hpp" +#include"ics3/parameter.hpp" static inline ics::Angle::rawType getReceiveAngle(const ics::Core::Container& rx) noexcept { return (rx[4] << 7) | rx[5]; From 0318a5674e25ae44a7d254c1cc25b10bb6f09ff3 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 4 Nov 2016 21:31:10 +0900 Subject: [PATCH 02/19] Order includes of std library by alfabet --- src/core.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index f114a9e..cc6275a 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -1,11 +1,11 @@ #include"core.hpp" #include -#include +#include // for error massage +#include // for cashe +#include // for memset #include // for open FLAGS #include // for tty checks -#include // for memset -#include // for cashe ics::Core::Core(const std::string& path, speed_t baudrate) : fd {open(path.c_str(), O_RDWR | O_NOCTTY)}, From 3170468b76fc49cab5006bf5a5350cdb87722543 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 4 Nov 2016 21:38:00 +0900 Subject: [PATCH 03/19] Order includes of std library by alfabet --- include/core.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/core.hpp b/include/core.hpp index 95a89b6..a2af425 100644 --- a/include/core.hpp +++ b/include/core.hpp @@ -1,10 +1,10 @@ #ifndef LIBICS3_ICS3_CORE_H_ #define LIBICS3_ICS3_CORE_H_ -#include #include -#include #include +#include +#include #include namespace ics { From 009046f40520c209edb6d558110b4eaa5d52269e Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 4 Nov 2016 21:39:29 +0900 Subject: [PATCH 04/19] Order includes of std library by alfabet --- 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 7ba8392..d4c61ed 100644 --- a/include/ics3/ics3.hpp +++ b/include/ics3/ics3.hpp @@ -4,8 +4,8 @@ #include"ics3/angle.hpp" #include"ics3/baudrate.hpp" -#include #include +#include namespace ics { // Forward declaration From 2ac153c211b20b43eb7084b417a327c2a13d1b2d Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 4 Nov 2016 22:36:54 +0900 Subject: [PATCH 05/19] Rename Valid check function to checkValidRange --- include/ics3/angle.hpp | 10 ++--- include/ics3/check_invalid.hpp | 2 +- include/ics3/eepparam.hpp | 68 +++++++++++++++++----------------- include/ics3/parameter.hpp | 4 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/include/ics3/angle.hpp b/include/ics3/angle.hpp index fbd56e0..20a9612 100644 --- a/include/ics3/angle.hpp +++ b/include/ics3/angle.hpp @@ -30,7 +30,7 @@ namespace ics { private: constexpr Angle(type, type); // non explicit, user cannot touch this static constexpr rawType castToRaw(type, type) noexcept; - static constexpr rawType checkInvalidAngle(rawType); + static constexpr rawType checkValidAngle(rawType); rawType rawData; const type rawCalibration; @@ -79,11 +79,11 @@ namespace ics { } inline void Angle::setRaw(rawType raw) { - rawData = checkInvalidAngle(raw); // throw std::out_of_range + rawData = checkValidAngle(raw); // throw std::out_of_range } constexpr Angle::Angle(type calibration, type angle) - : rawData {checkInvalidAngle(castToRaw(calibration, angle))}, // throw std::out_of_range + : rawData {checkValidAngle(castToRaw(calibration, angle))}, // throw std::out_of_range rawCalibration {calibration} {} @@ -91,8 +91,8 @@ namespace ics { return (calibration * angle) + MID; } - constexpr Angle::rawType Angle::checkInvalidAngle(rawType raw) { - return checkInvalidRange(raw, MIN, MAX); + constexpr Angle::rawType Angle::checkValidAngle(rawType raw) { + return checkValidRange(raw, MIN, MAX); } } diff --git a/include/ics3/check_invalid.hpp b/include/ics3/check_invalid.hpp index 8c058e7..4487955 100644 --- a/include/ics3/check_invalid.hpp +++ b/include/ics3/check_invalid.hpp @@ -5,7 +5,7 @@ namespace ics { template - constexpr T checkInvalidRange(T input, const T min, const T max) { + constexpr T checkValidRange(T input, const T min, const T max) { return input < min ? throw std::out_of_range {"Too small argument"} : max < input ? throw std::out_of_range {"Too big argument"} : input; diff --git a/include/ics3/eepparam.hpp b/include/ics3/eepparam.hpp index 7cb56cf..b42adb0 100644 --- a/include/ics3/eepparam.hpp +++ b/include/ics3/eepparam.hpp @@ -12,7 +12,7 @@ namespace ics { using type = uint16_t; using TargetContainer = std::array; using size_type = TargetContainer::size_type; - using InvalidChecker = type (&)(type, type, type); + using ValidChecker = type (&)(type, type, type); enum Flag : type { REVERSE = 0x01, FREE = 0x02, @@ -55,92 +55,92 @@ namespace ics { size_type, type, type, - InvalidChecker, + ValidChecker, type); - static constexpr type checkInvalidRange(type, type, type); - static constexpr type checkInvalidEvenRange(type, type, type); - static constexpr type checkInvalidFlag(type, type, type); - static constexpr type checkInvalidBaudrate(type, type, type); - static constexpr type checkInvalidOffset(type, type, type); + static constexpr type checkValidRange(type, type, type); + static constexpr type checkValidEvenRange(type, type, type); + static constexpr type checkValidFlag(type, type, type); + static constexpr type checkValidBaudrate(type, type, type); + static constexpr type checkValidOffset(type, type, type); const size_type offset; const size_type length; const type min; const type max; - InvalidChecker setFunc; + ValidChecker setFunc; type data; }; constexpr EepParam EepParam::stretch(type data) { - return {2, 2, 2, 254, EepParam::checkInvalidEvenRange, data}; + return {2, 2, 2, 254, EepParam::checkValidEvenRange, data}; } constexpr EepParam EepParam::speed(type data) { - return {4, 2, 1, 127, EepParam::checkInvalidRange, data}; + return {4, 2, 1, 127, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::punch(type data) { - return {6, 2, 0, 10, EepParam::checkInvalidRange, data}; + return {6, 2, 0, 10, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::deadBand(type data) { - return {8, 2, 0, 5, EepParam::checkInvalidRange, data}; + return {8, 2, 0, 5, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::dumping(type data) { - return {10, 2, 1, 255, EepParam::checkInvalidRange, data}; + return {10, 2, 1, 255, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::selfTimer(type data) { - return {12, 2, 10, 255, EepParam::checkInvalidRange, data}; + return {12, 2, 10, 255, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::flag(type data) { - return {14, 2, 0, 255, EepParam::checkInvalidFlag, data}; + return {14, 2, 0, 255, EepParam::checkValidFlag, data}; } constexpr EepParam EepParam::pulseMax(type data) { - return {16, 4, 3500, 11500, EepParam::checkInvalidRange, data}; + return {16, 4, 3500, 11500, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::pulseMin(type data) { - return {20, 4, 3500, 11500, EepParam::checkInvalidRange, data}; + return {20, 4, 3500, 11500, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::baudrate(type data) { - return {26, 2, 0, 10, EepParam::checkInvalidBaudrate, data}; + return {26, 2, 0, 10, EepParam::checkValidBaudrate, data}; } constexpr EepParam EepParam::temperature(type data) { - return {28, 2, 1, 127, EepParam::checkInvalidRange, data}; + return {28, 2, 1, 127, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::current(type data) { - return {30, 2, 1, 63, EepParam::checkInvalidRange, data}; + return {30, 2, 1, 63, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::response(type data) { - return {50, 2, 1, 5, EepParam::checkInvalidRange, data}; + return {50, 2, 1, 5, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::userOffset(type data) { - return {52, 2, 0x81, 127, EepParam::checkInvalidOffset, data}; // 0x81 is -127 on uint8_t type + return {52, 2, 0x81, 127, EepParam::checkValidOffset, data}; // 0x81 is -127 on uint8_t type } constexpr EepParam EepParam::id(type data) { - return {56, 2, 0, 31, EepParam::checkInvalidRange, data}; + return {56, 2, 0, 31, EepParam::checkValidRange, data}; } constexpr EepParam EepParam::strech1(type data) { - return {58, 2, 2, 254, EepParam::checkInvalidEvenRange, data}; + return {58, 2, 2, 254, EepParam::checkValidEvenRange, data}; } constexpr EepParam EepParam::strech2(type data) { - return {60, 2, 2, 254, EepParam::checkInvalidEvenRange, data}; + return {60, 2, 2, 254, EepParam::checkValidEvenRange, data}; } constexpr EepParam EepParam::strech3(type data) { - return {62, 2, 2, 254, EepParam::checkInvalidEvenRange, data}; + return {62, 2, 2, 254, EepParam::checkValidEvenRange, data}; } constexpr EepParam EepParam::newEepParam(const EepParam& paramType, type data) { @@ -187,7 +187,7 @@ namespace ics { size_type length, type min, type max, - InvalidChecker setFunc, + ValidChecker setFunc, type data) : offset(offset), length(length), @@ -197,30 +197,30 @@ namespace ics { data(setFunc(data, min, max)) // throw std::invalid_argument, std::out_of_range {} - constexpr EepParam::type EepParam::checkInvalidRange(type input, type min, type max) { - return ics::checkInvalidRange(input, min, max); + constexpr EepParam::type EepParam::checkValidRange(type input, type min, type max) { + return ics::checkValidRange(input, min, max); } - constexpr EepParam::type EepParam::checkInvalidEvenRange(type input, type min, type max) { + constexpr EepParam::type EepParam::checkValidEvenRange(type input, type min, type max) { return input % 2 ? throw std::out_of_range {"Must even value"} : - checkInvalidRange(input, min, max); // throw std::out_of_range + checkValidRange(input, min, max); // throw std::out_of_range } - constexpr EepParam::type EepParam::checkInvalidFlag(type input, type, type) { + constexpr EepParam::type EepParam::checkValidFlag(type input, type, type) { return !(input & 0x04) ? throw std::invalid_argument {"Eepparam(flag): Must up bits 0x04"} : ~(input | ~0x60) ? throw std::invalid_argument {"Eepparam(flag): Must down bits 0x60"} : input; } - constexpr EepParam::type EepParam::checkInvalidBaudrate(type input, type, type) { + constexpr EepParam::type EepParam::checkValidBaudrate(type input, type, type) { return input == Baudrate::RATE115200().get() ? input : //input == Baudrate::RATE625000().get() ? input : //input == Baudrate::RATE1250000().get() ? input : throw std::invalid_argument {"baudrate not exist"}; } - constexpr EepParam::type EepParam::checkInvalidOffset(type input, type min, type max) { + constexpr EepParam::type EepParam::checkValidOffset(type input, type min, type max) { return input < max ? input : // this min < 0; min value is 0 min < input ? input : // this min < 0; input must is bigger than min. throw std::out_of_range {"Eeprom(offset): range over"}; // min < input < max is failed diff --git a/include/ics3/parameter.hpp b/include/ics3/parameter.hpp index 8f01289..8e15144 100644 --- a/include/ics3/parameter.hpp +++ b/include/ics3/parameter.hpp @@ -56,7 +56,7 @@ namespace ics { } inline void Parameter::set(type input) { - data = checkInvalidRange(input, min, max); + data = checkValidRange(input, min, max); } inline Parameter& Parameter::operator=(type rhs) { @@ -72,7 +72,7 @@ namespace ics { : sc {sc}, min {min}, max {max}, - data {checkInvalidRange(defaultData, min, max)} + data {checkValidRange(defaultData, min, max)} {} } From a380e6b32461eb95641c977d53cceb75059e5985 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Sat, 5 Nov 2016 13:56:15 +0900 Subject: [PATCH 06/19] Add license code onto top User can take that code copys without modify them --- include/core.hpp | 26 ++++++++++++++++++++++++++ include/ics3/angle.hpp | 26 ++++++++++++++++++++++++++ include/ics3/baudrate.hpp | 26 ++++++++++++++++++++++++++ include/ics3/check_invalid.hpp | 26 ++++++++++++++++++++++++++ include/ics3/eepparam.hpp | 26 ++++++++++++++++++++++++++ include/ics3/eeprom.hpp | 26 ++++++++++++++++++++++++++ include/ics3/ics | 26 ++++++++++++++++++++++++++ include/ics3/ics3.hpp | 26 ++++++++++++++++++++++++++ include/ics3/id.hpp | 26 ++++++++++++++++++++++++++ include/ics3/parameter.hpp | 26 ++++++++++++++++++++++++++ script/setup.sh | 25 +++++++++++++++++++++++++ src/core.cpp | 26 ++++++++++++++++++++++++++ src/ics3.cpp | 26 ++++++++++++++++++++++++++ src/test.cpp | 26 ++++++++++++++++++++++++++ 14 files changed, 363 insertions(+) diff --git a/include/core.hpp b/include/core.hpp index a2af425..f7c7ec5 100644 --- a/include/core.hpp +++ b/include/core.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_CORE_H_ #define LIBICS3_ICS3_CORE_H_ diff --git a/include/ics3/angle.hpp b/include/ics3/angle.hpp index 20a9612..5e1947c 100644 --- a/include/ics3/angle.hpp +++ b/include/ics3/angle.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_ANGLE_H_ #define LIBICS3_ICS3_ANGLE_H_ diff --git a/include/ics3/baudrate.hpp b/include/ics3/baudrate.hpp index 3ec9822..dcc96e6 100644 --- a/include/ics3/baudrate.hpp +++ b/include/ics3/baudrate.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_BAUDRATE_H_ #define LIBICS3_ICS3_BAUDRATE_H_ diff --git a/include/ics3/check_invalid.hpp b/include/ics3/check_invalid.hpp index 4487955..786e29b 100644 --- a/include/ics3/check_invalid.hpp +++ b/include/ics3/check_invalid.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_CHECK_INVALID_H_ #define LIBICS3_ICS3_CHECK_INVALID_H_ diff --git a/include/ics3/eepparam.hpp b/include/ics3/eepparam.hpp index b42adb0..ce02297 100644 --- a/include/ics3/eepparam.hpp +++ b/include/ics3/eepparam.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_EEPPARAM_H_ #define LIBICS3_ICS3_EEPPARAM_H_ diff --git a/include/ics3/eeprom.hpp b/include/ics3/eeprom.hpp index 8661932..5142943 100644 --- a/include/ics3/eeprom.hpp +++ b/include/ics3/eeprom.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_EEPROM_H_ #define LIBICS3_ICS3_EEPROM_H_ diff --git a/include/ics3/ics b/include/ics3/ics index 194bc9e..29f448d 100644 --- a/include/ics3/ics +++ b/include/ics3/ics @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_ICS_H_ #define LIBICS3_ICS3_ICS_H_ diff --git a/include/ics3/ics3.hpp b/include/ics3/ics3.hpp index d4c61ed..f3b7cfa 100644 --- a/include/ics3/ics3.hpp +++ b/include/ics3/ics3.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_ICS3_H_ #define LIBICS3_ICS3_ICS3_H_ diff --git a/include/ics3/id.hpp b/include/ics3/id.hpp index f9650a0..37b3d18 100644 --- a/include/ics3/id.hpp +++ b/include/ics3/id.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_ID_H_ #define LIBICS3_ICS3_ID_H_ diff --git a/include/ics3/parameter.hpp b/include/ics3/parameter.hpp index 8e15144..3e868c1 100644 --- a/include/ics3/parameter.hpp +++ b/include/ics3/parameter.hpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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. +*/ #ifndef LIBICS3_ICS3_PARAMETER_H_ #define LIBICS3_ICS3_PARAMETER_H_ diff --git a/script/setup.sh b/script/setup.sh index 916fe9a..28eb1df 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -1,3 +1,28 @@ +# BSD 2-Clause License +# +# Copyright (c) 2016, Doi Yusuke +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# 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. invalidPID(){ [ $1 -lt 1 ] && return 0 [ $1 -lt 3 ] && return 1 diff --git a/src/core.cpp b/src/core.cpp index cc6275a..c65664c 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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"core.hpp" #include diff --git a/src/ics3.cpp b/src/ics3.cpp index 0e40fff..2825796 100644 --- a/src/ics3.cpp +++ b/src/ics3.cpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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.hpp" #include"core.hpp" diff --git a/src/test.cpp b/src/test.cpp index e995fa7..1d146e9 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -1,3 +1,29 @@ +/* BSD 2-Clause License + +Copyright (c) 2016, Doi Yusuke +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +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/ics" #include From ab6fe7224747f2b90d08e2ece642eed4e2aa978c Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Sat, 5 Nov 2016 14:49:41 +0900 Subject: [PATCH 07/19] Fix move copy method --- src/core.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index c65664c..b797853 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -44,7 +44,7 @@ ics::Core::Core(const std::string& path, speed_t baudrate) throw std::invalid_argument {"Not tty device"}; if (tcgetattr(fd, &oldTio) < 0) throw std::runtime_error {"Cannot setup tty"}; - auto&& newTio = getTermios(); // forward reference + auto newTio = getTermios(); // forward reference if (cfsetispeed(&newTio, baudrate) < 0) throw std::runtime_error {"Cannot set baudrate"}; if (cfsetospeed(&newTio, baudrate) < 0) @@ -70,6 +70,7 @@ ics::Core::Core(Core&& rhs) noexcept } ics::Core& ics::Core::operator=(Core&& rhs) noexcept { + if (&rhs == this) return *this; closeThis(); fd = rhs.fd; oldTio = rhs.oldTio; @@ -92,7 +93,7 @@ void ics::Core::communicate(const Container& tx, Container& rx) { write(fd, tx.data(), tx.size()); // send for (auto& receive : rx) read(fd, &receive, 1); // receive // check section - auto&& receive = rx.cbegin(); + auto receive = rx.cbegin(); for (const auto& send : tx) { if (send != *receive) { std::stringstream ss; @@ -108,7 +109,7 @@ void ics::Core::communicateID(const IDContainerTx& tx, IDContainerRx& rx) { write(fd, tx.data(), tx.size()); // send for (auto& receive : rx) read(fd, &receive, 1); // receive // check section - auto&& receive = rx.cbegin(); + auto receive = rx.cbegin(); for (const auto& send : tx) { if (send != *receive) { std::stringstream ss; From 5557ff945a6a0c34011b0b73ba5953690edcdd59 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Sat, 5 Nov 2016 14:56:44 +0900 Subject: [PATCH 08/19] Update method of check unique --- src/core.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index b797853..f574439 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -70,11 +70,12 @@ ics::Core::Core(Core&& rhs) noexcept } ics::Core& ics::Core::operator=(Core&& rhs) noexcept { - if (&rhs == this) return *this; - closeThis(); - fd = rhs.fd; - oldTio = rhs.oldTio; - rhs.fd = -1; + if (fd != ths.fd) { + closeThis(); + fd = rhs.fd; + oldTio = rhs.oldTio; + rhs.fd = -1; + } return *this; } From e77bfa12cb831085b49a01bb01375208aeee462a Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Sat, 5 Nov 2016 15:02:30 +0900 Subject: [PATCH 09/19] Fix typo --- src/core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.cpp b/src/core.cpp index f574439..b8c5a0f 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -70,7 +70,7 @@ ics::Core::Core(Core&& rhs) noexcept } ics::Core& ics::Core::operator=(Core&& rhs) noexcept { - if (fd != ths.fd) { + if (fd != rhs.fd) { closeThis(); fd = rhs.fd; oldTio = rhs.oldTio; From 794d21119e3844ae17e35cf6b4d5e1386f8721da Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Sat, 5 Nov 2016 15:08:49 +0900 Subject: [PATCH 10/19] Add const to closeThis --- include/core.hpp | 2 +- src/core.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/core.hpp b/include/core.hpp index f7c7ec5..937fbfa 100644 --- a/include/core.hpp +++ b/include/core.hpp @@ -51,7 +51,7 @@ namespace ics { void communicate(const Container&, Container&); void communicateID(const IDContainerTx&, IDContainerRx&); private: - void closeThis() noexcept; + void closeThis() const noexcept; static termios getTermios() noexcept; diff --git a/src/core.cpp b/src/core.cpp index b8c5a0f..6244ae1 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -122,7 +122,7 @@ void ics::Core::communicateID(const IDContainerTx& tx, IDContainerRx& rx) { if ((tx[0] & 0xE0) != (*receive & 0xE0)) throw std::runtime_error {"Receive failed: invalid target data"}; } -void ics::Core::closeThis() noexcept { +void ics::Core::closeThis() const noexcept { tcsetattr(fd, TCSANOW, &oldTio); close(fd); } From a5112ca9c42d61ded4f371cf09d53981949a9b0e Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Sat, 5 Nov 2016 15:23:12 +0900 Subject: [PATCH 11/19] Update with noexcept --- src/ics3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ics3.cpp b/src/ics3.cpp index 2825796..2b8dd00 100644 --- a/src/ics3.cpp +++ b/src/ics3.cpp @@ -35,7 +35,7 @@ static inline ics::Angle::rawType getReceiveAngle(const ics::Core::Container& rx return (rx[4] << 7) | rx[5]; } -static inline ics::Core::value_type getCmd(const ics::Core::value_type head, const ics::ID& id) { +static inline ics::Core::value_type getCmd(const ics::Core::value_type head, const ics::ID& id) noexcept { return head | id.get(); } From a9e23e476b845acc6d0703e5f5a555de914c0dca Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Sat, 5 Nov 2016 15:26:03 +0900 Subject: [PATCH 12/19] Omit cache on free method --- src/ics3.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ics3.cpp b/src/ics3.cpp index 2b8dd00..dc0a5cb 100644 --- a/src/ics3.cpp +++ b/src/ics3.cpp @@ -40,7 +40,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())} +: core {Core::getCore(path, baudrate.getSpeed())} // throw std::invalid_argument, std::runtime_error {} ics::Angle ics::ICS3::move(const ID& id, Angle angle) { @@ -55,8 +55,8 @@ ics::Angle ics::ICS3::move(const ID& id, Angle angle) { } ics::Angle ics::ICS3::free(const ID& id, Angle unit) { - static Core::Container tx(3), rx(6); // cache for runtime speed - tx[0] = getCmd(0x80, id); // tx[1] == tx[2] == 0 + const Core::Container tx {getCmd(0x80, id), 0x00, 0x00}; + Core::Container rx(6); core->communicate(tx, rx); // throw std::runtime_error unit.rawData = getReceiveAngle(rx); // avoid invalid check. need friend return unit; From f5929f7278632baade64ff5623c19e5b0a87a291 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Sat, 5 Nov 2016 20:16:22 +0900 Subject: [PATCH 13/19] Update license text on .sh for shebang --- script/setup.sh | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/script/setup.sh b/script/setup.sh index 28eb1df..707e251 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -1,28 +1,4 @@ -# BSD 2-Clause License -# -# Copyright (c) 2016, Doi Yusuke -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# 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. +#!/bin/sh invalidPID(){ [ $1 -lt 1 ] && return 0 [ $1 -lt 3 ] && return 1 From 148a9689e0edd27c05a13f71a1af6240182fde67 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Mon, 7 Nov 2016 23:00:56 +0900 Subject: [PATCH 14/19] Add license test to .sh file --- script/setup.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/script/setup.sh b/script/setup.sh index 707e251..3d8d0d8 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -1,4 +1,70 @@ #!/bin/sh + +# BSD 2-Clause License +# +# Copyright (c) 2016, Doi Yusuke +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# 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. + +invalidPID(){ + [ $1 -lt 1 ] && return 0 + [ $1 -lt 3 ] && return 1 + [ $1 -lt 6 ] && return 0 + [ $1 -lt 9 ] && return 1 + return 0 +} +if [ $# -gt 0 ]; then + expr $1 + 1 > /dev/null 2>&1 + inputCheck=$? +else + inputCheck=5 +fi +if [ $inputCheck -gt 1 ]; then + echo "Please select your device" + echo "1. ICS USB ADAPTER" + echo "2. SERIAL USB ADAPTER" + echo "3~5: nothing" + echo "6. ICS USB ADAPTER HS" + echo "7. SERIAL USB ADAPTER HS" + echo "8. DUAl USB ADAPTER HS" + read onePID + expr $onePID + 1 > /dev/null 2>&1 + INTCHECK=$? + if [ $INTCHECK -gt 1 ]; then + echo "Invalid argument" + return 1 +fi +else + onePID=$1 +fi +if invalidPID $onePID; then + echo "Out of range" + return 1 +fi +sudo modprobe ftdi-sio +sudo chmod 666 /sys/bus/usb-serial/drivers/ftdi_sio/new_id +echo 165c 000$onePID > /sys/bus/usb-serial/drivers/ftdi_sio/new_id +echo "ttyUSB{x} created : {x} is number." invalidPID(){ [ $1 -lt 1 ] && return 0 [ $1 -lt 3 ] && return 1 From d7e278b0162cc5062a3e800ac6dc41762c854f57 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Mon, 7 Nov 2016 23:03:32 +0900 Subject: [PATCH 15/19] Update argument for meanning --- include/ics3/check_invalid.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ics3/check_invalid.hpp b/include/ics3/check_invalid.hpp index 786e29b..acedbbc 100644 --- a/include/ics3/check_invalid.hpp +++ b/include/ics3/check_invalid.hpp @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace ics { template - constexpr T checkValidRange(T input, const T min, const T max) { + constexpr T checkValidRange(const T input, const T min, const T max) { return input < min ? throw std::out_of_range {"Too small argument"} : max < input ? throw std::out_of_range {"Too big argument"} : input; From 08e9518f8fc8efb66e66e75ac1d3f0a321f396fb Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Mon, 7 Nov 2016 23:04:22 +0900 Subject: [PATCH 16/19] Fix comment of friend --- include/ics3/angle.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ics3/angle.hpp b/include/ics3/angle.hpp index 5e1947c..8533a8c 100644 --- a/include/ics3/angle.hpp +++ b/include/ics3/angle.hpp @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace ics { class ICS3; class Angle { - friend ICS3; // for touch setRaw + friend ICS3; // for touch rawData public: using rawType = uint16_t; using type = double; From ab8dced6ae63b11ffa6b15c54be495e479539315 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Wed, 9 Nov 2016 09:00:57 +0900 Subject: [PATCH 17/19] Register v1.2.5 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d39531..4375539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(ics3 CXX) SET(PROJECT_VER_MAJOR 1) SET(PROJECT_VER_MINOR 2) -SET(PROJECT_VER_PATCH 4) +SET(PROJECT_VER_PATCH 5) SET(PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}") SET(PROJECT_APIVER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}") From c518886d24305d9975b001347f97f1bb7cbefa59 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Wed, 9 Nov 2016 09:02:19 +0900 Subject: [PATCH 18/19] Delete unnecessary space --- script/setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/script/setup.sh b/script/setup.sh index 3d8d0d8..e86f12c 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -1,20 +1,20 @@ #!/bin/sh # BSD 2-Clause License -# +# # Copyright (c) 2016, Doi Yusuke # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE From b83982cd3f15456f3cee3427131e8348428ca886 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Wed, 9 Nov 2016 09:12:45 +0900 Subject: [PATCH 19/19] Delete unnecessay space --- script/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/setup.sh b/script/setup.sh index e86f12c..1cd0b17 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -10,7 +10,7 @@ # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution.