diff --git a/.gitignore b/.gitignore
index 1377554..3a25c0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
*.swp
+.vscode/
diff --git a/README.md b/README.md
index 959c0dd..10390ed 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
# Veddar VESC Interface
+# ROS1 VESC Package

Packages to interface with Veddar VESC motor controllers. See https://vesc-project.com/ for details
+
+The ```noetic``` branch contains the ROS2 branch back ported to ROS1 such that it is compatible with VESC (tested on the VESC EDU)
diff --git a/vesc.yaml b/vesc.yaml
new file mode 100644
index 0000000..4b8588c
--- /dev/null
+++ b/vesc.yaml
@@ -0,0 +1,42 @@
+
+# erpm (electrical rpm) = speed_to_erpm_gain * speed (meters / second) + speed_to_erpm_offset
+speed_to_erpm_gain: 5420 #4614
+speed_to_erpm_offset: 0.0
+
+# Set gains for converting acceleration to current and brake control values
+accel_to_current_gain: 100
+accel_to_brake_gain: -80
+
+tachometer_ticks_to_meters_gain: 0.00225
+# servo smoother - limits rotation speed and smooths anything above limit
+max_servo_speed: 3.2 # radians/second
+servo_smoother_rate: 75.0 # messages/sec
+
+# servo smoother - limits acceleration and smooths anything above limit
+max_acceleration: 2.5 # meters/second^2
+throttle_smoother_rate: 75.0 # messages/sec
+
+# servo value (0 to 1) = steering_angle_to_servo_gain * steering angle (radians) + steering_angle_to_servo_offset
+steering_angle_to_servo_gain: -1.2135
+steering_angle_to_servo_offset: 0.55 #0.5304
+
+# publish odom to base link tf
+vesc_to_odom/publish_tf: false
+
+# car wheelbase is about 25cm
+wheelbase: .256
+
+vesc_driver:
+ port: /dev/sensors/vesc
+ duty_cycle_min: 0.0
+ duty_cycle_max: 0.0
+ current_min: 0.0
+ current_max: 100.0
+ brake_min: -20000.0
+ brake_max: 200000.0
+ speed_min: -23250
+ speed_max: 23250
+ position_min: 0.0
+ position_max: 0.0
+ servo_min: 0.15
+ servo_max: 0.85
diff --git a/vesc/package.xml b/vesc/package.xml
index e1deeb4..e961311 100644
--- a/vesc/package.xml
+++ b/vesc/package.xml
@@ -14,13 +14,18 @@
Michael T. Boulet
Joshua Whitley
+ http://www.ros.org/wiki/vesc
+ https://github.mit.edu/racecar/vesc
+ https://github.mit.edu/racecar/vesc/issues
+
catkin
- vesc_driver
- vesc_msgs
- vesc_ackermann
+ vesc_driver
+ vesc_msgs
+ vesc_ackermann
+
diff --git a/vesc_ackermann/include/vesc_ackermann/vesc_to_odom.h b/vesc_ackermann/include/vesc_ackermann/vesc_to_odom.h
index f864833..7a8b21e 100644
--- a/vesc_ackermann/include/vesc_ackermann/vesc_to_odom.h
+++ b/vesc_ackermann/include/vesc_ackermann/vesc_to_odom.h
@@ -34,6 +34,7 @@
#include
#include
#include
+#include
#include
namespace vesc_ackermann
@@ -58,14 +59,14 @@ class VescToOdom
// odometry state
double x_, y_, yaw_;
- std_msgs::Float64::ConstPtr last_servo_cmd_; ///< Last servo position commanded value
+ std_msgs::Float64::ConstPtr last_servo_cmd_; ///< Last servo position commanded value
vesc_msgs::VescStateStamped::ConstPtr last_state_; ///< Last received state message
// ROS services
ros::Publisher odom_pub_;
ros::Subscriber vesc_state_sub_;
ros::Subscriber servo_sub_;
- std::shared_ptr tf_pub_;
+ boost::shared_ptr tf_pub_;
// ROS callbacks
void vescStateCallback(const vesc_msgs::VescStateStamped::ConstPtr& state);
diff --git a/vesc_ackermann/package.xml b/vesc_ackermann/package.xml
index 34d1301..f2ddcf6 100644
--- a/vesc_ackermann/package.xml
+++ b/vesc_ackermann/package.xml
@@ -17,18 +17,28 @@
catkin
roslint
+ nodelet
+ pluginlib
+ roscpp
+ nav_msgs
+ std_msgs
+ geometry_msgs
+ tf
+ ackermann_msgs
+ vesc_msgs
- ackermann_msgs
- geometry_msgs
- nav_msgs
nodelet
pluginlib
roscpp
+ nav_msgs
std_msgs
+ geometry_msgs
tf
+ ackermann_msgs
vesc_msgs
+
diff --git a/vesc_ackermann/src/ackermann_to_vesc.cpp b/vesc_ackermann/src/ackermann_to_vesc.cpp
index c8c057f..01f1c0b 100644
--- a/vesc_ackermann/src/ackermann_to_vesc.cpp
+++ b/vesc_ackermann/src/ackermann_to_vesc.cpp
@@ -37,28 +37,22 @@ namespace vesc_ackermann
{
template
-inline bool getRequiredParam(const ros::NodeHandle& nh, const std::string& name, T* value);
+inline bool getRequiredParam(const ros::NodeHandle& nh, std::string name, T& value);
AckermannToVesc::AckermannToVesc(ros::NodeHandle nh, ros::NodeHandle private_nh)
{
// get conversion parameters
- if (!getRequiredParam(nh, "speed_to_erpm_gain", &speed_to_erpm_gain_))
+ if (!getRequiredParam(nh, "speed_to_erpm_gain", speed_to_erpm_gain_))
return;
- if (!getRequiredParam(nh, "speed_to_erpm_offset", &speed_to_erpm_offset_))
+ if (!getRequiredParam(nh, "speed_to_erpm_offset", speed_to_erpm_offset_))
return;
- if (!getRequiredParam(nh, "accel_to_current_gain", &accel_to_current_gain_))
+ if (!getRequiredParam(nh, "steering_angle_to_servo_gain", steering_to_servo_gain_))
return;
- if (!getRequiredParam(nh, "accel_to_brake_gain", &accel_to_brake_gain_))
- return;
- if (!getRequiredParam(nh, "steering_angle_to_servo_gain", &steering_to_servo_gain_))
- return;
- if (!getRequiredParam(nh, "steering_angle_to_servo_offset", &steering_to_servo_offset_))
+ if (!getRequiredParam(nh, "steering_angle_to_servo_offset", steering_to_servo_offset_))
return;
// create publishers to vesc electric-RPM (speed) and servo commands
erpm_pub_ = nh.advertise("commands/motor/speed", 10);
- current_pub_ = nh.advertise("commands/motor/current", 10);
- brake_pub_ = nh.advertise("commands/motor/brake", 10);
servo_pub_ = nh.advertise("commands/servo/position", 10);
// subscribe to ackermann topic
@@ -72,22 +66,6 @@ void AckermannToVesc::ackermannCmdCallback(const AckermannMsgPtr& cmd)
std_msgs::Float64::Ptr erpm_msg(new std_msgs::Float64);
erpm_msg->data = speed_to_erpm_gain_ * cmd->drive.speed + speed_to_erpm_offset_;
- // calc vesc current/brake (acceleration)
- bool is_positive_accel = true;
- std_msgs::Float64::Ptr current_msg(new std_msgs::Float64);
- std_msgs::Float64::Ptr brake_msg(new std_msgs::Float64);
- current_msg->data = 0;
- brake_msg->data = 0;
- if (cmd->drive.acceleration < 0)
- {
- brake_msg->data = accel_to_brake_gain_ * cmd->drive.acceleration;
- is_positive_accel = false;
- }
- else
- {
- current_msg->data = accel_to_current_gain_ * cmd->drive.acceleration;
- }
-
// calc steering angle (servo)
std_msgs::Float64::Ptr servo_msg(new std_msgs::Float64);
servo_msg->data = steering_to_servo_gain_ * cmd->drive.steering_angle + steering_to_servo_offset_;
@@ -95,40 +73,15 @@ void AckermannToVesc::ackermannCmdCallback(const AckermannMsgPtr& cmd)
// publish
if (ros::ok())
{
- // The below code attempts to stick to the previous mode until a new message forces a mode switch.
- if (erpm_msg->data != 0 || previous_mode_speed_)
- {
- erpm_pub_.publish(erpm_msg);
- }
- else
- {
- if (is_positive_accel)
- {
- current_pub_.publish(current_msg);
- }
- else
- {
- brake_pub_.publish(brake_msg);
- }
- }
+ erpm_pub_.publish(erpm_msg);
servo_pub_.publish(servo_msg);
}
-
- // The lines below are to determine which mode we are in so we can hold until new messages force a switch.
- if (erpm_msg->data != 0)
- {
- previous_mode_speed_ = true;
- }
- else if (current_msg->data != 0 || brake_msg->data != 0)
- {
- previous_mode_speed_ = false;
- }
}
template
-inline bool getRequiredParam(const ros::NodeHandle& nh, const std::string& name, T* value)
+inline bool getRequiredParam(const ros::NodeHandle& nh, std::string name, T& value)
{
- if (nh.getParam(name, *value))
+ if (nh.getParam(name, value))
return true;
ROS_FATAL("AckermannToVesc: Parameter %s is required.", name.c_str());
diff --git a/vesc_ackermann/src/ackermann_to_vesc_nodelet.cpp b/vesc_ackermann/src/ackermann_to_vesc_nodelet.cpp
index 5b72582..2900faa 100644
--- a/vesc_ackermann/src/ackermann_to_vesc_nodelet.cpp
+++ b/vesc_ackermann/src/ackermann_to_vesc_nodelet.cpp
@@ -23,26 +23,28 @@
// 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
#include
#include
#include
-#include
-
#include "vesc_ackermann/ackermann_to_vesc.h"
namespace vesc_ackermann
{
-class AckermannToVescNodelet: public nodelet::Nodelet
+class AckermannToVescNodelet : public nodelet::Nodelet
{
public:
- AckermannToVescNodelet() {}
+ AckermannToVescNodelet()
+ {
+ }
private:
virtual void onInit(void);
- std::shared_ptr ackermann_to_vesc_;
+ boost::shared_ptr ackermann_to_vesc_;
+
}; // class AckermannToVescNodelet
void AckermannToVescNodelet::onInit()
diff --git a/vesc_ackermann/src/vesc_to_odom.cpp b/vesc_ackermann/src/vesc_to_odom.cpp
index cca7d11..ad5c63e 100644
--- a/vesc_ackermann/src/vesc_to_odom.cpp
+++ b/vesc_ackermann/src/vesc_to_odom.cpp
@@ -28,7 +28,6 @@
#include "vesc_ackermann/vesc_to_odom.h"
#include
-#include
#include
#include
@@ -37,27 +36,26 @@ namespace vesc_ackermann
{
template
-inline bool getRequiredParam(const ros::NodeHandle& nh, const std::string& name, T* value);
+inline bool getRequiredParam(const ros::NodeHandle& nh, std::string name, T& value);
-VescToOdom::VescToOdom(ros::NodeHandle nh, ros::NodeHandle private_nh) :
- odom_frame_("odom"), base_frame_("base_link"),
- use_servo_cmd_(true), publish_tf_(false), x_(0.0), y_(0.0), yaw_(0.0)
+VescToOdom::VescToOdom(ros::NodeHandle nh, ros::NodeHandle private_nh)
+ : odom_frame_("odom"), base_frame_("base_link"), use_servo_cmd_(true), publish_tf_(false), x_(0.0), y_(0.0), yaw_(0.0)
{
// get ROS parameters
private_nh.param("odom_frame", odom_frame_, odom_frame_);
private_nh.param("base_frame", base_frame_, base_frame_);
private_nh.param("use_servo_cmd_to_calc_angular_velocity", use_servo_cmd_, use_servo_cmd_);
- if (!getRequiredParam(nh, "speed_to_erpm_gain", &speed_to_erpm_gain_))
+ if (!getRequiredParam(nh, "speed_to_erpm_gain", speed_to_erpm_gain_))
return;
- if (!getRequiredParam(nh, "speed_to_erpm_offset", &speed_to_erpm_offset_))
+ if (!getRequiredParam(nh, "speed_to_erpm_offset", speed_to_erpm_offset_))
return;
if (use_servo_cmd_)
{
- if (!getRequiredParam(nh, "steering_angle_to_servo_gain", &steering_to_servo_gain_))
+ if (!getRequiredParam(nh, "steering_angle_to_servo_gain", steering_to_servo_gain_))
return;
- if (!getRequiredParam(nh, "steering_angle_to_servo_offset", &steering_to_servo_offset_))
+ if (!getRequiredParam(nh, "steering_angle_to_servo_offset", steering_to_servo_offset_))
return;
- if (!getRequiredParam(nh, "wheelbase", &wheelbase_))
+ if (!getRequiredParam(nh, "wheelbase", wheelbase_))
return;
}
private_nh.param("publish_tf", publish_tf_, publish_tf_);
@@ -75,8 +73,7 @@ VescToOdom::VescToOdom(ros::NodeHandle nh, ros::NodeHandle private_nh) :
vesc_state_sub_ = nh.subscribe("sensors/core", 10, &VescToOdom::vescStateCallback, this);
if (use_servo_cmd_)
{
- servo_sub_ = nh.subscribe("sensors/servo_position_command", 10,
- &VescToOdom::servoCmdCallback, this);
+ servo_sub_ = nh.subscribe("sensors/servo_position_command", 10, &VescToOdom::servoCmdCallback, this);
}
}
@@ -95,8 +92,7 @@ void VescToOdom::vescStateCallback(const vesc_msgs::VescStateStamped::ConstPtr&
double current_steering_angle(0.0), current_angular_velocity(0.0);
if (use_servo_cmd_)
{
- current_steering_angle =
- (last_servo_cmd_->data - steering_to_servo_offset_) / steering_to_servo_gain_;
+ current_steering_angle = (last_servo_cmd_->data - steering_to_servo_offset_) / steering_to_servo_gain_;
current_angular_velocity = current_speed * tan(current_steering_angle) / wheelbase_;
}
@@ -136,8 +132,8 @@ void VescToOdom::vescStateCallback(const vesc_msgs::VescStateStamped::ConstPtr&
// Position uncertainty
/** @todo Think about position uncertainty, perhaps get from parameters? */
- odom->pose.covariance[0] = 0.2; ///< x
- odom->pose.covariance[7] = 0.2; ///< y
+ odom->pose.covariance[0] = 0.2; ///< x
+ odom->pose.covariance[7] = 0.2; ///< y
odom->pose.covariance[35] = 0.4; ///< yaw
// Velocity ("in the coordinate frame given by the child_frame_id")
@@ -176,9 +172,9 @@ void VescToOdom::servoCmdCallback(const std_msgs::Float64::ConstPtr& servo)
}
template
-inline bool getRequiredParam(const ros::NodeHandle& nh, const std::string& name, T* value)
+inline bool getRequiredParam(const ros::NodeHandle& nh, std::string name, T& value)
{
- if (nh.getParam(name, *value))
+ if (nh.getParam(name, value))
return true;
ROS_FATAL("VescToOdom: Parameter %s is required.", name.c_str());
diff --git a/vesc_ackermann/src/vesc_to_odom_nodelet.cpp b/vesc_ackermann/src/vesc_to_odom_nodelet.cpp
index 5f21c85..9d0be7c 100644
--- a/vesc_ackermann/src/vesc_to_odom_nodelet.cpp
+++ b/vesc_ackermann/src/vesc_to_odom_nodelet.cpp
@@ -23,26 +23,28 @@
// 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
#include
#include
#include
-#include
-
#include "vesc_ackermann/vesc_to_odom.h"
namespace vesc_ackermann
{
-class VescToOdomNodelet: public nodelet::Nodelet
+class VescToOdomNodelet : public nodelet::Nodelet
{
public:
- VescToOdomNodelet() {}
+ VescToOdomNodelet()
+ {
+ }
private:
virtual void onInit(void);
- std::shared_ptr vesc_to_odom_;
+ boost::shared_ptr vesc_to_odom_;
+
}; // class VescToOdomNodelet
void VescToOdomNodelet::onInit()
diff --git a/vesc_driver/CHANGELOG.rst b/vesc_driver/CHANGELOG.rst
index 1b48d3e..c505185 100644
--- a/vesc_driver/CHANGELOG.rst
+++ b/vesc_driver/CHANGELOG.rst
@@ -9,7 +9,7 @@ Changelog for package vesc_driver
* Exclude crc.h from roslint.
* Replacing boost::crc with CRCPP.
* Replacing boost::begin, boost::end, and boost::distance with Standard Library equivalents.
-* Replacing boost::bind with Standard Library equivalent.
+* Replacing boost::bind with Standards Library equivalent.
* Replaing boost::noncopyable with C++ equivalent.
* Replacing boost::function with Standard Library version.
* Replacing Boost smart pointers with Standard Library equivalents.
diff --git a/vesc_driver/CMakeLists.txt b/vesc_driver/CMakeLists.txt
index 50221d3..2a8e97d 100644
--- a/vesc_driver/CMakeLists.txt
+++ b/vesc_driver/CMakeLists.txt
@@ -20,15 +20,17 @@ find_package(catkin REQUIRED COMPONENTS
serial
std_msgs
vesc_msgs
+ serial
)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS
- nodelet
- pluginlib
- std_msgs
- vesc_msgs serial
+ nodelet
+ pluginlib
+ std_msgs
+ vesc_msgs serial
+ CATKIN_DEPENDS nodelet pluginlib roscpp std_msgs vesc_msgs serial
)
###########
@@ -97,4 +99,4 @@ install(DIRECTORY launch/
if(CATKIN_ENABLE_TESTING)
roslint_add_test()
-endif()
+endif()
\ No newline at end of file
diff --git a/vesc_driver/include/vesc_driver/crc.h b/vesc_driver/include/vesc_driver/crc.h
deleted file mode 100644
index 68e322d..0000000
--- a/vesc_driver/include/vesc_driver/crc.h
+++ /dev/null
@@ -1,1705 +0,0 @@
-/**
- @file CRC.h
- @author Daniel Bahr
- @version 1.0.1.0
- @copyright
- @parblock
- CRC++
- Copyright (c) 2020, Daniel Bahr
- 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.
-
- * Neither the name of CRC++ nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- 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.
- @endparblock
-*/
-
-/*
- CRC++ can be configured by setting various #defines before #including this header file:
-
- #define crcpp_uint8 - Specifies the type used to store CRCs that have a width of 8 bits or less.
- This type is not used in CRC calculations. Defaults to ::std::uint8_t.
- #define crcpp_uint16 - Specifies the type used to store CRCs that have a width between 9 and 16 bits (inclusive).
- This type is not used in CRC calculations. Defaults to ::std::uint16_t.
- #define crcpp_uint32 - Specifies the type used to store CRCs that have a width between 17 and 32 bits (inclusive).
- This type is not used in CRC calculations. Defaults to ::std::uint32_t.
- #define crcpp_uint64 - Specifies the type used to store CRCs that have a width between 33 and 64 bits (inclusive).
- This type is not used in CRC calculations. Defaults to ::std::uint64_t.
- #define crcpp_size - This type is used for loop iteration and function signatures only. Defaults to ::std::size_t.
- #define CRCPP_USE_NAMESPACE - Define to place all CRC++ code within the ::CRCPP namespace.
- #define CRCPP_BRANCHLESS - Define to enable a branchless CRC implementation. The branchless implementation uses a single integer
- multiplication in the bit-by-bit calculation instead of a small conditional. The branchless implementation
- may be faster on processor architectures which support single-instruction integer multiplication.
- #define CRCPP_USE_CPP11 - Define to enables C++11 features (move semantics, constexpr, static_assert, etc.).
- #define CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - Define to include definitions for little-used CRCs.
-*/
-
-#ifndef VESC_DRIVER_CRC_H_
-#define VESC_DRIVER_CRC_H_
-
-#include // Includes CHAR_BIT
-#ifdef CRCPP_USE_CPP11
-#include // Includes ::std::size_t
-#include // Includes ::std::uint8_t, ::std::uint16_t, ::std::uint32_t, ::std::uint64_t
-#else
-#include // Includes size_t
-#include // Includes uint8_t, uint16_t, uint32_t, uint64_t
-#endif
-#include // Includes ::std::numeric_limits
-#include // Includes ::std::move
-
-#ifndef crcpp_uint8
-# ifdef CRCPP_USE_CPP11
- /// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions.
-# define crcpp_uint8 ::std::uint8_t
-# else
- /// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions.
-# define crcpp_uint8 uint8_t
-# endif
-#endif
-
-#ifndef crcpp_uint16
-# ifdef CRCPP_USE_CPP11
- /// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions.
-# define crcpp_uint16 ::std::uint16_t
-# else
- /// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions.
-# define crcpp_uint16 uint16_t
-# endif
-#endif
-
-#ifndef crcpp_uint32
-# ifdef CRCPP_USE_CPP11
- /// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions.
-# define crcpp_uint32 ::std::uint32_t
-# else
- /// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions.
-# define crcpp_uint32 uint32_t
-# endif
-#endif
-
-#ifndef crcpp_uint64
-# ifdef CRCPP_USE_CPP11
- /// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions.
-# define crcpp_uint64 ::std::uint64_t
-# else
- /// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions.
-# define crcpp_uint64 uint64_t
-# endif
-#endif
-
-#ifndef crcpp_size
-# ifdef CRCPP_USE_CPP11
- /// @brief Unsigned size definition, used for specifying data sizes.
-# define crcpp_size ::std::size_t
-# else
- /// @brief Unsigned size definition, used for specifying data sizes.
-# define crcpp_size size_t
-# endif
-#endif
-
-#ifdef CRCPP_USE_CPP11
- /// @brief Compile-time expression definition.
-# define crcpp_constexpr constexpr
-#else
- /// @brief Compile-time expression definition.
-# define crcpp_constexpr const
-#endif
-
-#ifdef CRCPP_USE_NAMESPACE
-namespace CRCPP
-{
-#endif
-
-/**
- @brief Static class for computing CRCs.
- @note This class supports computation of full and multi-part CRCs, using a bit-by-bit algorithm or a
- byte-by-byte lookup table. The CRCs are calculated using as many optimizations as is reasonable.
- If compiling with C++11, the constexpr keyword is used liberally so that many calculations are
- performed at compile-time instead of at runtime.
-*/
-class CRC
-{
-public:
- // Forward declaration
- template
- struct Table;
-
- /**
- @brief CRC parameters.
- */
- template
- struct Parameters
- {
- CRCType polynomial; ///< CRC polynomial
- CRCType initialValue; ///< Initial CRC value
- CRCType finalXOR; ///< Value to XOR with the final CRC
- bool reflectInput; ///< true to reflect all input bytes
- bool reflectOutput; ///< true to reflect the output CRC (reflection occurs before the final XOR)
-
- Table MakeTable() const;
- };
-
- /**
- @brief CRC lookup table. After construction, the CRC parameters are fixed.
- @note A CRC table can be used for multiple CRC calculations.
- */
- template
- struct Table
- {
- // Constructors are intentionally NOT marked explicit.
- Table(const Parameters & parameters);
-
-#ifdef CRCPP_USE_CPP11
- Table(Parameters && parameters);
-#endif
-
- const Parameters & GetParameters() const;
-
- const CRCType * GetTable() const;
-
- CRCType operator[](unsigned char index) const;
-
- private:
- void InitTable();
-
- Parameters parameters; ///< CRC parameters used to construct the table
- CRCType table[1 << CHAR_BIT]; ///< CRC lookup table
- };
-
- // The number of bits in CRCType must be at least as large as CRCWidth.
- // CRCType must be an unsigned integer type or a custom type with operator overloads.
- template
- static CRCType Calculate(const void * data, crcpp_size size, const Parameters & parameters);
-
- template
- static CRCType Calculate(const void * data, crcpp_size size, const Parameters & parameters, CRCType crc);
-
- template
- static CRCType Calculate(const void * data, crcpp_size size, const Table & lookupTable);
-
- template
- static CRCType Calculate(const void * data, crcpp_size size, const Table & lookupTable, CRCType crc);
-
- // Common CRCs up to 64 bits.
- // Note: Check values are the computed CRCs when given an ASCII input of "123456789" (without null terminator)
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
- static const Parameters< crcpp_uint8, 4> & CRC_4_ITU();
- static const Parameters< crcpp_uint8, 5> & CRC_5_EPC();
- static const Parameters< crcpp_uint8, 5> & CRC_5_ITU();
- static const Parameters< crcpp_uint8, 5> & CRC_5_USB();
- static const Parameters< crcpp_uint8, 6> & CRC_6_CDMA2000A();
- static const Parameters< crcpp_uint8, 6> & CRC_6_CDMA2000B();
- static const Parameters< crcpp_uint8, 6> & CRC_6_ITU();
- static const Parameters< crcpp_uint8, 7> & CRC_7();
-#endif
- static const Parameters< crcpp_uint8, 8> & CRC_8();
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
- static const Parameters< crcpp_uint8, 8> & CRC_8_EBU();
- static const Parameters< crcpp_uint8, 8> & CRC_8_MAXIM();
- static const Parameters< crcpp_uint8, 8> & CRC_8_WCDMA();
- static const Parameters & CRC_10();
- static const Parameters & CRC_10_CDMA2000();
- static const Parameters & CRC_11();
- static const Parameters & CRC_12_CDMA2000();
- static const Parameters & CRC_12_DECT();
- static const Parameters & CRC_12_UMTS();
- static const Parameters & CRC_13_BBC();
- static const Parameters & CRC_15();
- static const Parameters & CRC_15_MPT1327();
-#endif
- static const Parameters & CRC_16_ARC();
- static const Parameters & CRC_16_BUYPASS();
- static const Parameters & CRC_16_CCITTFALSE();
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
- static const Parameters & CRC_16_CDMA2000();
- static const Parameters & CRC_16_CMS();
- static const Parameters & CRC_16_DECTR();
- static const Parameters & CRC_16_DECTX();
- static const Parameters & CRC_16_DNP();
-#endif
- static const Parameters & CRC_16_GENIBUS();
- static const Parameters & CRC_16_KERMIT();
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
- static const Parameters & CRC_16_MAXIM();
- static const Parameters & CRC_16_MODBUS();
- static const Parameters & CRC_16_T10DIF();
- static const Parameters & CRC_16_USB();
-#endif
- static const Parameters & CRC_16_X25();
- static const Parameters & CRC_16_XMODEM();
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
- static const Parameters & CRC_17_CAN();
- static const Parameters & CRC_21_CAN();
- static const Parameters & CRC_24();
- static const Parameters & CRC_24_FLEXRAYA();
- static const Parameters & CRC_24_FLEXRAYB();
- static const Parameters & CRC_30();
-#endif
- static const Parameters & CRC_32();
- static const Parameters & CRC_32_BZIP2();
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
- static const Parameters & CRC_32_C();
-#endif
- static const Parameters & CRC_32_MPEG2();
- static const Parameters & CRC_32_POSIX();
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
- static const Parameters & CRC_32_Q();
- static const Parameters & CRC_40_GSM();
- static const Parameters & CRC_64();
-#endif
-
-#ifdef CRCPP_USE_CPP11
- CRC() = delete;
- CRC(const CRC & other) = delete;
- CRC & operator=(const CRC & other) = delete;
- CRC(CRC && other) = delete;
- CRC & operator=(CRC && other) = delete;
-#endif
-
-private:
-#ifndef CRCPP_USE_CPP11
- CRC();
- CRC(const CRC & other);
- CRC & operator=(const CRC & other);
-#endif
-
- template
- static IntegerType Reflect(IntegerType value, crcpp_uint16 numBits);
-
- template
- static CRCType Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput);
-
- template
- static CRCType UndoFinalize(CRCType remainder, CRCType finalXOR, bool reflectOutput);
-
- template
- static CRCType CalculateRemainder(const void * data, crcpp_size size, const Parameters & parameters, CRCType remainder);
-
- template
- static CRCType CalculateRemainder(const void * data, crcpp_size size, const Table & lookupTable, CRCType remainder);
-};
-
-/**
- @brief Returns a CRC lookup table construct using these CRC parameters.
- @note This function primarily exists to allow use of the auto keyword instead of instantiating
- a table directly, since template parameters are not inferred in constructors.
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC lookup table
-*/
-template
-inline CRC::Table CRC::Parameters::MakeTable() const
-{
- // This should take advantage of RVO and optimize out the copy.
- return CRC::Table(*this);
-}
-
-/**
- @brief Constructs a CRC table from a set of CRC parameters
- @param[in] params CRC parameters
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
-*/
-template
-inline CRC::Table::Table(const Parameters & params) :
- parameters(params)
-{
- InitTable();
-}
-
-#ifdef CRCPP_USE_CPP11
-/**
- @brief Constructs a CRC table from a set of CRC parameters
- @param[in] params CRC parameters
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
-*/
-template
-inline CRC::Table::Table(Parameters && params) :
- parameters(::std::move(params))
-{
- InitTable();
-}
-#endif
-
-/**
- @brief Gets the CRC parameters used to construct the CRC table
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC parameters
-*/
-template
-inline const CRC::Parameters & CRC::Table::GetParameters() const
-{
- return parameters;
-}
-
-/**
- @brief Gets the CRC table
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC table
-*/
-template
-inline const CRCType * CRC::Table::GetTable() const
-{
- return table;
-}
-
-/**
- @brief Gets an entry in the CRC table
- @param[in] index Index into the CRC table
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC table entry
-*/
-template
-inline CRCType CRC::Table::operator[](unsigned char index) const
-{
- return table[index];
-}
-
-/**
- @brief Initializes a CRC table.
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
-*/
-template
-inline void CRC::Table::InitTable()
-{
- // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth)
- static crcpp_constexpr CRCType BIT_MASK((CRCType(1) << (CRCWidth - CRCType(1))) |
- ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1)));
-
- // The conditional expression is used to avoid a -Wshift-count-overflow warning.
- static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ? static_cast(CHAR_BIT - CRCWidth) : 0);
-
- CRCType crc;
- unsigned char byte = 0;
-
- // Loop over each dividend (each possible number storable in an unsigned char)
- do
- {
- crc = CRC::CalculateRemainder(&byte, sizeof(byte), parameters, CRCType(0));
-
- // This mask might not be necessary; all unit tests pass with this line commented out,
- // but that might just be a coincidence based on the CRC parameters used for testing.
- // In any case, this is harmless to leave in and only adds a single machine instruction per loop iteration.
- crc &= BIT_MASK;
-
- if (!parameters.reflectInput && CRCWidth < CHAR_BIT)
- {
- // Undo the special operation at the end of the CalculateRemainder()
- // function for non-reflected CRCs < CHAR_BIT.
- crc = static_cast(crc << SHIFT);
- }
-
- table[byte] = crc;
- }
- while (++byte);
-}
-
-/**
- @brief Computes a CRC.
- @param[in] data Data over which CRC will be computed
- @param[in] size Size of the data
- @param[in] parameters CRC parameters
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC
-*/
-template
-inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Parameters & parameters)
-{
- CRCType remainder = CalculateRemainder(data, size, parameters, parameters.initialValue);
-
- // No need to mask the remainder here; the mask will be applied in the Finalize() function.
-
- return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
-}
-/**
- @brief Appends additional data to a previous CRC calculation.
- @note This function can be used to compute multi-part CRCs.
- @param[in] data Data over which CRC will be computed
- @param[in] size Size of the data
- @param[in] parameters CRC parameters
- @param[in] crc CRC from a previous calculation
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC
-*/
-template
-inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Parameters & parameters, CRCType crc)
-{
- CRCType remainder = UndoFinalize(crc, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
-
- remainder = CalculateRemainder(data, size, parameters, remainder);
-
- // No need to mask the remainder here; the mask will be applied in the Finalize() function.
-
- return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
-}
-
-/**
- @brief Computes a CRC via a lookup table.
- @param[in] data Data over which CRC will be computed
- @param[in] size Size of the data
- @param[in] lookupTable CRC lookup table
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC
-*/
-template
-inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Table & lookupTable)
-{
- const Parameters & parameters = lookupTable.GetParameters();
-
- CRCType remainder = CalculateRemainder(data, size, lookupTable, parameters.initialValue);
-
- // No need to mask the remainder here; the mask will be applied in the Finalize() function.
-
- return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
-}
-
-/**
- @brief Appends additional data to a previous CRC calculation using a lookup table.
- @note This function can be used to compute multi-part CRCs.
- @param[in] data Data over which CRC will be computed
- @param[in] size Size of the data
- @param[in] lookupTable CRC lookup table
- @param[in] crc CRC from a previous calculation
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC
-*/
-template
-inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Table & lookupTable, CRCType crc)
-{
- const Parameters & parameters = lookupTable.GetParameters();
-
- CRCType remainder = UndoFinalize(crc, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
-
- remainder = CalculateRemainder(data, size, lookupTable, remainder);
-
- // No need to mask the remainder here; the mask will be applied in the Finalize() function.
-
- return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
-}
-
-/**
- @brief Reflects (i.e. reverses the bits within) an integer value.
- @param[in] value Value to reflect
- @param[in] numBits Number of bits in the integer which will be reflected
- @tparam IntegerType Integer type of the value being reflected
- @return Reflected value
-*/
-template
-inline IntegerType CRC::Reflect(IntegerType value, crcpp_uint16 numBits)
-{
- IntegerType reversedValue(0);
-
- for (crcpp_uint16 i = 0; i < numBits; ++i)
- {
- reversedValue = static_cast((reversedValue << 1) | (value & 1));
- value = static_cast(value >> 1);
- }
-
- return reversedValue;
-}
-
-/**
- @brief Computes the final reflection and XOR of a CRC remainder.
- @param[in] remainder CRC remainder to reflect and XOR
- @param[in] finalXOR Final value to XOR with the remainder
- @param[in] reflectOutput true to reflect each byte of the remainder before the XOR
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return Final CRC
-*/
-template
-inline CRCType CRC::Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput)
-{
- // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth)
- static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
- ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
-
- if (reflectOutput)
- {
- remainder = Reflect(remainder, CRCWidth);
- }
-
- return (remainder ^ finalXOR) & BIT_MASK;
-}
-
-/**
- @brief Undoes the process of computing the final reflection and XOR of a CRC remainder.
- @note This function allows for computation of multi-part CRCs
- @note Calling UndoFinalize() followed by Finalize() (or vice versa) will always return the original remainder value:
-
- CRCType x = ...;
- CRCType y = Finalize(x, finalXOR, reflectOutput);
- CRCType z = UndoFinalize(y, finalXOR, reflectOutput);
- assert(x == z);
-
- @param[in] crc Reflected and XORed CRC
- @param[in] finalXOR Final value XORed with the remainder
- @param[in] reflectOutput true if the remainder is to be reflected
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return Un-finalized CRC remainder
-*/
-template
-inline CRCType CRC::UndoFinalize(CRCType crc, CRCType finalXOR, bool reflectOutput)
-{
- // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth)
- static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
- ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
-
- crc = (crc & BIT_MASK) ^ finalXOR;
-
- if (reflectOutput)
- {
- crc = Reflect(crc, CRCWidth);
- }
-
- return crc;
-}
-
-/**
- @brief Computes a CRC remainder.
- @param[in] data Data over which the remainder will be computed
- @param[in] size Size of the data
- @param[in] parameters CRC parameters
- @param[in] remainder Running CRC remainder. Can be an initial value or the result of a previous CRC remainder calculation.
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC remainder
-*/
-template
-inline CRCType CRC::CalculateRemainder(const void * data, crcpp_size size, const Parameters & parameters, CRCType remainder)
-{
-#ifdef CRCPP_USE_CPP11
- // This static_assert is put here because this function will always be compiled in no matter what
- // the template parameters are and whether or not a table lookup or bit-by-bit algorithm is used.
- static_assert(::std::numeric_limits::digits >= CRCWidth, "CRCType is too small to contain a CRC of width CRCWidth.");
-#else
- // Catching this compile-time error is very important. Sadly, the compiler error will be very cryptic, but it's
- // better than nothing.
- enum { static_assert_failed_CRCType_is_too_small_to_contain_a_CRC_of_width_CRCWidth = 1 / (::std::numeric_limits::digits >= CRCWidth ? 1 : 0) };
-#endif
-
- const unsigned char * current = reinterpret_cast(data);
-
- // Slightly different implementations based on the parameters. The current implementations try to eliminate as much
- // computation from the inner loop (looping over each bit) as possible.
- if (parameters.reflectInput)
- {
- CRCType polynomial = CRC::Reflect(parameters.polynomial, CRCWidth);
- while (size--)
- {
- remainder = static_cast(remainder ^ *current++);
-
- // An optimizing compiler might choose to unroll this loop.
- for (crcpp_size i = 0; i < CHAR_BIT; ++i)
- {
-#ifdef CRCPP_BRANCHLESS
- // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following:
- // if (remainder & 1)
- // remainder = (remainder >> 1) ^ polynomial;
- // else
- // remainder >>= 1;
- remainder = static_cast((remainder >> 1) ^ ((remainder & 1) * polynomial));
-#else
- remainder = static_cast((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
-#endif
- }
- }
- }
- else if (CRCWidth >= CHAR_BIT)
- {
- static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
-#ifndef CRCPP_BRANCHLESS
- static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
-#endif
- // The conditional expression is used to avoid a -Wshift-count-overflow warning.
- static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ? static_cast(CRCWidth - CHAR_BIT) : 0);
-
- while (size--)
- {
- remainder = static_cast(remainder ^ (static_cast(*current++) << SHIFT));
-
- // An optimizing compiler might choose to unroll this loop.
- for (crcpp_size i = 0; i < CHAR_BIT; ++i)
- {
-#ifdef CRCPP_BRANCHLESS
- // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following:
- // if (remainder & CRC_HIGHEST_BIT_MASK)
- // remainder = (remainder << 1) ^ parameters.polynomial;
- // else
- // remainder <<= 1;
- remainder = static_cast((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.polynomial));
-#else
- remainder = static_cast((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.polynomial) : (remainder << 1));
-#endif
- }
- }
- }
- else
- {
- static crcpp_constexpr CRCType CHAR_BIT_MINUS_ONE(CHAR_BIT - 1);
-#ifndef CRCPP_BRANCHLESS
- static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
-#endif
- // The conditional expression is used to avoid a -Wshift-count-overflow warning.
- static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ? static_cast(CHAR_BIT - CRCWidth) : 0);
-
- CRCType polynomial = static_cast(parameters.polynomial << SHIFT);
- remainder = static_cast(remainder << SHIFT);
-
- while (size--)
- {
- remainder = static_cast(remainder ^ *current++);
-
- // An optimizing compiler might choose to unroll this loop.
- for (crcpp_size i = 0; i < CHAR_BIT; ++i)
- {
-#ifdef CRCPP_BRANCHLESS
- // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following:
- // if (remainder & CHAR_BIT_HIGHEST_BIT_MASK)
- // remainder = (remainder << 1) ^ polynomial;
- // else
- // remainder <<= 1;
- remainder = static_cast((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
-#else
- remainder = static_cast((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
-#endif
- }
- }
-
- remainder = static_cast(remainder >> SHIFT);
- }
-
- return remainder;
-}
-
-/**
- @brief Computes a CRC remainder using lookup table.
- @param[in] data Data over which the remainder will be computed
- @param[in] size Size of the data
- @param[in] lookupTable CRC lookup table
- @param[in] remainder Running CRC remainder. Can be an initial value or the result of a previous CRC remainder calculation.
- @tparam CRCType Integer type for storing the CRC result
- @tparam CRCWidth Number of bits in the CRC
- @return CRC remainder
-*/
-template
-inline CRCType CRC::CalculateRemainder(const void * data, crcpp_size size, const Table & lookupTable, CRCType remainder)
-{
- const unsigned char * current = reinterpret_cast(data);
-
- if (lookupTable.GetParameters().reflectInput)
- {
- while (size--)
- {
-#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
- // Disable warning about data loss when doing (remainder >> CHAR_BIT) when
- // remainder is one byte long. The algorithm is still correct in this case,
- // though it's possible that one additional machine instruction will be executed.
-# pragma warning (push)
-# pragma warning (disable : 4333)
-#endif
- remainder = static_cast((remainder >> CHAR_BIT) ^ lookupTable[static_cast(remainder ^ *current++)]);
-#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
-# pragma warning (pop)
-#endif
- }
- }
- else if (CRCWidth >= CHAR_BIT)
- {
- // The conditional expression is used to avoid a -Wshift-count-overflow warning.
- static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ? static_cast(CRCWidth - CHAR_BIT) : 0);
-
- while (size--)
- {
- remainder = static_cast((remainder << CHAR_BIT) ^ lookupTable[static_cast((remainder >> SHIFT) ^ *current++)]);
- }
- }
- else
- {
- // The conditional expression is used to avoid a -Wshift-count-overflow warning.
- static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ? static_cast(CHAR_BIT - CRCWidth) : 0);
-
- remainder = static_cast(remainder << SHIFT);
-
- while (size--)
- {
- // Note: no need to mask here since remainder is guaranteed to fit in a single byte.
- remainder = lookupTable[static_cast(remainder ^ *current++)];
- }
-
- remainder = static_cast(remainder >> SHIFT);
- }
-
- return remainder;
-}
-
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-/**
- @brief Returns a set of parameters for CRC-4 ITU.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-4 ITU has the following parameters and check value:
- - polynomial = 0x3
- - initial value = 0x0
- - final XOR = 0x0
- - reflect input = true
- - reflect output = true
- - check value = 0x7
- @return CRC-4 ITU parameters
-*/
-inline const CRC::Parameters & CRC::CRC_4_ITU()
-{
- static const Parameters parameters = { 0x3, 0x0, 0x0, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-5 EPC.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-5 EPC has the following parameters and check value:
- - polynomial = 0x09
- - initial value = 0x09
- - final XOR = 0x00
- - reflect input = false
- - reflect output = false
- - check value = 0x00
- @return CRC-5 EPC parameters
-*/
-inline const CRC::Parameters & CRC::CRC_5_EPC()
-{
- static const Parameters parameters = { 0x09, 0x09, 0x00, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-5 ITU.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-5 ITU has the following parameters and check value:
- - polynomial = 0x15
- - initial value = 0x00
- - final XOR = 0x00
- - reflect input = true
- - reflect output = true
- - check value = 0x07
- @return CRC-5 ITU parameters
-*/
-inline const CRC::Parameters & CRC::CRC_5_ITU()
-{
- static const Parameters parameters = { 0x15, 0x00, 0x00, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-5 USB.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-5 USB has the following parameters and check value:
- - polynomial = 0x05
- - initial value = 0x1F
- - final XOR = 0x1F
- - reflect input = true
- - reflect output = true
- - check value = 0x19
- @return CRC-5 USB parameters
-*/
-inline const CRC::Parameters & CRC::CRC_5_USB()
-{
- static const Parameters parameters = { 0x05, 0x1F, 0x1F, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-6 CDMA2000-A.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-6 CDMA2000-A has the following parameters and check value:
- - polynomial = 0x27
- - initial value = 0x3F
- - final XOR = 0x00
- - reflect input = false
- - reflect output = false
- - check value = 0x0D
- @return CRC-6 CDMA2000-A parameters
-*/
-inline const CRC::Parameters & CRC::CRC_6_CDMA2000A()
-{
- static const Parameters parameters = { 0x27, 0x3F, 0x00, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-6 CDMA2000-B.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-6 CDMA2000-A has the following parameters and check value:
- - polynomial = 0x07
- - initial value = 0x3F
- - final XOR = 0x00
- - reflect input = false
- - reflect output = false
- - check value = 0x3B
- @return CRC-6 CDMA2000-B parameters
-*/
-inline const CRC::Parameters & CRC::CRC_6_CDMA2000B()
-{
- static const Parameters parameters = { 0x07, 0x3F, 0x00, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-6 ITU.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-6 ITU has the following parameters and check value:
- - polynomial = 0x03
- - initial value = 0x00
- - final XOR = 0x00
- - reflect input = true
- - reflect output = true
- - check value = 0x06
- @return CRC-6 ITU parameters
-*/
-inline const CRC::Parameters & CRC::CRC_6_ITU()
-{
- static const Parameters parameters = { 0x03, 0x00, 0x00, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-7 JEDEC.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-7 JEDEC has the following parameters and check value:
- - polynomial = 0x09
- - initial value = 0x00
- - final XOR = 0x00
- - reflect input = false
- - reflect output = false
- - check value = 0x75
- @return CRC-7 JEDEC parameters
-*/
-inline const CRC::Parameters & CRC::CRC_7()
-{
- static const Parameters parameters = { 0x09, 0x00, 0x00, false, false };
- return parameters;
-}
-#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-
-/**
- @brief Returns a set of parameters for CRC-8 SMBus.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-8 SMBus has the following parameters and check value:
- - polynomial = 0x07
- - initial value = 0x00
- - final XOR = 0x00
- - reflect input = false
- - reflect output = false
- - check value = 0xF4
- @return CRC-8 SMBus parameters
-*/
-inline const CRC::Parameters & CRC::CRC_8()
-{
- static const Parameters parameters = { 0x07, 0x00, 0x00, false, false };
- return parameters;
-}
-
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-/**
- @brief Returns a set of parameters for CRC-8 EBU (aka CRC-8 AES).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-8 EBU has the following parameters and check value:
- - polynomial = 0x1D
- - initial value = 0xFF
- - final XOR = 0x00
- - reflect input = true
- - reflect output = true
- - check value = 0x97
- @return CRC-8 EBU parameters
-*/
-inline const CRC::Parameters & CRC::CRC_8_EBU()
-{
- static const Parameters parameters = { 0x1D, 0xFF, 0x00, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-8 MAXIM (aka CRC-8 DOW-CRC).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-8 MAXIM has the following parameters and check value:
- - polynomial = 0x31
- - initial value = 0x00
- - final XOR = 0x00
- - reflect input = true
- - reflect output = true
- - check value = 0xA1
- @return CRC-8 MAXIM parameters
-*/
-inline const CRC::Parameters & CRC::CRC_8_MAXIM()
-{
- static const Parameters parameters = { 0x31, 0x00, 0x00, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-8 WCDMA.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-8 WCDMA has the following parameters and check value:
- - polynomial = 0x9B
- - initial value = 0x00
- - final XOR = 0x00
- - reflect input = true
- - reflect output = true
- - check value = 0x25
- @return CRC-8 WCDMA parameters
-*/
-inline const CRC::Parameters & CRC::CRC_8_WCDMA()
-{
- static const Parameters parameters = { 0x9B, 0x00, 0x00, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-10 ITU.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-10 ITU has the following parameters and check value:
- - polynomial = 0x233
- - initial value = 0x000
- - final XOR = 0x000
- - reflect input = false
- - reflect output = false
- - check value = 0x199
- @return CRC-10 ITU parameters
-*/
-inline const CRC::Parameters & CRC::CRC_10()
-{
- static const Parameters parameters = { 0x233, 0x000, 0x000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-10 CDMA2000.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-10 CDMA2000 has the following parameters and check value:
- - polynomial = 0x3D9
- - initial value = 0x3FF
- - final XOR = 0x000
- - reflect input = false
- - reflect output = false
- - check value = 0x233
- @return CRC-10 CDMA2000 parameters
-*/
-inline const CRC::Parameters & CRC::CRC_10_CDMA2000()
-{
- static const Parameters parameters = { 0x3D9, 0x3FF, 0x000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-11 FlexRay.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-11 FlexRay has the following parameters and check value:
- - polynomial = 0x385
- - initial value = 0x01A
- - final XOR = 0x000
- - reflect input = false
- - reflect output = false
- - check value = 0x5A3
- @return CRC-11 FlexRay parameters
-*/
-inline const CRC::Parameters & CRC::CRC_11()
-{
- static const Parameters parameters = { 0x385, 0x01A, 0x000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-12 CDMA2000.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-12 CDMA2000 has the following parameters and check value:
- - polynomial = 0xF13
- - initial value = 0xFFF
- - final XOR = 0x000
- - reflect input = false
- - reflect output = false
- - check value = 0xD4D
- @return CRC-12 CDMA2000 parameters
-*/
-inline const CRC::Parameters & CRC::CRC_12_CDMA2000()
-{
- static const Parameters parameters = { 0xF13, 0xFFF, 0x000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-12 DECT (aka CRC-12 X-CRC).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-12 DECT has the following parameters and check value:
- - polynomial = 0x80F
- - initial value = 0x000
- - final XOR = 0x000
- - reflect input = false
- - reflect output = false
- - check value = 0xF5B
- @return CRC-12 DECT parameters
-*/
-inline const CRC::Parameters & CRC::CRC_12_DECT()
-{
- static const Parameters parameters = { 0x80F, 0x000, 0x000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-12 UMTS (aka CRC-12 3GPP).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-12 UMTS has the following parameters and check value:
- - polynomial = 0x80F
- - initial value = 0x000
- - final XOR = 0x000
- - reflect input = false
- - reflect output = true
- - check value = 0xDAF
- @return CRC-12 UMTS parameters
-*/
-inline const CRC::Parameters & CRC::CRC_12_UMTS()
-{
- static const Parameters parameters = { 0x80F, 0x000, 0x000, false, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-13 BBC.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-13 BBC has the following parameters and check value:
- - polynomial = 0x1CF5
- - initial value = 0x0000
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0x04FA
- @return CRC-13 BBC parameters
-*/
-inline const CRC::Parameters & CRC::CRC_13_BBC()
-{
- static const Parameters parameters = { 0x1CF5, 0x0000, 0x0000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-15 CAN.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-15 CAN has the following parameters and check value:
- - polynomial = 0x4599
- - initial value = 0x0000
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0x059E
- @return CRC-15 CAN parameters
-*/
-inline const CRC::Parameters & CRC::CRC_15()
-{
- static const Parameters parameters = { 0x4599, 0x0000, 0x0000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-15 MPT1327.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-15 MPT1327 has the following parameters and check value:
- - polynomial = 0x6815
- - initial value = 0x0000
- - final XOR = 0x0001
- - reflect input = false
- - reflect output = false
- - check value = 0x2566
- @return CRC-15 MPT1327 parameters
-*/
-inline const CRC::Parameters & CRC::CRC_15_MPT1327()
-{
- static const Parameters parameters = { 0x6815, 0x0000, 0x0001, false, false };
- return parameters;
-}
-#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-
-/**
- @brief Returns a set of parameters for CRC-16 ARC (aka CRC-16 IBM, CRC-16 LHA).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 ARC has the following parameters and check value:
- - polynomial = 0x8005
- - initial value = 0x0000
- - final XOR = 0x0000
- - reflect input = true
- - reflect output = true
- - check value = 0xBB3D
- @return CRC-16 ARC parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_ARC()
-{
- static const Parameters parameters = { 0x8005, 0x0000, 0x0000, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 BUYPASS (aka CRC-16 VERIFONE, CRC-16 UMTS).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 BUYPASS has the following parameters and check value:
- - polynomial = 0x8005
- - initial value = 0x0000
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0xFEE8
- @return CRC-16 BUYPASS parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_BUYPASS()
-{
- static const Parameters parameters = { 0x8005, 0x0000, 0x0000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 CCITT FALSE.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 CCITT FALSE has the following parameters and check value:
- - polynomial = 0x1021
- - initial value = 0xFFFF
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0x29B1
- @return CRC-16 CCITT FALSE parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_CCITTFALSE()
-{
- static const Parameters parameters = { 0x1021, 0xFFFF, 0x0000, false, false };
- return parameters;
-}
-
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-/**
- @brief Returns a set of parameters for CRC-16 CDMA2000.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 CDMA2000 has the following parameters and check value:
- - polynomial = 0xC867
- - initial value = 0xFFFF
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0x4C06
- @return CRC-16 CDMA2000 parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_CDMA2000()
-{
- static const Parameters parameters = { 0xC867, 0xFFFF, 0x0000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 CMS.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 CMS has the following parameters and check value:
- - polynomial = 0x8005
- - initial value = 0xFFFF
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0xAEE7
- @return CRC-16 CMS parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_CMS()
-{
- static const Parameters parameters = { 0x8005, 0xFFFF, 0x0000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 DECT-R (aka CRC-16 R-CRC).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 DECT-R has the following parameters and check value:
- - polynomial = 0x0589
- - initial value = 0x0000
- - final XOR = 0x0001
- - reflect input = false
- - reflect output = false
- - check value = 0x007E
- @return CRC-16 DECT-R parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_DECTR()
-{
- static const Parameters parameters = { 0x0589, 0x0000, 0x0001, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 DECT-X (aka CRC-16 X-CRC).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 DECT-X has the following parameters and check value:
- - polynomial = 0x0589
- - initial value = 0x0000
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0x007F
- @return CRC-16 DECT-X parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_DECTX()
-{
- static const Parameters parameters = { 0x0589, 0x0000, 0x0000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 DNP.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 DNP has the following parameters and check value:
- - polynomial = 0x3D65
- - initial value = 0x0000
- - final XOR = 0xFFFF
- - reflect input = true
- - reflect output = true
- - check value = 0xEA82
- @return CRC-16 DNP parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_DNP()
-{
- static const Parameters parameters = { 0x3D65, 0x0000, 0xFFFF, true, true };
- return parameters;
-}
-#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-
-/**
- @brief Returns a set of parameters for CRC-16 GENIBUS (aka CRC-16 EPC, CRC-16 I-CODE, CRC-16 DARC).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 GENIBUS has the following parameters and check value:
- - polynomial = 0x1021
- - initial value = 0xFFFF
- - final XOR = 0xFFFF
- - reflect input = false
- - reflect output = false
- - check value = 0xD64E
- @return CRC-16 GENIBUS parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_GENIBUS()
-{
- static const Parameters parameters = { 0x1021, 0xFFFF, 0xFFFF, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 KERMIT (aka CRC-16 CCITT, CRC-16 CCITT-TRUE).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 KERMIT has the following parameters and check value:
- - polynomial = 0x1021
- - initial value = 0x0000
- - final XOR = 0x0000
- - reflect input = true
- - reflect output = true
- - check value = 0x2189
- @return CRC-16 KERMIT parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_KERMIT()
-{
- static const Parameters parameters = { 0x1021, 0x0000, 0x0000, true, true };
- return parameters;
-}
-
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-/**
- @brief Returns a set of parameters for CRC-16 MAXIM.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 MAXIM has the following parameters and check value:
- - polynomial = 0x8005
- - initial value = 0x0000
- - final XOR = 0xFFFF
- - reflect input = true
- - reflect output = true
- - check value = 0x44C2
- @return CRC-16 MAXIM parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_MAXIM()
-{
- static const Parameters parameters = { 0x8005, 0x0000, 0xFFFF, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 MODBUS.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 MODBUS has the following parameters and check value:
- - polynomial = 0x8005
- - initial value = 0xFFFF
- - final XOR = 0x0000
- - reflect input = true
- - reflect output = true
- - check value = 0x4B37
- @return CRC-16 MODBUS parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_MODBUS()
-{
- static const Parameters parameters = { 0x8005, 0xFFFF, 0x0000, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 T10-DIF.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 T10-DIF has the following parameters and check value:
- - polynomial = 0x8BB7
- - initial value = 0x0000
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0xD0DB
- @return CRC-16 T10-DIF parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_T10DIF()
-{
- static const Parameters parameters = { 0x8BB7, 0x0000, 0x0000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 USB.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 USB has the following parameters and check value:
- - polynomial = 0x8005
- - initial value = 0xFFFF
- - final XOR = 0xFFFF
- - reflect input = true
- - reflect output = true
- - check value = 0xB4C8
- @return CRC-16 USB parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_USB()
-{
- static const Parameters parameters = { 0x8005, 0xFFFF, 0xFFFF, true, true };
- return parameters;
-}
-
-#endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-
-/**
- @brief Returns a set of parameters for CRC-16 X-25 (aka CRC-16 IBM-SDLC, CRC-16 ISO-HDLC, CRC-16 B).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 X-25 has the following parameters and check value:
- - polynomial = 0x1021
- - initial value = 0xFFFF
- - final XOR = 0xFFFF
- - reflect input = true
- - reflect output = true
- - check value = 0x906E
- @return CRC-16 X-25 parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_X25()
-{
- static const Parameters parameters = { 0x1021, 0xFFFF, 0xFFFF, true, true };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-16 XMODEM (aka CRC-16 ZMODEM, CRC-16 ACORN, CRC-16 LTE).
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-16 XMODEM has the following parameters and check value:
- - polynomial = 0x1021
- - initial value = 0x0000
- - final XOR = 0x0000
- - reflect input = false
- - reflect output = false
- - check value = 0x31C3
- @return CRC-16 XMODEM parameters
-*/
-inline const CRC::Parameters & CRC::CRC_16_XMODEM()
-{
- static const Parameters parameters = { 0x1021, 0x0000, 0x0000, false, false };
- return parameters;
-}
-
-#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
-/**
- @brief Returns a set of parameters for CRC-17 CAN.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-17 CAN has the following parameters and check value:
- - polynomial = 0x1685B
- - initial value = 0x00000
- - final XOR = 0x00000
- - reflect input = false
- - reflect output = false
- - check value = 0x04F03
- @return CRC-17 CAN parameters
-*/
-inline const CRC::Parameters & CRC::CRC_17_CAN()
-{
- static const Parameters parameters = { 0x1685B, 0x00000, 0x00000, false, false };
- return parameters;
-}
-
-/**
- @brief Returns a set of parameters for CRC-21 CAN.
- @note The parameters are static and are delayed-constructed to reduce memory footprint.
- @note CRC-21 CAN has the following parameters and check value:
- - polynomial = 0x102899
- - initial value = 0x000000
- - final XOR = 0x000000
- - reflect input = false
- - reflect output = false
- - check value = 0x0ED841
- @return CRC-21 CAN parameters
-*/
-inline const CRC::Parameters & CRC::CRC_21_CAN()
-{
- static const Parameters