void datareceiver::myexport1()
{
qint64 numBytes ;
qint64 i;
const int blockLength = 2944;
char buff[4096];
quint16 r;
if(port->bytesAvailable())
{
inscnt++;
numBytes = port->bytesAvailable();
if(numBytes%2 == 0)
numBytes = numBytes;
else
numBytes = numBytes-1;
if(numBytes > sizeof(buff))
numBytes = sizeof(buff);
i = port->read(buff,numBytes);
quint16 r;
//****************** Bit Wise Shift Left Logic and ORing of two Bytes *********************/
for (int i = 0; i < data.size(); i+=2)
{
// r = ((stfram.at(i) << 5) |(stfram.at(i+1)));
r = (((quint16) data.at(i) << 5) |(data.at(i+1)));
char *ptrR = (char*) &r;
result.append(ptrR[1]);
result.append(ptrR[0]);
}
oldat.append(result.toHex()); // QByteArray oldat,result,stfrm ;
//****************** Logic to search for First frame ID and save to db from there*********************/
if(datrow ==0)
{
pos = matcher.indexIn(oldat, pos);
datrow++;
}
for(np = pos; np<oldat.size(); np++)
{
stfram.append(oldat.at(np));
pos++;
}
//************************* Cheacking for the Start of Frame "03b702200000" if true then insert 2944 chars every row******************//
if((stfram.startsWith("03b702200000")))
{
qry.prepare("insert into Bulkdb (Time_Interval, ChannelData) values (?, ?)");
while ((stfram.length() > blockLength)) {
qry.bindValue(0, rcount++);
qry.bindValue(1, stfram.left(blockLength));
qry.exec();
stfram = stfram.mid(blockLength);
}
qDebug()<< stfram;
}
}
// QByteArray oldat,result,stfrm ; Do i have to clear all these containers everytime this function is called sir, i am not doing it right now , since the data is continuous these containers will have data appended into them till the program runs.
}
void datareceiver::myexport1()
{
qint64 numBytes ;
qint64 i;
const int blockLength = 2944;
char buff[4096];
QByteArray result;
quint16 r;
QString covdat;
if(port->bytesAvailable())
{
inscnt++;
numBytes = port->bytesAvailable();
if(numBytes%2 == 0)
numBytes = numBytes;
else
numBytes = numBytes-1;
if(numBytes > sizeof(buff))
numBytes = sizeof(buff);
i = port->read(buff,numBytes);
QByteArray data = (QByteArray::fromRawData(buff,numBytes)); // retreving data on RS232 terminal
quint16 r;
//****************** Bit Wise Shift Left Logic and ORing of two Bytes *********************/
for (int i = 0; i < data.size(); i+=2)
{
// r = ((stfram.at(i) << 5) |(stfram.at(i+1)));
r = (((quint16) data.at(i) << 5) |(data.at(i+1)));
char *ptrR = (char*) &r;
result.append(ptrR[1]);
result.append(ptrR[0]);
}
oldat.append(result.toHex()); // QByteArray oldat,result,stfrm ;
//****************** Logic to search for First frame ID and save to db from there*********************/
if(datrow ==0)
{
QByteArray pattern("03b702200000");
QByteArrayMatcher matcher(pattern);
pos = matcher.indexIn(oldat, pos);
datrow++;
}
for(np = pos; np<oldat.size(); np++)
{
stfram.append(oldat.at(np));
pos++;
}
//************************* Cheacking for the Start of Frame "03b702200000" if true then insert 2944 chars every row******************//
if((stfram.startsWith("03b702200000")))
{
QSqlQuery qry;
qry.prepare("insert into Bulkdb (Time_Interval, ChannelData) values (?, ?)");
while ((stfram.length() > blockLength)) {
qry.bindValue(0, rcount++);
qry.bindValue(1, stfram.left(blockLength));
qry.exec();
stfram = stfram.mid(blockLength);
}
qDebug()<< stfram;
}
}
// QByteArray oldat,result,stfrm ; Do i have to clear all these containers everytime this function is called sir, i am not doing it right now , since the data is continuous these containers will have data appended into them till the program runs.
}
To copy to clipboard, switch view to plain text mode
Is this a timer syncronization problem or am i not clearing the QByteArray Containers properly..
Bookmarks