Update to Qt6

This commit is contained in:
Ian Gebbie 2021-08-21 19:29:31 +02:00 committed by Ian Gebbie
parent e277b719da
commit 9536c97312
12 changed files with 149 additions and 97 deletions

View file

@ -108,6 +108,7 @@ private:
public: public:
List(QString, hp_DataType); List(QString, hp_DataType);
QByteArray getData() override; QByteArray getData() override;
bool getData(QDataStream &ds) override;
itemData getListItem(int); itemData getListItem(int);
void setListItem(int, itemData); void setListItem(int, itemData);
QString getItem(int); QString getItem(int);
@ -130,7 +131,7 @@ public:
void setItem(int, int, QString); void setItem(int, int, QString);
void setItem(int, int, QString, double); void setItem(int, int, QString, double);
// QByteArray getData() override; // QByteArray getData() override;
bool getData(QDataStream &ds); bool getData(QDataStream &ds) override;
m_Size getMatrixSize(); m_Size getMatrixSize();
int getMatrixRows(); int getMatrixRows();
int getMatrixColumns(); int getMatrixColumns();

View file

@ -97,7 +97,4 @@ const QString mimetypes[FUNC_NUM][2]={ {"Main","application/x-calc"},
QByteArray data; QByteArray data;
}; };
#endif // HP_TYPEDEF_H #endif // HP_TYPEDEF_H

View file

@ -25,6 +25,8 @@
struct itemData { struct itemData {
double dReal=0.0; double dReal=0.0;
double dImaginary=0.0; double dImaginary=0.0;
QByteArray buf_real[16];
QByteArray buf_imag[16];
QString sValue=QStringLiteral(""); QString sValue=QStringLiteral("");
}; };

View file

