this is my first time asking a question so please have some patience with me.
I'm trying to read the content of a text file which is meant to be sent to a printer. In the middle of the characters that define how the label is printed there are control characters, STX, SOH, CR, LF. In my example, I will read the contents of the file and pass them to a data structure(array) in the memory, append some data to it and later send it to the printer directly, erasing the data in that structure.
The function that does this is the following:
void ClientThread::readFile2Structure(bool GoodOrBad)
{
int i = 0;
int j = 0;
// Clean structure
// here clean the structure
// According to the name comes from the arguments.
if(GoodOrBad == 1)
{
labelFile.setFileName(labelPathGood);
//qDebug() << "Fez o set filepath" << labelPathGood;
}
else if(GoodOrBad == 0)
{
labelFile.setFileName(labelPathBad);
//qDebug() << "Fez o set filepath" << labelPathBad;
}
if (!labelFile.open(QIODevice::ReadOnly))
{
qDebug() << "Unable to open label definition file PrinterGood.ini/PrinterBad.ini!";
return;
}
else
{
while (!labelFile.atEnd())
{
temporaryStructure[i] = labelFile.readLine();
i++;
}
// for debug purposes only!
qDebug() << "Structure";
for(j=0; j<=i; j++)
{
qDebug() << temporaryStructure[j];
}
}
}
The data structure has the following definition: QByteArray temporaryStructure[50];
The file to be sent is: STX f259 CRLF SOH D STX L CRLF STX L CRLF D11 CRLF PC CRLF SC CRLF H25 CRLF 1W1c66000004100202000016036 CRLF
The data in bold are the control characters.
In my console, when I execute the function above, all the control characters appear as small squares and CRLF does not even appear.
Why are these different control characters appearing as small squares and are these going to be modified with the copying to a QByteArray array?
I'm afraid that nothing comes out of the printer and I still haven't got one to test with, FreeSerialPort Monitor will be the way to see if everything is coming out right.
Thank you for your attention.