31 #include "ccec/CECFrame.hpp"
32 #include "ccec/Util.hpp"
39 CECFrame::CECFrame(
const uint8_t *buf,
size_t len) : len_() {
41 if (buf && len > 0) append(buf, len);
46 if (len == 0) len = MAX_LENGTH;
47 while(
start < len_ && len--) {
48 frame.append(at(
start));
54 void CECFrame::append(uint8_t
byte) {
55 if (len_ == MAX_LENGTH)
56 throw std::out_of_range(
"Frame grows beyond maximum");
60 void CECFrame::append(
const uint8_t *buf,
size_t len) {
61 for (
size_t i = 0; i < (len); i++) {
66 void CECFrame::append(
const CECFrame &frame) {
67 const uint8_t *buf = NULL;
69 frame.getBuffer(&buf, &len);
73 void CECFrame::reset(
void) {
77 void CECFrame::getBuffer(
const uint8_t **buf,
size_t *len)
const {
83 const uint8_t * CECFrame::getBuffer(
void)
const {
87 const uint8_t CECFrame::at(
size_t i)
const {
89 CCEC_LOG( LOG_DEBUG,
"Frame i=%d, len=%d\r\n", i, len_);
92 throw std::out_of_range(
"Frame reads beyond maximum");
98 uint8_t & CECFrame::operator[] (
size_t i) {
100 throw std::out_of_range(
"Frame access beyond maximum");
106 const size_t CECFrame::length(
void)
const {
110 void CECFrame::hexDump(
int level)
const {
112 CCEC_LOG( level,
"FRAME DUMP========================: \r\n");
113 for (
size_t i = 0; i < len_; i++) {
114 CCEC_LOG( level,
"%02X ", (
int) buf_[i]);
116 CCEC_LOG( level,
"\r\n================================== \r\n");