diff --git a/src/hwapi.cpp b/src/hwapi.cpp index 80ea312..afaa4c7 100755 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -1920,8 +1920,39 @@ void hwapi::prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, void hwapi::prn_sendQRdata(QByteArray *buf) const { - // maximal 150 alphanummeric bytes - buf->clear(); + // buf must be 256byte long + // printer can use maximal 150 alphanummeric bytes + // but we send 256byte for reserve + + //buf->clear(); + QByteArray dataPart1, dataPart2, dataPart3, dataPart4; + int bufLength=buf->length(); + int toFill=0; + + // make sure that input buffer is long enough because program crashes when reading too much! + if (bufLength<256) + { + toFill=256-bufLength; + //toFill+=2; // just some byte more to be sure + buf->append(toFill, 0); + } + dataPart1.clear(); + dataPart2.clear(); + dataPart3.clear(); + dataPart4.clear(); + dataPart4=buf->right(64); + buf->chop(64); + dataPart3=buf->right(64); + buf->chop(64); + dataPart2=buf->right(64); + buf->chop(64); + dataPart1=buf->right(64); + + longFDcmd_set(CMD2DC_STOR_QR_DATA, 0, 0, 64, &dataPart1); + longFDcmd_set(CMD2DC_STOR_QR_DATA, 0, 1, 64, &dataPart2); + longFDcmd_set(CMD2DC_STOR_QR_DATA, 0, 2, 64, &dataPart3); + longFDcmd_set(CMD2DC_STOR_QR_DATA, 0, 3, 64, &dataPart4); + } void hwapi::prn_printQRcode(void) const