@ -16,7 +16,7 @@
*/ */
#include <QDebug> #include <QDebug>
#include <QTextCodec> //#include <QTextCodec>
#include <QtMath> #include <QtMath>
#include <QBuffer> #include <QBuffer>
#include <math.h> #include <math.h>
@ -146,8 +146,8 @@ QString value2Str(int sign, double m, double exp) {
QString complex2Str(QString real, QString imag) { QString complex2Str(QString real, QString imag) {
QString value; QString value;
if((imag[0]!="+")&&(imag[0]!="-")) { if((imag.at(0)!=u'+')&&(imag.at(0)!=u'-')) {
value = real+"+"+imag+"*i"; value = real+u'+'+imag+"*i";
} }
else else
{ {
@ -163,8 +163,9 @@ QString complex2Str(QString real, QString imag) {
return value; return value;
} }
//Parse 16byte real
itemData extract16(QByteArray item) { itemData extract16(QByteArray item) {
;
itemData listvalue; itemData listvalue;
QString msg; QString msg;
QString value=QStringLiteral(""); QString value=QStringLiteral("");
@ -290,7 +291,15 @@ return out;
} }
///Real to BCD ///Real to BCD List format
bool BCDL(QDataStream &ds, double real) {
qDebug()<<"BCD List from "<<real;
}
///Real to BCD for Matrix
bool BCD(QDataStream &ds, double real) { bool BCD(QDataStream &ds, double real) {
double base=0.0; double base=0.0;
@ -306,9 +315,6 @@ double exponent = floor(log10(F));
double mantissa = F/(pow(10,exponent)); double mantissa = F/(pow(10,exponent));
quint8 data[8]; quint8 data[8];
qDebug()<<"BCD from "<<real;
if(exponent < 0) if(exponent < 0)
exponent += 0x1000; exponent += 0x1000;
@ -348,12 +354,12 @@ qDebug()<<"BCD from "<<real;
// ds<<(quint8)num; // ds<<(quint8)num;
data[7-i]=(quint8)num; data[7-i]=(quint8)num;
qDebug()<<"i= "<<i<<": "<<hex<<num; // qDebug()<<"i= "<<i<<": "<<hex<<num;
} }
expn=(quint16)exponent; expn=(quint16)exponent;
//EXP is in binary //EXP is in binary
qDebug()<<hex<<expn; // qDebug()<<hex<<expn;
ds<<expn; ds<<expn;
for (i=2; i<8; i++) { for (i=2; i<8; i++) {
@ -741,9 +747,43 @@ List::List(QString name_in, hp_DataType type_in):
} }
QByteArray List::getData() { QByteArray List::getData() {
qDebug()<<"List::getData()";
return data; return data;
} }
//resturns a datastream of the datafile
bool List::getData(QDataStream &ds) {
qDebug()<<"List::getData(ds)";
int list,i;
itemData item;
list=getListSize();
ds<<(quint16)0xfffe; //?
ds<<(quint8)0x16; //?
ds<<(quint8)0x00; //?
ds<<(quint16)list; //Size
ds<<(quint16)0x0000; //?
for (i=0;i<list;i++)
{
item=getListItem(i);
}
return true;
}
//Look for list
//Format of header
// FE
// FF
// 16
// 00
// Size
// ??
void List::parseData() { void List::parseData() {
QByteArray a1; QByteArray a1;
@ -1053,17 +1093,17 @@ void Program::setProg(QString data_in) {
void Program::parseData() { void Program::parseData() {
QTextCodec * codec = QTextCodec::codecForName("ISO 8859-1"); //QTextCodec * codec = QTextCodec::codecForName("ISO 8859-1");
QByteArray a1; QByteArray a1;
a1=getData(); a1=getData();
text = codec->toUnicode(a1); //text = codec->toUnicode(a1);
text = a1;
return; return;
} }
void Program::parseData(QDataStream& in) { void Program::parseData(QDataStream& in) {
QTextCodec * codec = QTextCodec::codecForName("ISO 8859-1"); //QTextCodec * codec = QTextCodec::codecForName("ISO 8859-1");
QByteArrayMatcher matcher; QByteArrayMatcher matcher;
QByteArray search; QByteArray search;
QByteArray phrase; QByteArray phrase;
@ -1099,7 +1139,8 @@ void Program::parseData(QDataStream& in) {
ind=pos+10; ind=pos+10;
phrase=a1.mid(ind,16*3); phrase=a1.mid(ind,16*3);
//add array to catch variable list //add array to catch variable list
str=codec->toUnicode(phrase); //str=codec->toUnicode(phrase);
str = phrase;
errlog(QString("TD...%1 %2").arg(pos,0,16).arg(ind)); errlog(QString("TD...%1 %2").arg(pos,0,16).arg(ind));
main_err->dump((uint8_t *)phrase.data(),3*16); main_err->dump((uint8_t *)phrase.data(),3*16);
errlog(str); errlog(str);
@ -1118,8 +1159,8 @@ void Program::parseData(QDataStream& in) {
// a1=getData(); // a1=getData();
// qDebug()<<codec->toUnicode(a1); // qDebug()<<codec->toUnicode(a1);
setProg(codec->toUnicode(a1)); // setProg(codec->toUnicode(a1));
setProg(a1);
return; return;
} }
@ -1156,7 +1197,7 @@ void Notes::parseData() {
// quint16 len1,len2; // quint16 len1,len2;
int formatstart; int formatstart;
QTextCodec * codec = QTextCodec::codecForName("UTF-8"); //QTextCodec * codec = QTextCodec::codecForName("UTF-8");
QByteArray a1,a3; QByteArray a1,a3;
@ -1166,9 +1207,10 @@ void Notes::parseData() {
a3=a1.mid(formatstart,-1); a3=a1.mid(formatstart,-1);
a1=a1.mid(0,formatstart); a1=a1.mid(0,formatstart);
text = codec->toUnicode(a1); //text = codec->toUnicode(a1);
format = codec->toUnicode(a3); text = a1;
//format = codec->toUnicode(a3);
format=a3;
} }
void Notes::setNote(QString data_in) { void Notes::setNote(QString data_in) {

View file

@ -25,7 +25,7 @@
#include <hp_infodialog.h> #include <hp_infodialog.h>
#include <hp_mdivariableedit.h> #include <hp_mdivariableedit.h>
#include <QSettings> #include <QSettings>
#include <QTextCodec> //#include <QTextCodec>
#include <utility> #include <utility>
#define FILE_NUM 9 #define FILE_NUM 9

View file

@ -52,7 +52,7 @@ QVariant dataModel::data(const QModelIndex &index, int role) const
.arg(row + 1) .arg(row + 1)
.arg(col +1); .arg(col +1);
break; break;
case Qt::FontRole: /* case Qt::FontRole:
if (row == 0 && col == 0) //change font only for cell(0,0) if (row == 0 && col == 0) //change font only for cell(0,0)
{ {
QFont boldFont; QFont boldFont;
@ -81,7 +81,7 @@ QVariant dataModel::data(const QModelIndex &index, int role) const
{ {
return Qt::Checked; return Qt::Checked;
} }
} */ }
return QVariant(); return QVariant();
} }

View file

@ -18,6 +18,7 @@
#include "errorhandler.h" #include "errorhandler.h"
#include "mainwindow.h" #include "mainwindow.h"
#include <QTextStream>
errorHandler::errorHandler() errorHandler::errorHandler()
{ {
@ -59,7 +60,7 @@ int errorHandler::writeLog(QString lineToBeLogged)
QDateTime time(QDateTime::currentDateTime()); QDateTime time(QDateTime::currentDateTime());
QTextStream out(&fileLog); QTextStream out(&fileLog);
out << time.toString("yyyy/MM/dd hh:mm:ss") << " "<< lineToBeLogged << endl; out << time.toString("yyyy/MM/dd hh:mm:ss") << " "<< lineToBeLogged << Qt::endl;
fileLog.close(); fileLog.close();
@ -110,7 +111,7 @@ int errorHandler::dump(uint8_t * data, int size)
QString text = QString("Dump:\n"); QString text = QString("Dump:\n");
QString texta = QString("ASCII:\n"); QString texta = QString("ASCII:\n");
j=0; j=0;
text = text + QString().sprintf("%04d | ",0); text = text + QString().asprintf("%04d | ",0);
for (i=0; i< size; i++) for (i=0; i< size; i++)
{ {
text = text + QString(" %1 ").arg(QChar(data[i]).unicode(),2,16,QChar('0')); text = text + QString(" %1 ").arg(QChar(data[i]).unicode(),2,16,QChar('0'));
@ -118,7 +119,7 @@ int errorHandler::dump(uint8_t * data, int size)
if (j>15) { if (j>15) {
j=0; j=0;
text=text+"\n"; text=text+"\n";
text = text + QString().sprintf("%04d | ",i+1); text = text + QString().asprintf("%04d | ",i+1);
} }
texta = texta +" "+QChar(data[i]).unicode(); texta = texta +" "+QChar(data[i]).unicode();

View file

@ -46,7 +46,7 @@ void hp_SettingsDlg::setupSettings() {
ui->cb_font->setCurrentIndex(dlgset.font_size); ui->cb_font->setCurrentIndex(dlgset.font_size);
ui->cb_theme->setCurrentIndex(dlgset.theme); ui->cb_theme->setCurrentIndex(dlgset.theme);
ui->le_integer->setText(QString().sprintf("%d",dlgset.bits)); ui->le_integer->setText(QString().asprintf("%d",dlgset.bits));
if (dlgset.textbook) if (dlgset.textbook)
ui->ch_textbook->setCheckState(Qt::Checked); ui->ch_textbook->setCheckState(Qt::Checked);

View file

@ -169,7 +169,7 @@ void hpCalcData::readSettings() {
if (api) { if (api) {
if(handle) { if(handle) {
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle); qDebug()<<QString().asprintf("%s %p",__FUNCTION__,handle->usbhandle);
if (api) { if (api) {
api->get_settings(handle); api->get_settings(handle);
} }
@ -204,7 +204,7 @@ void hpCalcData::readScreen() {
if (api) { if (api) {
if(handle) { if(handle) {
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle); qDebug()<<QString().asprintf("%s %p",__FUNCTION__,handle->usbhandle);
if (api) { if (api) {
api->get_screen_shot(handle); api->get_screen_shot(handle);
// if (screenShot!=nullptr) { // if (screenShot!=nullptr) {
@ -398,7 +398,7 @@ void hpCalcData::readInfo() {
if (api) { if (api) {
if(handle) { if(handle) {
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle); qDebug()<<QString().asprintf("%s %p",__FUNCTION__,handle->usbhandle);
if (api) if (api)
api->load_info(handle); api->load_info(handle);
} }

View file

@ -9,7 +9,7 @@
// return 0 = success // return 0 = success
// return <> 0 = error // return <> 0 = error
#include <QTextCodec> // #include <QTextCodec>
#include <QObject> #include <QObject>
#include "global.h" #include "global.h"
@ -111,7 +111,7 @@ int hpusb::hp_init()
return ret; return ret;
} }
else else
err(L3,ret,QString(QString().sprintf("Could not open libusb: %d",ret))); err(L3,ret,QString(QString().asprintf("Could not open libusb: %d",ret)));
} }
return ret; return ret;
} }
@ -166,17 +166,17 @@ int hpusb::hp_open(hp_Handle * handle) {
//claim interface //claim interface
ret = libusb_kernel_driver_active ( handle->usbhandle, 0x0) ; ret = libusb_kernel_driver_active ( handle->usbhandle, 0x0) ;
if (ret==1) { if (ret==1) {
errlog(QString().sprintf("Keneral active")); errlog(QString().asprintf("Keneral active"));
ret = libusb_detach_kernel_driver( handle->usbhandle, 0x0) ; ret = libusb_detach_kernel_driver( handle->usbhandle, 0x0) ;
errlog(QString().sprintf("Keneral detach: %s\n", libusb_error_name(ret))); errlog(QString().asprintf("Keneral detach: %s\n", libusb_error_name(ret)));
if (ret!=0) { if (ret!=0) {
errlog(QString().sprintf("Keneral detach error: %s\n", libusb_error_name(ret))); errlog(QString().asprintf("Keneral detach error: %s\n", libusb_error_name(ret)));
goto endfunc; goto endfunc;
} }
} }
else else
if (ret!=0) { if (ret!=0) {
errlog(QString().sprintf("Kernal error %s\n", libusb_error_name(ret))); errlog(QString().asprintf("Kernal error %s\n", libusb_error_name(ret)));
goto endfunc; goto endfunc;
} }
@ -192,7 +192,7 @@ int hpusb::hp_open(hp_Handle * handle) {
ret = libusb_claim_interface(handle->usbhandle, 0x0); ret = libusb_claim_interface(handle->usbhandle, 0x0);
if (ret!=0) { if (ret!=0) {
errlog(QString().sprintf("Claim interface Error: %s\n", libusb_error_name(ret))); errlog(QString().asprintf("Claim interface Error: %s\n", libusb_error_name(ret)));
return -1; return -1;
} }
} }
@ -235,20 +235,20 @@ void hpusb::dumpDevice(libusb_device * device) {
if (device) { if (device) {
rc = libusb_get_device_descriptor(device, &desc); rc = libusb_get_device_descriptor(device, &desc);
if (!rc) { if (!rc) {
dump+=QString().sprintf("bLength: %d\n",(int)desc.bLength); dump+=QString().asprintf("bLength: %d\n",(int)desc.bLength);
dump+=QString().sprintf("bDescriptor Type: %d\n",(int)desc.bDescriptorType); dump+=QString().asprintf("bDescriptor Type: %d\n",(int)desc.bDescriptorType);
dump+=QString().sprintf("bcdUSB: %d\n",(int)desc.bcdUSB); dump+=QString().asprintf("bcdUSB: %d\n",(int)desc.bcdUSB);
dump+=QString().sprintf("bDeviceClass: %d\n",(int)desc.bDeviceClass); dump+=QString().asprintf("bDeviceClass: %d\n",(int)desc.bDeviceClass);
dump+=QString().sprintf("bDeviceSubClass: %d\n",(int)desc.bDeviceSubClass); dump+=QString().asprintf("bDeviceSubClass: %d\n",(int)desc.bDeviceSubClass);
dump+=QString().sprintf("bDeviceProtocal: %d\n",(int)desc.bDeviceProtocol); dump+=QString().asprintf("bDeviceProtocal: %d\n",(int)desc.bDeviceProtocol);
dump+=QString().sprintf("bMaxPacketSize0: %d\n",(int)desc.bMaxPacketSize0); dump+=QString().asprintf("bMaxPacketSize0: %d\n",(int)desc.bMaxPacketSize0);
dump+=QString().sprintf("idVendor: %X\n",(int)desc.idVendor); dump+=QString().asprintf("idVendor: %X\n",(int)desc.idVendor);
dump+=QString().sprintf("idProduct: %d\n",(int)desc.idProduct); dump+=QString().asprintf("idProduct: %d\n",(int)desc.idProduct);
dump+=QString().sprintf("bcdDevicel: %d\n",(int)desc.bcdDevice); dump+=QString().asprintf("bcdDevicel: %d\n",(int)desc.bcdDevice);
dump+=QString().sprintf("iManufacture: %i\n",desc.iManufacturer); dump+=QString().asprintf("iManufacture: %i\n",desc.iManufacturer);
dump+=QString().sprintf("iProduct: %i\n",desc.iProduct); dump+=QString().asprintf("iProduct: %i\n",desc.iProduct);
dump+=QString().sprintf("iSerialNumber: %i\n",desc.iSerialNumber); dump+=QString().asprintf("iSerialNumber: %i\n",desc.iSerialNumber);
dump+=QString().sprintf("bNumConfigurations: %d\n",desc.bNumConfigurations); dump+=QString().asprintf("bNumConfigurations: %d\n",desc.bNumConfigurations);
} }
} }
errlog(dump); errlog(dump);
@ -292,19 +292,19 @@ int hpusb::submit_sync_s_transfer(hp_Handle * handle, hp_pkt_out * pktout) {
} }
errlog("In sync send transfer"); errlog("In sync send transfer");
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle); qDebug()<<QString().asprintf("%s %p",__FUNCTION__,handle->usbhandle);
//write //write
errlog("Send.."); errlog("Send..");
ret = libusb_interrupt_transfer(devh, ENDPOINT_OUT, raw.data, raw.size, ret = libusb_interrupt_transfer(devh, ENDPOINT_OUT, raw.data, raw.size,
&trans,10000); &trans,10000);
if (ret) { if (ret) {
errlog(QString().sprintf("Write Error: %s\n", libusb_error_name(ret))); errlog(QString().asprintf("Write Error: %s\n", libusb_error_name(ret)));
r = 0; r = 0;
break; break;
} }
else { else {
errlog(QString().sprintf("Write bytes: %d\n", trans)); errlog(QString().asprintf("Write bytes: %d\n", trans));
} }
// Increment packet ID, which seems to be necessary for computer -> calc packets // Increment packet ID, which seems to be necessary for computer -> calc packets
pkt_id++; pkt_id++;
@ -331,10 +331,10 @@ int hpusb::submit_sync_s_transfer(hp_Handle * handle, hp_pkt_out * pktout) {
&trans,10000); &trans,10000);
if (ret) { if (ret) {
errlog(QString().sprintf("Write Error: %s\n", libusb_error_name(ret))); errlog(QString().asprintf("Write Error: %s\n", libusb_error_name(ret)));
} }
else { else {
errlog(QString().sprintf("Write bytes: %d\n", trans)); errlog(QString().asprintf("Write bytes: %d\n", trans));
} }
} }
@ -476,7 +476,7 @@ int hpusb::submit_sync_r_transfer(hp_Handle * handle, hp_pkt_in * pktin) {
libusb_device_handle * devh = handle->usbhandle; libusb_device_handle * devh = handle->usbhandle;
errlog("hpusb::submit_sync_r_transfer: Receive..."); errlog("hpusb::submit_sync_r_transfer: Receive...");
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle); qDebug()<<QString().asprintf("%s %p",__FUNCTION__,handle->usbhandle);
if (!handle) { if (!handle) {
errlog("Null handle"); errlog("Null handle");
@ -626,16 +626,17 @@ int hpusb::send_info(hp_pkt_in * pkt) {
errlog("Unpacking Data"); errlog("Unpacking Data");
int ind=0; int ind=0;
QTextCodec * codec = QTextCodec::codecForName("UTF-16LE"); // QTextCodec * codec = QTextCodec::codecForName("UTF-16LE");
QTextCodec * codec8 = QTextCodec::codecForName("UTF-8"); // QTextCodec * codec8 = QTextCodec::codecForName("UTF-8");
QByteArray rd= pkt->array; QByteArray rd= pkt->array;
//find name //find name
ind=rd.indexOf(QChar(0x6c),0)+1; ind=rd.indexOf(0x6c,0)+1;
QByteArray str1 =rd.mid(ind,64); QByteArray str1 =rd.mid(ind,64);
QString name; QString name;
name = codec->toUnicode(str1); //name = codec->toUnicode(str1);
name = str1;
hpinfo.name=name; hpinfo.name=name;
//unsigned char searchstr[] = {0x80,0x20,0x80,0x01,0x62}; //unsigned char searchstr[] = {0x80,0x20,0x80,0x01,0x62};
@ -666,7 +667,8 @@ int hpusb::send_info(hp_pkt_in * pkt) {
//end test //end test
qDebug()<<str1; qDebug()<<str1;
QString app; QString app;
app = codec8->toUnicode(str1); //app = codec8->toUnicode(str1);
app=str1;
hpinfo.appver=QString("v%1").arg(listnum[4]); hpinfo.appver=QString("v%1").arg(listnum[4]);
errlog(app); errlog(app);
@ -675,7 +677,8 @@ int hpusb::send_info(hp_pkt_in * pkt) {
str1 =rd.mid(ind,16); str1 =rd.mid(ind,16);
// qDebug()<<str1; // qDebug()<<str1;
QString osv; QString osv;
osv = codec8->toUnicode(str1); //osv = codec8->toUnicode(str1);
osv=str1;
hpinfo.osver=osv; hpinfo.osver=osv;
// qDebug()<<osv; // qDebug()<<osv;
errlog(osv); errlog(osv);
@ -684,7 +687,8 @@ int hpusb::send_info(hp_pkt_in * pkt) {
ind+=16; ind+=16;
str1 =rd.mid(ind,16); str1 =rd.mid(ind,16);
QString serial; QString serial;
serial = codec8->toUnicode(str1); //serial = codec8->toUnicode(str1);
serial=str1;
hpinfo.serialnum=serial; hpinfo.serialnum=serial;
errlog(serial); errlog(serial);
pkt->calc->recvInfo(hpinfo); pkt->calc->recvInfo(hpinfo);
@ -728,7 +732,7 @@ int hpusb::send_file(hp_pkt_in * pkt) {
qDebug()<<"hpusb::send_file: In File Processor"; qDebug()<<"hpusb::send_file: In File Processor";
QString filename; QString filename;
QTextCodec * codec = QTextCodec::codecForName("UTF-16LE"); //QTextCodec * codec = QTextCodec::codecForName("UTF-16LE");
QByteArray rd= pkt->array; QByteArray rd= pkt->array;
int len; int len;
qint8 crc; qint8 crc;
@ -751,7 +755,8 @@ int hpusb::send_file(hp_pkt_in * pkt) {
//find file name //find file name
QByteArray str1 =rd.mid(3,len); QByteArray str1 =rd.mid(3,len);
filename = codec->toUnicode(str1); //filename = codec->toUnicode(str1);
filename = str1;
errlog(QString("File: %1 Type: %2").arg(filename).arg(pkt->pkt_type)); errlog(QString("File: %1 Type: %2").arg(filename).arg(pkt->pkt_type));
qDebug()<<"hpusb:Checking file type"; qDebug()<<"hpusb:Checking file type";
@ -809,7 +814,8 @@ int hpusb::send_file(hp_pkt_in * pkt) {
qDebug()<<QString("%1 %2 %3").arg((uint8_t)rd[len],1,16).arg((uint8_t)rd[len+1],1,16).arg((uint8_t)rd[len+2],1,16); qDebug()<<QString("%1 %2 %3").arg((uint8_t)rd[len],1,16).arg((uint8_t)rd[len+1],1,16).arg((uint8_t)rd[len+2],1,16);
size=rd[len+1]; //Is the byte a size? size=rd[len+1]; //Is the byte a size?
QByteArray str1 =rd.mid(len+3,-1); QByteArray str1 =rd.mid(len+3,-1);
note.text = codec->toUnicode(str1); //note.text = codec->toUnicode(str1);
note.text=str1;
note.data=str1; note.data=str1;
pkt->calc->recvNote(note); pkt->calc->recvNote(note);
} }
@ -825,7 +831,8 @@ int hpusb::send_file(hp_pkt_in * pkt) {
size=rd[len+1]; size=rd[len+1];
QByteArray str1 =rd.mid(len+3,-1); QByteArray str1 =rd.mid(len+3,-1);
prog.data=str1; prog.data=str1;
prog.prog = codec->toUnicode(str1); //prog.prog = codec->toUnicode(str1);
prog.prog = str1;
pkt->calc->recvProg(prog); pkt->calc->recvProg(prog);
} }
break; break;
@ -984,8 +991,9 @@ int hpusb::lookfordouble (QByteArray rd, int start) {
long double num=0; long double num=0;
QString app; QString app;
QByteArray str1; QByteArray str1;
QTextCodec * codec = QTextCodec::codecForName("UTF-16"); //QTextCodec * codec = QTextCodec::codecForName("UTF-16");
app = codec->toUnicode(str1); //app = codec->toUnicode(str1);
app=str1;
errlog(app); errlog(app);
int i,ind; int i,ind;
@ -995,9 +1003,10 @@ int hpusb::lookfordouble (QByteArray rd, int start) {
ind+=1; ind+=1;
str1 =rd.mid(ind,sizeof(num)); str1 =rd.mid(ind,sizeof(num));
num= *(long double*)(str1.constData()); num= *(long double*)(str1.constData());
app = codec->toUnicode(str1); //app = codec->toUnicode(str1);
app =str1;
// qDebug()<<num; // qDebug()<<num;
qDebug()<<QString().sprintf("%e",num); qDebug()<<QString().asprintf("%e",num);
qDebug()<<app; qDebug()<<app;
} }
return 0; return 0;
@ -1164,17 +1173,17 @@ void hpusb::print_libusb_transfer(struct libusb_transfer *p_t)
} }
else { else {
errlog("libusb_transfer structure:\n"); errlog("libusb_transfer structure:\n");
errlog(QString().sprintf("flags =%x \n", p_t->flags)); errlog(QString().asprintf("flags =%x \n", p_t->flags));
errlog(QString().sprintf("endpoint=%x \n", p_t->endpoint)); errlog(QString().asprintf("endpoint=%x \n", p_t->endpoint));
errlog(QString().sprintf("type =%x \n", p_t->type)); errlog(QString().asprintf("type =%x \n", p_t->type));
errlog(QString().sprintf("timeout =%d \n", p_t->timeout)); errlog(QString().asprintf("timeout =%d \n", p_t->timeout));
// length, and buffer are commands sent to the device // length, and buffer are commands sent to the device
errlog(QString().sprintf("length =%d \n", p_t->length)); errlog(QString().asprintf("length =%d \n", p_t->length));
errlog(QString().sprintf("actual_length =%d \n", p_t->actual_length)); errlog(QString().asprintf("actual_length =%d \n", p_t->actual_length));
errlog(QString().sprintf("buffer =%p \n", p_t->buffer)); errlog(QString().asprintf("buffer =%p \n", p_t->buffer));
for (i=0; i < p_t->length; i++){ for (i=0; i < p_t->length; i++){
errlog(QString().sprintf("%d %x", i, p_t->buffer[i])); errlog(QString().asprintf("%d %x", i, p_t->buffer[i]));
} }
} }
return; return;
@ -1325,7 +1334,7 @@ void sighandler(int signum)
// - This is called after the Out transfer has been received by libusb // - This is called after the Out transfer has been received by libusb
void cb_out(struct libusb_transfer *transfer) { void cb_out(struct libusb_transfer *transfer) {
QString().sprintf("status =%d, actual_length=%d\n", QString().asprintf("status =%d, actual_length=%d\n",
transfer->status, transfer->actual_length); transfer->status, transfer->actual_length);
} }

View file

@ -161,7 +161,7 @@ MainWindow::MainWindow(QWidget *parent) :
errlog("Initialising...."); errlog("Initialising....");
if (hpapi->hp_init()) if (hpapi->hp_init())
err(L1,0,QString().sprintf("%s Failed to open libusb",__FUNCTION__)); err(L1,0,QString().asprintf("%s Failed to open libusb",__FUNCTION__));
//setup event handler //setup event handler
eventThread = new EventThread(this); eventThread = new EventThread(this);
@ -191,7 +191,7 @@ void MainWindow::testFunction() {
if (pH) { if (pH) {
cmd = QInputDialog::getInt(this,"Get Command","CMD:",0,0,0xFFFF); cmd = QInputDialog::getInt(this,"Get Command","CMD:",0,0,0xFFFF);
errlog("command is "+QString().sprintf("%x",cmd)); errlog("command is "+QString().asprintf("%x",cmd));
pH->vpkt_send_experiments(cmd); pH->vpkt_send_experiments(cmd);
} }
else else
@ -209,7 +209,7 @@ void MainWindow::testFunction2() {
QString out; QString out;
cmd = QInputDialog::getInt(this,"Get Command","CMD:",0,0,0xFFFF); cmd = QInputDialog::getInt(this,"Get Command","CMD:",0,0,0xFFFF);
out=I2BCDS(cmd); out=I2BCDS(cmd);
errlog("command is "+QString().sprintf("%x",cmd)); errlog("command is "+QString().asprintf("%x",cmd));
qDebug()<<out; qDebug()<<out;
} }

View file

@ -282,16 +282,16 @@ QVariant varTableModel::headerData(int section, Qt::Orientation orientation, in
bool varTableModel::getData(QDataStream &ds) { bool varTableModel::getData(QDataStream &ds) {
// QByteArray buf; QByteArray buf;
// buf.clear(); buf.clear();
// QDataStream ds_test(&buf, QIODevice::ReadWrite); QDataStream ds_test(&buf, QIODevice::ReadWrite);
// ds_test.setByteOrder(QDataStream::LittleEndian); ds_test.setByteOrder(QDataStream::LittleEndian);
if(dataobj!=nullptr) { if(dataobj!=nullptr) {
dataobj->getData(ds); // dataobj->getData(ds);
// dataobj->getData(ds_test); dataobj->getData(ds_test);
// qDebug()<<"VarTableModel::getData"; qDebug()<<"VarTableModel::getData";
// qDebug()<<"Out:"<<buf.toHex(); qDebug()<<"Out:"<<buf.toHex();
return true; return true;
} }