Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #21 from forno/upgrade-v1.2.5
Browse files Browse the repository at this point in the history
Upgrade v1.2.5
  • Loading branch information
forno committed Nov 9, 2016
2 parents f5ff088 + b83982c commit 89a32e2
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 65 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
32 changes: 29 additions & 3 deletions include/core.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
/* 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_

#include<vector>
#include<array>
#include<string>
#include<memory>
#include<string>
#include<vector>
#include<termios.h>

namespace ics {
Expand All @@ -25,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;

Expand Down
38 changes: 32 additions & 6 deletions include/ics3/angle.hpp
Original file line number Diff line number Diff line change
@@ -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_

Expand All @@ -6,7 +32,7 @@
namespace ics {
class ICS3;
class Angle {
friend ICS3; // for touch setRaw
friend ICS3; // for touch rawData
public:
using rawType = uint16_t;
using type = double;
Expand All @@ -30,7 +56,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;
Expand Down Expand Up @@ -79,20 +105,20 @@ 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}
{}

constexpr Angle::rawType Angle::castToRaw(type calibration, type angle) noexcept {
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);
}
}

Expand Down
26 changes: 26 additions & 0 deletions include/ics3/baudrate.hpp
Original file line number Diff line number Diff line change
@@ -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_

Expand Down
28 changes: 27 additions & 1 deletion include/ics3/check_invalid.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
/* 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_

#include<stdexcept>

namespace ics {
template<typename T>
constexpr T checkInvalidRange(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;
Expand Down
Loading

0 comments on commit 89a32e2

Please sign in to comment.