mirror of
https://github.com/Indy970/QtHPConnect
synced 2025-01-30 20:34:35 +01:00
Added Content Window
This commit is contained in:
parent
f51dc60335
commit
d6d25e71be
11 changed files with 160 additions and 109 deletions
|
@ -17,7 +17,18 @@ TEMPLATE = app
|
||||||
# deprecated API in order to know how to port your code away from it.
|
# deprecated API in order to know how to port your code away from it.
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
DEFINES += "VERSION=0"
|
VERSION_MAJOR = HP_MAJOR_VERSION
|
||||||
|
VERSION_MINOR = HP_MINOR_VERSION
|
||||||
|
VERSION_PATCH = HP_MINOR_PATCH
|
||||||
|
VERSION_BUILD = HP_MINOR_BUILD
|
||||||
|
|
||||||
|
DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\
|
||||||
|
"VERSION_MINOR=$$VERSION_MINOR"\
|
||||||
|
"VERSION_PATCH=$$VERSION_PATCH"\
|
||||||
|
"VERSION_BUILD=$$VERSION_BUILD"
|
||||||
|
|
||||||
|
#Target version
|
||||||
|
VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_PATCH}$${VERSION_BUILD}
|
||||||
|
|
||||||
#QMAKE_CFLAGS += -Wno-unused-parameter -Werror=shadow -Werror=write-strings -Werror=redundant-decls -Werror=format -Werror=format-nonliteral -Werror=date-time -Werror=missing-prototypes -Werror=pointer-arith -Wunreachable-code -Werror=format-security -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=return-type -D_FORTIFY_SOURCE=2 -D__LINUX__ -fvisibility=hidden
|
#QMAKE_CFLAGS += -Wno-unused-parameter -Werror=shadow -Werror=write-strings -Werror=redundant-decls -Werror=format -Werror=format-nonliteral -Werror=date-time -Werror=missing-prototypes -Werror=pointer-arith -Wunreachable-code -Werror=format-security -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=return-type -D_FORTIFY_SOURCE=2 -D__LINUX__ -fvisibility=hidden
|
||||||
#QMAKE_CXXFLAGS += -include cctype -include cstdlib
|
#QMAKE_CXXFLAGS += -include cctype -include cstdlib
|
||||||
|
@ -102,8 +113,8 @@ HEADERS += \
|
||||||
hp_infodialog.h \
|
hp_infodialog.h \
|
||||||
getnumber.h \
|
getnumber.h \
|
||||||
hpusb.h \
|
hpusb.h \
|
||||||
hp_settingsdlg.h
|
hp_settingsdlg.h \
|
||||||
|
version.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
|
|
7
TODO.md
7
TODO.md
|
@ -1,8 +1,13 @@
|
||||||
17/02/2019
|
|
||||||
1 GUI
|
1 GUI
|
||||||
About
|
About
|
||||||
|
Content - fix icons
|
||||||
|
Content - fix columns
|
||||||
|
Content - fix resizing
|
||||||
|
Create storage path if it does not exist
|
||||||
Load and read program files
|
Load and read program files
|
||||||
Load Screen shot and display
|
Load Screen shot and display
|
||||||
|
Add options - set default paths
|
||||||
2 Comms
|
2 Comms
|
||||||
Understand what the calc is doing!
|
Understand what the calc is doing!
|
||||||
3 Backup to disk
|
3 Backup to disk
|
||||||
|
|
5
global.h
5
global.h
|
@ -1,11 +1,14 @@
|
||||||
#ifndef GLOBAL_H
|
#ifndef GLOBAL_H
|
||||||
#define GLOBAL_H
|
#define GLOBAL_H
|
||||||
#include <errorhandler.h>
|
#include "version.h"
|
||||||
|
#include "errorhandler.h"
|
||||||
|
|
||||||
|
|
||||||
class errorHandler;
|
class errorHandler;
|
||||||
extern errorHandler *main_err;
|
extern errorHandler *main_err;
|
||||||
#define log(a) main_err->error(L7,0,QString(a),QString());
|
#define log(a) main_err->error(L7,0,QString(a),QString());
|
||||||
#define err(a,b,c) main_err->error(a,b,QString(c),QString());
|
#define err(a,b,c) main_err->error(a,b,QString(c),QString());
|
||||||
|
|
||||||
|
|
||||||
#endif // GLOBAL_H
|
#endif // GLOBAL_H
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ void hpCalcData::readScreen() {
|
||||||
hp_Settings hpset;
|
hp_Settings hpset;
|
||||||
|
|
||||||
log("Reading Screen");
|
log("Reading Screen");
|
||||||
qDebug()<<"Reading Screen";
|
|
||||||
api=getAPI();
|
api=getAPI();
|
||||||
handle=getHandle();
|
handle=getHandle();
|
||||||
|
|
||||||
|
@ -123,11 +123,9 @@ void hpCalcData::readScreen() {
|
||||||
if (screenShot!=nullptr) {
|
if (screenShot!=nullptr) {
|
||||||
delete screenShot;
|
delete screenShot;
|
||||||
}
|
}
|
||||||
qDebug()<<"New ScreenShot";
|
|
||||||
screenShot = new QPixmap();
|
screenShot = new QPixmap();
|
||||||
|
|
||||||
qDebug()<<"Loading data";
|
|
||||||
qDebug()<<imageData[1];
|
|
||||||
screenShot->loadFromData(imageData);
|
screenShot->loadFromData(imageData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
115
hpusb.cpp
115
hpusb.cpp
|
@ -298,7 +298,6 @@ int hpusb::extract_header(uint8_t * raw, usb_header * uh) {
|
||||||
b_9=raw[9];
|
b_9=raw[9];
|
||||||
b_10=raw[10];
|
b_10=raw[10];
|
||||||
|
|
||||||
|
|
||||||
qDebug()<<QString("Extract Header");
|
qDebug()<<QString("Extract Header");
|
||||||
b_0=raw[0];
|
b_0=raw[0];
|
||||||
|
|
||||||
|
@ -362,7 +361,7 @@ int hpusb::submit_sync_r_transfer(hp_Handle * handle, hp_pkt_in * pktin) {
|
||||||
int trans_c=0;
|
int trans_c=0;
|
||||||
int chunks;
|
int chunks;
|
||||||
uint8_t raw[1024];
|
uint8_t raw[1024];
|
||||||
|
QByteArray in_buffer(1024,0);
|
||||||
|
|
||||||
log("Recieve...");
|
log("Recieve...");
|
||||||
|
|
||||||
|
@ -377,11 +376,14 @@ int hpusb::submit_sync_r_transfer(hp_Handle * handle, hp_pkt_in * pktin) {
|
||||||
|
|
||||||
if (!devh)
|
if (!devh)
|
||||||
return -1;
|
return -1;
|
||||||
memset((void *)pktin->data, 0, sizeof(pktin->size));
|
|
||||||
ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,1024,&trans,5000);
|
ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,1024,&trans,5000);
|
||||||
|
|
||||||
extract_header(raw,&uh1);
|
extract_header(raw,&uh1);
|
||||||
memcpy(pktin->data,raw,trans);
|
|
||||||
|
in_buffer.insert(0,(const char *)raw,trans);
|
||||||
|
in_buffer.resize(trans);
|
||||||
|
|
||||||
qDebug()<<QString("Looking for %1 items: %2 bytes read").arg(uh1.items).arg(trans);
|
qDebug()<<QString("Looking for %1 items: %2 bytes read").arg(uh1.items).arg(trans);
|
||||||
|
|
||||||
if ((uh1.type==HP_HDR_FIRST)&&(uh1.items>0x00)) {
|
if ((uh1.type==HP_HDR_FIRST)&&(uh1.items>0x00)) {
|
||||||
|
@ -392,11 +394,31 @@ int hpusb::submit_sync_r_transfer(hp_Handle * handle, hp_pkt_in * pktin) {
|
||||||
//read additional chuncks
|
//read additional chuncks
|
||||||
ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,1024,&trans_c,5000);
|
ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,1024,&trans_c,5000);
|
||||||
extract_header(raw, &uh2);
|
extract_header(raw, &uh2);
|
||||||
qDebug()<<QString("Copying %1 bytes").arg(trans_c);
|
//check for empty packet
|
||||||
memcpy(&pktin->data[trans],raw,trans_c);
|
if (trans_c>0) {
|
||||||
|
qDebug()<<QString("Copying %1 bytes").arg(trans_c);
|
||||||
|
in_buffer.append((const char *)raw,trans_c);
|
||||||
|
qDebug()<<QString("another chunk read %1/%2").arg(chunks).arg(uh2.chunk);
|
||||||
|
trans+=trans_c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qDebug()<<QString("another chunk read %1/%2").arg(chunks).arg(uh2.chunk);
|
if ((uh1.type==HP_HDR_STD)&&(uh1.items>0x00)) {
|
||||||
trans+=trans_c;
|
qDebug()<<QString("First std chunk detected %1").arg(uh1.items);
|
||||||
|
|
||||||
|
for (chunks=1; chunks<uh1.items; chunks++) {
|
||||||
|
trans_c=0;
|
||||||
|
//read additional chuncks
|
||||||
|
ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,1024,&trans_c,5000);
|
||||||
|
extract_header(raw, &uh2);
|
||||||
|
//check for empty packet
|
||||||
|
if (trans_c>0) {
|
||||||
|
qDebug()<<QString("Copying %1 bytes").arg(trans_c);
|
||||||
|
in_buffer.append((const char *)raw,trans_c);
|
||||||
|
qDebug()<<QString("another chunk read %1/%2").arg(chunks).arg(uh2.chunk);
|
||||||
|
trans+=trans_c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,12 +433,12 @@ int hpusb::submit_sync_r_transfer(hp_Handle * handle, hp_pkt_in * pktin) {
|
||||||
//read additional chuncks
|
//read additional chuncks
|
||||||
ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,1024,&trans_c,5000);
|
ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,1024,&trans_c,5000);
|
||||||
extract_header(raw, &uh2);
|
extract_header(raw, &uh2);
|
||||||
if (trans_c>2) {
|
//check for empty packet
|
||||||
|
if (trans_c>0) {
|
||||||
qDebug()<<QString("PNG: Copying %1 bytes").arg(trans_c);
|
qDebug()<<QString("PNG: Copying %1 bytes").arg(trans_c);
|
||||||
//Assume first byte a chunck count
|
//Assume first byte a chunck count
|
||||||
memcpy(&pktin->data[trans],&raw[headerlen],trans_c-headerlen);
|
in_buffer.append((const char *)&raw[headerlen],trans_c-headerlen);
|
||||||
trans+=trans_c-headerlen;
|
trans+=trans_c-headerlen;
|
||||||
pktin->size=trans;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -427,17 +449,15 @@ int hpusb::submit_sync_r_transfer(hp_Handle * handle, hp_pkt_in * pktin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug()<<QString("%1: Recieved ").arg(__FUNCTION__)<<trans<<" bytes";
|
pktin->array=in_buffer;
|
||||||
log(QString().sprintf("read: %d\n", trans));
|
|
||||||
|
|
||||||
if (ret){
|
if (ret){
|
||||||
log(QString().sprintf("ERROR in interrupt read: %s\n", libusb_error_name(ret)));
|
log(QString().sprintf("ERROR in interrupt read: %s\n", libusb_error_name(ret)));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//printf("%d receive %d bytes from device: %s\n");
|
|
||||||
qDebug()<<QString("Exiting %1 ret %2").arg(__FUNCTION__).arg(ret);
|
qDebug()<<QString("Exiting %1 ret %2").arg(__FUNCTION__).arg(ret);
|
||||||
log(QString().sprintf("%d bytes received",trans));
|
log(QString().sprintf("%d bytes received",trans));
|
||||||
main_err-> dump(pktin->data,trans);
|
main_err-> dump((uint8_t *)pktin->array.constData(),trans);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -462,7 +482,6 @@ int hpusb::get_screen_shot(hp_Handle * handle, QByteArray * imageData) {
|
||||||
if (handle != NULL) {
|
if (handle != NULL) {
|
||||||
|
|
||||||
uint8_t transferbuffer[LEN_IN_BUFFER+8];
|
uint8_t transferbuffer[LEN_IN_BUFFER+8];
|
||||||
uint8_t in_buffer[LEN_IN_BUFFER*16];
|
|
||||||
hp_pkt_in pktin;
|
hp_pkt_in pktin;
|
||||||
hp_pkt_out pktout;
|
hp_pkt_out pktout;
|
||||||
|
|
||||||
|
@ -477,22 +496,19 @@ int hpusb::get_screen_shot(hp_Handle * handle, QByteArray * imageData) {
|
||||||
if (!(res=submit_sync_s_transfer(handle,&pktout))){
|
if (!(res=submit_sync_s_transfer(handle,&pktout))){
|
||||||
|
|
||||||
pktin.cmd= CMD_PRIME_RECV_SCREEN;
|
pktin.cmd= CMD_PRIME_RECV_SCREEN;
|
||||||
pktin.data=in_buffer;
|
|
||||||
|
|
||||||
pktin.size=sizeof(in_buffer);
|
|
||||||
log(QString("%1: Waiting for a reply").arg(__FUNCTION__));
|
log(QString("%1: Waiting for a reply").arg(__FUNCTION__));
|
||||||
|
|
||||||
if (!submit_sync_r_transfer(handle,&pktin)){
|
if (!submit_sync_r_transfer(handle,&pktin)){
|
||||||
log(QString("%1: Recieved a reply").arg(__FUNCTION__));
|
log(QString("%1: Recieved a reply").arg(__FUNCTION__));
|
||||||
//Trying to understand reply
|
//Trying to understand reply
|
||||||
int endpos;
|
int endpos;
|
||||||
QByteArray rd= QByteArray(reinterpret_cast<const char*>(pktin.data), pktin.size);
|
QByteArray rd = pktin.array;
|
||||||
endpos = rd.indexOf("IEND");
|
endpos = rd.indexOf("IEND");
|
||||||
qDebug()<<"End pos:"<<endpos;
|
qDebug()<<"End pos:"<<endpos;
|
||||||
*imageData = QByteArray(rd.mid(14,endpos+4-14));
|
*imageData = QByteArray(rd.mid(14,endpos+4-14));
|
||||||
// qDebug()<<*imageData;
|
// qDebug()<<*imageData;
|
||||||
log(QString().sprintf("%d bytes received",pktin.size));
|
log(QString().sprintf("%d bytes received",pktin.array.size()));
|
||||||
main_err-> dump((uint8_t *)imageData->data(),imageData->size());;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,14 +545,14 @@ int hpusb::is_ready(hp_Handle * handle) {
|
||||||
if (!(res=submit_sync_s_transfer(handle,&pktout))){
|
if (!(res=submit_sync_s_transfer(handle,&pktout))){
|
||||||
|
|
||||||
pktin.cmd= CMD_PRIME_CHECK_READY;
|
pktin.cmd= CMD_PRIME_CHECK_READY;
|
||||||
pktin.data=in_buffer;
|
// pktin.data=in_buffer;
|
||||||
pktin.size=1024;
|
// pktin.size=1024;
|
||||||
log(QString("%1: Waiting for a reply").arg(__FUNCTION__));
|
log(QString("%1: Waiting for a reply").arg(__FUNCTION__));
|
||||||
|
|
||||||
if (!submit_sync_r_transfer(handle,&pktin)){
|
if (!submit_sync_r_transfer(handle,&pktin)){
|
||||||
log(QString("%1: Recieved a reply").arg(__FUNCTION__));
|
log(QString("%1: Recieved a reply").arg(__FUNCTION__));
|
||||||
//Trying to understand reply
|
//Trying to understand reply
|
||||||
QByteArray rd= QByteArray(reinterpret_cast<const char*>(pktin.data), pktin.size);
|
// QByteArray rd= QByteArray(reinterpret_cast<const char*>(pktin.data), pktin.size);
|
||||||
// lookfordouble(rd,64);
|
// lookfordouble(rd,64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,7 +567,7 @@ int hpusb::is_ready(hp_Handle * handle) {
|
||||||
int hpusb::load_info(hp_Handle * handle, hp_Information * hpinfo) {
|
int hpusb::load_info(hp_Handle * handle, hp_Information * hpinfo) {
|
||||||
|
|
||||||
uint8_t transferbuffer[LEN_IN_BUFFER+8];
|
uint8_t transferbuffer[LEN_IN_BUFFER+8];
|
||||||
uint8_t in_buffer[LEN_IN_BUFFER+8];
|
// uint8_t in_buffer[LEN_IN_BUFFER+8];
|
||||||
|
|
||||||
hp_pkt_in pktin;
|
hp_pkt_in pktin;
|
||||||
hp_pkt_out pktout;
|
hp_pkt_out pktout;
|
||||||
|
@ -586,26 +602,22 @@ int hpusb::load_info(hp_Handle * handle, hp_Information * hpinfo) {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//recieve response
|
//recieve response
|
||||||
pktin.data=in_buffer;
|
|
||||||
pktin.size=sizeof(in_buffer);
|
|
||||||
// pktout.size=PRIME_RAW_HID_DATA_SIZE+16;
|
|
||||||
|
|
||||||
if(!submit_sync_r_transfer(handle,&pktin)) {
|
if(!submit_sync_r_transfer(handle,&pktin)) {
|
||||||
|
|
||||||
//unpack data
|
//unpack data
|
||||||
log("unpacking data");
|
log("unpacking data");
|
||||||
|
|
||||||
int ind=0;
|
int ind=0;
|
||||||
QTextCodec * codec = QTextCodec::codecForName("UTF-8");
|
QTextCodec * codec = QTextCodec::codecForName("UTF-8");
|
||||||
QByteArray rd= QByteArray(reinterpret_cast<const char*>(pktin.data), pktin.size);
|
QByteArray rd= pktin.array;
|
||||||
|
|
||||||
//find name
|
//find name
|
||||||
ind=rd.indexOf(QChar(0x6c),0)+1;
|
ind=rd.indexOf(QChar(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);
|
||||||
hpinfo->name=name;
|
hpinfo->name=name;
|
||||||
|
|
||||||
//find OS Version
|
//find OS Version
|
||||||
unsigned char searchstr[] = {0x80,0x20,0x80,0x01,0x62,0x01};
|
unsigned char searchstr[] = {0x80,0x20,0x80,0x01,0x62,0x01};
|
||||||
|
@ -631,13 +643,11 @@ int hpusb::load_info(hp_Handle * handle, hp_Information * hpinfo) {
|
||||||
ind+=16;
|
ind+=16;
|
||||||
str1 =rd.mid(ind,16);
|
str1 =rd.mid(ind,16);
|
||||||
|
|
||||||
// QByteArray db= QByteArray(reinterpret_cast<const double*>(&pktout.buffer[ind]), pktout.size-ind);
|
return 0;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("failed to read info from device");
|
log("failed to read info from device");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -673,7 +683,6 @@ int hpusb::get_settings(hp_Handle * handle, hp_Settings * set) {
|
||||||
hp_Settings inset;
|
hp_Settings inset;
|
||||||
|
|
||||||
uint8_t transferbuffer[LEN_IN_BUFFER+8];
|
uint8_t transferbuffer[LEN_IN_BUFFER+8];
|
||||||
uint8_t in_buffer[LEN_IN_BUFFER+8];
|
|
||||||
|
|
||||||
hp_pkt_in pktin;
|
hp_pkt_in pktin;
|
||||||
hp_pkt_out pktout;
|
hp_pkt_out pktout;
|
||||||
|
@ -684,9 +693,6 @@ int hpusb::get_settings(hp_Handle * handle, hp_Settings * set) {
|
||||||
pktout.data=transferbuffer;
|
pktout.data=transferbuffer;
|
||||||
pktout.size=1024;
|
pktout.size=1024;
|
||||||
|
|
||||||
pktin.data=in_buffer;
|
|
||||||
pktin.size=sizeof(in_buffer);
|
|
||||||
// pktout.size=PRIME_RAW_HID_DATA_SIZE+16;
|
|
||||||
if(!handle) {
|
if(!handle) {
|
||||||
err(L3,0,"Passed 0 handle");
|
err(L3,0,"Passed 0 handle");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -716,7 +722,6 @@ int hpusb::set_settings(hp_Handle * handle, hp_Settings set) {
|
||||||
int hpusb::vpkt_send_experiments(hp_Handle * handle, int cmd) {
|
int hpusb::vpkt_send_experiments(hp_Handle * handle, int cmd) {
|
||||||
|
|
||||||
uint8_t transferbuffer[LEN_IN_BUFFER*8 ];
|
uint8_t transferbuffer[LEN_IN_BUFFER*8 ];
|
||||||
uint8_t in_buffer[LEN_IN_BUFFER+8];
|
|
||||||
|
|
||||||
hp_pkt_in pktin;
|
hp_pkt_in pktin;
|
||||||
hp_pkt_out pktout;
|
hp_pkt_out pktout;
|
||||||
|
@ -790,10 +795,6 @@ int hpusb::vpkt_send_experiments(hp_Handle * handle, int cmd) {
|
||||||
pktout.data=transferbuffer;
|
pktout.data=transferbuffer;
|
||||||
pktout.size=1024;
|
pktout.size=1024;
|
||||||
|
|
||||||
pktin.data=in_buffer;
|
|
||||||
pktin.size=sizeof(in_buffer);
|
|
||||||
// pktout.size=PRIME_RAW_HID_DATA_SIZE+16;
|
|
||||||
|
|
||||||
submit_sync_s_transfer(handle,&pktout);
|
submit_sync_s_transfer(handle,&pktout);
|
||||||
|
|
||||||
submit_sync_r_transfer(handle,&pktin);
|
submit_sync_r_transfer(handle,&pktin);
|
||||||
|
@ -883,9 +884,9 @@ int hpusb::submit_async_transfer(hp_Handle * handle, hp_pkt_in * pktin, hp_pkt_o
|
||||||
|
|
||||||
//Filling
|
//Filling
|
||||||
//libusb_fill_interrupt_setup(in_buffer,LIBUSB_RECIPIENT_DEVICE ,LIBUSB_REQUEST_TYPE_STANDARD,0,0,16);
|
//libusb_fill_interrupt_setup(in_buffer,LIBUSB_RECIPIENT_DEVICE ,LIBUSB_REQUEST_TYPE_STANDARD,0,0,16);
|
||||||
libusb_fill_control_transfer( transfer_in, devh,
|
// libusb_fill_control_transfer( transfer_in, devh,
|
||||||
pktin->data, // Note: in_buffer is where input data written.
|
// pktin->data, // Note: in_buffer is where input data written.
|
||||||
cb_in, nullptr, 1000); // no user data
|
// cb_in, nullptr, 1000); // no user data
|
||||||
|
|
||||||
//take the initial time measurement
|
//take the initial time measurement
|
||||||
clock_gettime(CLOCK_REALTIME, &t1);
|
clock_gettime(CLOCK_REALTIME, &t1);
|
||||||
|
|
3
hpusb.h
3
hpusb.h
|
@ -81,13 +81,14 @@ struct hp_cmd {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hp_pkt_in {
|
struct hp_pkt_in {
|
||||||
uint8_t * data;
|
QByteArray array;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hp_pkt_out {
|
struct hp_pkt_out {
|
||||||
uint8_t * data;
|
uint8_t * data;
|
||||||
|
QByteArray array= QByteArray(1024,0);
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
};
|
};
|
||||||
|
|
10
main.cpp
10
main.cpp
|
@ -9,16 +9,16 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("QtProject");
|
QCoreApplication::setOrganizationName("");
|
||||||
QCoreApplication::setApplicationName("Linux HP Connect");
|
QCoreApplication::setApplicationName("Linux QtHP Connect");
|
||||||
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
|
QCoreApplication::setApplicationVersion(HP_VERSION_STRING);
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription(QCoreApplication::applicationName());
|
|
||||||
|
|
||||||
|
parser.setApplicationDescription(QCoreApplication::applicationName());
|
||||||
//REWORK
|
//REWORK
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addVersionOption();
|
parser.addVersionOption();
|
||||||
parser.addPositionalArgument("file", "The file to open.");
|
// parser.addPositionalArgument("file", "The file to open.");
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
|
@ -22,16 +22,17 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QtWidgets/QTableView>
|
#include <QtWidgets/QTableView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QInputDialog>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QFileIconProvider>
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
#include "hpusb.h"
|
#include "hpusb.h"
|
||||||
#include "datamodel.h"
|
#include "datamodel.h"
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
@ -42,7 +43,6 @@
|
||||||
#include "hpdata.h"
|
#include "hpdata.h"
|
||||||
#include "hp_mdivariableedit.h"
|
#include "hp_mdivariableedit.h"
|
||||||
#include "hp_mditexteditor.h"
|
#include "hp_mditexteditor.h"
|
||||||
#include <QInputDialog>
|
|
||||||
|
|
||||||
errorHandler *main_err;
|
errorHandler *main_err;
|
||||||
#define log(a) main_err->error(L7,0,QString(a),QString());
|
#define log(a) main_err->error(L7,0,QString(a),QString());
|
||||||
|
@ -52,10 +52,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
//setup
|
//setup
|
||||||
QCoreApplication::setOrganizationName("Private");
|
QCoreApplication::setOrganizationName("IRGP");
|
||||||
QCoreApplication::setOrganizationDomain("");
|
QCoreApplication::setOrganizationDomain("");
|
||||||
QCoreApplication::setApplicationName("Linux HP Prime Interface");
|
QCoreApplication::setApplicationName("Linux QtHPConnect");
|
||||||
QSettings appSettings;
|
QSettings appSettings("IRGP","QtHPconnect");
|
||||||
|
|
||||||
|
//Set config file location (default used)
|
||||||
|
// appSettings->setPath(QSettings::NativeFormat,QSettings::UserScope,"");
|
||||||
|
|
||||||
|
appSettings.setValue("contentPath",QDir::homePath()+"/.local/share/qthpconnect/contents/");
|
||||||
|
|
||||||
//error handler
|
//error handler
|
||||||
main_err = new errorHandler(this);
|
main_err = new errorHandler(this);
|
||||||
|
@ -77,6 +82,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
createActions();
|
createActions();
|
||||||
createLogWindow();
|
createLogWindow();
|
||||||
setTreeMenu();
|
setTreeMenu();
|
||||||
|
setContentWindow();
|
||||||
|
|
||||||
//setup trees
|
//setup trees
|
||||||
ui->tvCalculators->setModel(hpTreeModel);
|
ui->tvCalculators->setModel(hpTreeModel);
|
||||||
|
@ -302,10 +308,9 @@ void MainWindow::clickedCalculator(QModelIndex index) {
|
||||||
|
|
||||||
void MainWindow::about()
|
void MainWindow::about()
|
||||||
{
|
{
|
||||||
QMessageBox::about(this, tr("About Application"),
|
QMessageBox::about(this, tr("About QtHP Connect"),
|
||||||
tr("The <b>Application</b> example demonstrates how to "
|
QString("Version: ")+HP_VERSION_STRING);
|
||||||
"write modern GUI applications using Qt, with a menu bar, "
|
|
||||||
"toolbars, and a status bar."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dummy from examples -- edit
|
//Dummy from examples -- edit
|
||||||
|
@ -321,12 +326,33 @@ void MainWindow::createActions()
|
||||||
//show or hide content window
|
//show or hide content window
|
||||||
void MainWindow::showContent() {
|
void MainWindow::showContent() {
|
||||||
|
|
||||||
if (ui->dwContent_2->isVisible()) {
|
if (ui->dwContent->isVisible()) {
|
||||||
ui->dwContent_2->hide();
|
ui->dwContent->hide();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->dwContent_2->show();
|
ui->dwContent->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Setup the content window to show saved content
|
||||||
|
void MainWindow::setContentWindow() {
|
||||||
|
|
||||||
|
QSettings appSettings("IRGP","QtHPconnect");
|
||||||
|
QString path;
|
||||||
|
|
||||||
|
path=appSettings.value("contentPath").toString();
|
||||||
|
qDebug()<<"Content Path:"<<path;
|
||||||
|
|
||||||
|
contentModel.setRootPath(path);
|
||||||
|
contentModel.iconProvider()->setOptions(QFileIconProvider::DontUseCustomDirectoryIcons);
|
||||||
|
|
||||||
|
ui->tvContent->setModel(&contentModel);
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
const QModelIndex rootIndex = contentModel.index(QDir::cleanPath(path));
|
||||||
|
if (rootIndex.isValid()) {
|
||||||
|
ui->tvContent->setRootIndex(rootIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +402,6 @@ void MainWindow::dataChange(hp_Change hpchange) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HP_SCREEN: {
|
case HP_SCREEN: {
|
||||||
qDebug()<<"Reciebed screenshot changed";
|
|
||||||
if (hpchange.calc!=nullptr) {
|
if (hpchange.calc!=nullptr) {
|
||||||
hp_ScreenShot scrn;
|
hp_ScreenShot scrn;
|
||||||
scrn = hpchange.calc->getScreenShot();
|
scrn = hpchange.calc->getScreenShot();
|
||||||
|
@ -390,9 +415,7 @@ void MainWindow::dataChange(hp_Change hpchange) {
|
||||||
//Add screen shots to the message window
|
//Add screen shots to the message window
|
||||||
void MainWindow::monitorAddImage(hp_ScreenShot scrnshot) {
|
void MainWindow::monitorAddImage(hp_ScreenShot scrnshot) {
|
||||||
|
|
||||||
qDebug()<<"In Monitor Add Screen Shot";
|
QPixmap * pic;
|
||||||
|
|
||||||
QPixmap * pic;
|
|
||||||
int col;
|
int col;
|
||||||
int row;
|
int row;
|
||||||
int count;
|
int count;
|
||||||
|
@ -413,8 +436,8 @@ void MainWindow::monitorAddImage(hp_ScreenShot scrnshot) {
|
||||||
col=count%maxcol;
|
col=count%maxcol;
|
||||||
row=count/maxcol;
|
row=count/maxcol;
|
||||||
|
|
||||||
qDebug()<<"Row set"<<row;
|
// qDebug()<<"Row set"<<row;
|
||||||
qDebug()<<"Column set"<<col;
|
// qDebug()<<"Column set"<<col;
|
||||||
ui->wMonitorGrid->addWidget(label,row,col,Qt::AlignTop);
|
ui->wMonitorGrid->addWidget(label,row,col,Qt::AlignTop);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QMdiArea>
|
#include <QMdiArea>
|
||||||
#include <QMdiSubWindow>
|
#include <QMdiSubWindow>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QFileSystemModel>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "errorhandler.h"
|
#include "errorhandler.h"
|
||||||
|
@ -53,7 +54,7 @@ private slots:
|
||||||
void createLogWindow();
|
void createLogWindow();
|
||||||
void testFunction();
|
void testFunction();
|
||||||
treeModel * getTreeModel();
|
treeModel * getTreeModel();
|
||||||
void setTreeMenu();
|
|
||||||
void treeMenuAction(bool);
|
void treeMenuAction(bool);
|
||||||
void on_tvCalculators_customContextMenuRequested(const QPoint &pos);
|
void on_tvCalculators_customContextMenuRequested(const QPoint &pos);
|
||||||
|
|
||||||
|
@ -66,11 +67,14 @@ private:
|
||||||
hpusb * hpapi;
|
hpusb * hpapi;
|
||||||
QMdiSubWindow * msgWindow=0;
|
QMdiSubWindow * msgWindow=0;
|
||||||
hp_MdiWindow * logWindow=0;
|
hp_MdiWindow * logWindow=0;
|
||||||
|
QFileSystemModel contentModel;
|
||||||
QTextEdit * logEdit=0;
|
QTextEdit * logEdit=0;
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
void loadTextFile();
|
void loadTextFile();
|
||||||
void createTextWindow();
|
void createTextWindow();
|
||||||
QMdiArea * getMdi();
|
QMdiArea * getMdi();
|
||||||
|
void setContentWindow();
|
||||||
|
void setTreeMenu();
|
||||||
void monitorAddImage(hp_ScreenShot scrnshot);
|
void monitorAddImage(hp_ScreenShot scrnshot);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,8 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>272</width>
|
<width>524287</width>
|
||||||
<height>524287</height>
|
<height>524290</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="baseSize">
|
<property name="baseSize">
|
||||||
|
@ -188,13 +188,19 @@
|
||||||
<addaction name="actionTestSettings"/>
|
<addaction name="actionTestSettings"/>
|
||||||
<addaction name="actionTestScreen"/>
|
<addaction name="actionTestScreen"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDockWidget" name="dwContent_2">
|
<widget class="QDockWidget" name="dwContent">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>130</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>524287</width>
|
<width>524287</width>
|
||||||
|
@ -204,7 +210,7 @@
|
||||||
<attribute name="dockWidgetArea">
|
<attribute name="dockWidgetArea">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="wContent_2">
|
<widget class="QWidget" name="wContent">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -213,19 +219,7 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeWidget" name="twContent">
|
<widget class="QTreeView" name="tvContent"/>
|
||||||
<property name="columnCount">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<attribute name="headerVisible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>1</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
11
version.h
Normal file
11
version.h
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef VERSION_H
|
||||||
|
#define VERSION_H
|
||||||
|
|
||||||
|
#define HP_VERSION_MAJOR 0
|
||||||
|
#define HP_VERSION_MINOR 1
|
||||||
|
#define HP_VERSION_PATCH 0
|
||||||
|
#define HP_VERSION_BUILD ""
|
||||||
|
#define HP_VERSION_STRING QString("%1.%2.%3%4").arg(HP_VERSION_MAJOR).arg(HP_VERSION_MINOR).arg(HP_VERSION_PATCH).arg(HP_VERSION_BUILD)
|
||||||
|
|
||||||
|
|
||||||
|
#endif // VERSION_H
|
Loading…
Add table
Reference in a new issue