Skip to content

Commit 90161f3

Browse files
committed
Choose proper name for frame buffer
1 parent 4b2a61d commit 90161f3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

components/victron/victron.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,18 @@ void VictronComponent::loop() {
137137
state_ = 0;
138138
// The checksum is used as end of frame indicator, checksum_ should now be 0
139139
publish_frame_();
140-
block_buffer_.clear();
140+
frame_buffer_.clear();
141141
checksum_ = 0;
142142
continue;
143143
}
144144
if (c == '\r' || c == '\n') {
145145
// a block/frame has up to 22 entries
146146
// transmission errors could garble the end of frame indicator, leading to excess buffer length
147-
if (block_buffer_.size() + label_.size() + value_.size() + 3 < MAX_BUF_SIZE) {
148-
block_buffer_.append(label_.c_str());
149-
block_buffer_.append("\t");
150-
block_buffer_.append(value_.c_str());
151-
block_buffer_.append("\r\n");
147+
if (frame_buffer_.size() + label_.size() + value_.size() + 3 < MAX_BUF_SIZE) {
148+
frame_buffer_.append(label_.c_str());
149+
frame_buffer_.append("\t");
150+
frame_buffer_.append(value_.c_str());
151+
frame_buffer_.append("\r\n");
152152
}
153153
state_ = 0;
154154
} else {
@@ -746,8 +746,8 @@ void VictronComponent::publish_frame_() {
746746

747747
size_t last = 0;
748748
size_t next = 0;
749-
while ((next = block_buffer_.find("\r\n", last)) != std::string::npos) {
750-
std::string item = block_buffer_.substr(last, next-last);
749+
while ((next = frame_buffer_.find("\r\n", last)) != std::string::npos) {
750+
std::string item = frame_buffer_.substr(last, next-last);
751751
last = next + 2;
752752
if (item.size() == 0) {
753753
continue;

components/victron/victron.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class VictronComponent : public uart::UARTDevice, public Component {
294294
u_int16_t checksum_{0};
295295
std::string label_;
296296
std::string value_;
297-
std::string block_buffer_;
297+
std::string frame_buffer_;
298298
uint32_t last_transmission_{0};
299299
uint32_t last_publish_{0};
300300
uint32_t throttle_{0};

0 commit comments

Comments
 (0)