Successful label printing

This commit is contained in:
2023-09-24 18:08:18 +02:00
parent b940890268
commit 4b3247ef6d
4 changed files with 30 additions and 11 deletions

View File

@@ -22,7 +22,6 @@
#include <algorithm>
#include <spdlog/spdlog.h>
#include <chrono>
#include <cstdint>
#include <iostream>
#include <iterator>
@@ -141,7 +140,7 @@ bool P700Printer::printBitmap(const graphics::Bitmap<graphics::ALPHA8>& bitmap)
rastercmd[1] = 0x00; // size +1
rastercmd[2] = 0x00;
rastercmd[3] = 0x00; // size -1
for (unsigned int i = 0; i < 8; i++) {
for (unsigned int i = 0; i < bm.getWidth(); i++) {
auto bmcol = bm.getCol(i);
if (!bmcol) {
spdlog::error("Out of bounds bitmap access");
@@ -156,7 +155,9 @@ bool P700Printer::printBitmap(const graphics::Bitmap<graphics::ALPHA8>& bitmap)
buf[1] = col.size() + 1;
buf[3] = col.size() - 1;
send(buf);
if (!send(buf)) {
break;
};
}
send(commands["eject"]);
@@ -177,15 +178,24 @@ bool P700Printer::send(std::vector<uint8_t>& data) {
return false;
}
int tx = 0;
#ifndef DRYRUN
if (!mUsbHndl->bulkTransfer(0x02, data, nullptr, 0)) {
if (!mUsbHndl->bulkTransfer(0x02, data, &tx, 0)) {
spdlog::error("Error writing command to Printer: {}", mUsbHndl->getLastErrorString());
return false;
}
#else
tx = data.size();
spdlog::debug("USB raw data(len {}): {}", data.size(), spdlog::to_hex(data));
#endif
if (tx != static_cast<int>(data.size())) {
spdlog::error("Could not transfer all data via USB bulk transfer. Only send {} of {} bytes",
tx, data.size());
return false;
}
return true;
}