mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Driver: Add optional debug prints
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
#include "icsneo/communication/driver.h"
|
#include "icsneo/communication/driver.h"
|
||||||
|
|
||||||
|
//#define ICSNEO_DRIVER_DEBUG_PRINTS
|
||||||
|
#ifdef ICSNEO_DRIVER_DEBUG_PRINTS
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
bool Driver::read(std::vector<uint8_t>& bytes, size_t limit) {
|
bool Driver::read(std::vector<uint8_t>& bytes, size_t limit) {
|
||||||
@@ -35,6 +41,18 @@ bool Driver::readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds tim
|
|||||||
|
|
||||||
bytes.resize(actuallyRead);
|
bytes.resize(actuallyRead);
|
||||||
|
|
||||||
|
#ifdef ICSNEO_DRIVER_DEBUG_PRINTS
|
||||||
|
if(actuallyRead > 0) {
|
||||||
|
std::cout << "Read data: (" << actuallyRead << ')' << std::hex << std::endl;
|
||||||
|
for(int i = 0; i < actuallyRead; i += 16) {
|
||||||
|
for(int j = 0; j < std::min<int>(actuallyRead - i, 16); j++)
|
||||||
|
std::cout << std::setw(2) << std::setfill('0') << uint32_t(bytes[i+j]) << ' ';
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
std::cout << std::dec << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return actuallyRead > 0;
|
return actuallyRead > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user