Skip to content

Commit

Permalink
Add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Dec 7, 2023
1 parent 537891e commit d2f1202
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libraries/RPLidar/src/RPLidar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,18 @@ void RPLidar::_send_cmd(uint8_t cmd)
std::tuple<uint8_t, bool, uint8_t> RPLidar::_read_descriptor()
{
// Read descriptor packet
std::vector<uint8_t> descriptor(DESCRIPTOR_LEN);
std::vector<uint8_t> descriptor;
descriptor.reserve(DESCRIPTOR_LEN);
this->_serial->read(descriptor.data(), DESCRIPTOR_LEN);
spdlog::debug("Received descriptor: {}", spdlog::to_hex(descriptor));

if (descriptor.size() != DESCRIPTOR_LEN)
{
throw std::runtime_error("Descriptor length mismatch");
throw std::runtime_error(fmt::format("Descriptor length mismatch : {}", descriptor.size()));
}
else if (descriptor[0] != SYNC_BYTE || descriptor[1] != SYNC_BYTE2)
{
throw std::runtime_error("Incorrect descriptor starting bytes");
throw std::runtime_error(fmt::format("Incorrect descriptor starting bytes : {} | {}", descriptor[0], descriptor[1]));
}

bool isSingle = descriptor[5] == 0;
Expand Down

0 comments on commit d2f1202

Please sign in to comment.