Correct camera message processing to not cause CPU usage peaks
This commit is contained in:
parent
4fa2790bbd
commit
309fd3021d
1 changed files with 5 additions and 4 deletions
|
|
@ -39,16 +39,17 @@ bool CameraMessageProcessor::process_data(const std::vector<std::uint8_t> &data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraMessageProcessor::process_commands() {
|
void CameraMessageProcessor::process_commands() {
|
||||||
while (true) {
|
while (buffer_.size() > 0) {
|
||||||
size_t size;
|
size_t size = 0;
|
||||||
for (size = 0; size < buffer_.size(); size++) {
|
while (size < buffer_.size()) {
|
||||||
if (buffer_.at(size) == 0x0)
|
if (buffer_.at(size) == 0x0)
|
||||||
break;
|
break;
|
||||||
|
size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string command;
|
std::string command;
|
||||||
command.insert(0, reinterpret_cast<const char*>(buffer_.data()), size);
|
command.insert(0, reinterpret_cast<const char*>(buffer_.data()), size);
|
||||||
buffer_.erase(buffer_.begin(), buffer_.begin() + size);
|
buffer_.erase(buffer_.begin(), buffer_.begin() + size + 1);
|
||||||
|
|
||||||
handle_command(command);
|
handle_command(command);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue