5 bool hex2dec(uint8_t& d,
const char& h) {
6 if (
'0' <= h && h <=
'9')
8 else if (
'a' <= h && h <=
'f')
10 else if (
'A' <= h && h <=
'F')
18 bool hex2buffer(std::string& out,
const std::string& in_raw,
bool pad) {
19 std::string in(in_raw);
20 if ((in.size() % 2) != 0) {
26 out.resize(in.size() >> 1);
27 for (
size_t i = 0; i < out.size(); ++i) {
32 out[i] = (hi << 4) | lo;
37 bool dec2hex(
char& h,
const uint8_t& d,
bool lc) {
40 }
else if (d < 16 && lc) {
42 }
else if (d < 16 && !lc) {
51 std::string
byte2hex(
const uint8_t& d,
bool pad,
bool lc) {
66 s.reserve(in.size() * 2);
67 for (
size_t i = 0; i < in.size(); ++i) {
68 std::string b =
byte2hex(in[i],
true, lc);
80 std::stringstream buf;
83 buf << std::nouppercase;
85 buf << std::uppercase;
91 uint32_t
tohex(
const std::string& s) {
93 std::stringstream stream;
94 stream << std::hex << s;
100 unsigned int h =
tohex(s);
108 for (uint8_t i = 0; i < f.
dlc; ++i) {
115 size_t sep = s.find(
'#');
116 if (sep == std::string::npos)
123 if (buffer.size() > 8)
126 for (
size_t i = 0; i < buffer.size(); ++i) {
127 frame.data[i] = buffer[i];
129 frame.dlc = buffer.size();
136 size_t delim = s.find_first_of(
":~-_");
142 if(delim != std::string::npos) {
144 second =
tohex(s.substr(delim +1));
146 uint32_t first =
toheader(s.substr(0, delim));
166 return tofilter<std::string>(s);
bool dec2hex(char &h, const uint8_t &d, bool lc)
std::string tostring(const Header &h, bool lc)
FrameFilterSharedPtr tofilter(const T &ct)
bool hex2dec(uint8_t &d, const char &h)
Header toheader(const std::string &s)
std::ostream & operator<<(std::ostream &stream, const can::Header &h)
std::string buffer2hex(const std::string &in, bool lc)
boost::array< value_type, 8 > data
array for 8 data bytes with bounds checking
Frame toframe(const std::string &s)
std::string byte2hex(const uint8_t &d, bool pad, bool lc)
uint32_t tohex(const std::string &s)
boost::shared_ptr< FrameFilter > FrameFilterSharedPtr
static const uint32_t MASK_RELAXED
bool hex2buffer(std::string &out, const std::string &in_raw, bool pad)
unsigned char dlc
len of data