Go to the documentation of this file.
6 bool hex2dec(uint8_t& d,
const char& h) {
7 if (
'0' <= h && h <=
'9')
9 else if (
'a' <= h && h <=
'f')
11 else if (
'A' <= h && h <=
'F')
19 bool hex2buffer(std::string& out,
const std::string& in_raw,
bool pad) {
20 std::string in(in_raw);
21 if ((in.size() % 2) != 0) {
27 out.resize(in.size() >> 1);
28 for (
size_t i = 0; i < out.size(); ++i) {
33 out[i] = (hi << 4) | lo;
38 bool dec2hex(
char& h,
const uint8_t& d,
bool lc) {
41 }
else if (d < 16 && lc) {
43 }
else if (d < 16 && !lc) {
52 std::string
byte2hex(
const uint8_t& d,
bool pad,
bool lc) {
67 s.reserve(in.size() * 2);
68 for (
size_t i = 0; i < in.size(); ++i) {
69 std::string b =
byte2hex(in[i],
true, lc);
81 std::stringstream buf;
84 buf << std::nouppercase;
86 buf << std::uppercase;
89 buf << std::setfill(
'0') << std::setw(8);
95 uint32_t
tohex(
const std::string& s) {
97 std::stringstream stream;
98 stream << std::hex << s;
104 unsigned int h =
tohex(s);
113 for (uint8_t i = 0; i < f.
dlc; ++i) {
120 size_t sep = s.find(
'#');
121 if (sep == std::string::npos)
128 if (buffer.size() > 8)
131 for (
size_t i = 0; i < buffer.size(); ++i) {
132 frame.
data[i] = buffer[i];
134 frame.
dlc = buffer.size();
141 size_t delim = s.find_first_of(
":~-_");
147 if(delim != std::string::npos) {
149 second =
tohex(s.substr(delim +1));
171 return tofilter<std::string>(s);
std::string tostring(const Header &h, bool lc)
static const uint32_t MASK_RELAXED
FrameFilterSharedPtr tofilter(const T &ct)
std::ostream & operator<<(std::ostream &stream, const Header &h)
unsigned char dlc
len of data
bool dec2hex(char &h, const uint8_t &d, bool lc)
std::string byte2hex(const uint8_t &d, bool pad, bool lc)
std::string buffer2hex(const std::string &in, bool lc)
std::array< value_type, 8 > data
array for 8 data bytes with bounds checking
Header toheader(const std::string &s)
std::shared_ptr< FrameFilter > FrameFilterSharedPtr
bool hex2dec(uint8_t &d, const char &h)
Frame toframe(const std::string &s)
uint32_t tohex(const std::string &s)
bool hex2buffer(std::string &out, const std::string &in_raw, bool pad)