diff --git a/ahbuartplugin/ahbuartplugin.cpp b/ahbuartplugin/ahbuartplugin.cpp --- a/ahbuartplugin/ahbuartplugin.cpp +++ b/ahbuartplugin/ahbuartplugin.cpp @@ -31,6 +31,7 @@ #include #include #include +#include ahbuartplugin::ahbuartplugin(QWidget *parent):socexplorerplugin(parent,false) { @@ -40,16 +41,11 @@ ahbuartplugin::ahbuartplugin(QWidget *pa this->setWidget((QWidget*)this->UI); QObject::connect(this,SIGNAL(activateSig(bool)),this->UI,SLOT(setConnected(bool))); QObject::connect(this->UI,SIGNAL(connectPortsig(QString,int)),this,SLOT(togglePort(QString,int))); -// this->pyObject = new ahbuartPywrapper(this); -// QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(open(QString,int)),this,SLOT(open(QString,int))); -// QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(close()),this,SLOT(close())); -// QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(ReadBytes(uint,uint)),this,SLOT(ReadBytes(uint,uint))); -// QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(WriteBytes(uint,QList)),this,SLOT(WriteBytes(uint,QList))); QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList())); QObject::connect(this,SIGNAL(addReadBytes(int)),this->UI,SLOT(addReadBytes(int))); QObject::connect(this,SIGNAL(addWritenBytes(int)),this->UI,SLOT(addWritenBytes(int))); this->portListcompleter = NULL; - this->scanDone = false; +// this->scanDone = false; updatePortList(); } @@ -61,6 +57,8 @@ ahbuartplugin::~ahbuartplugin() rs232close(this->port); this->port = (rs232port_t)NULL; } + SocExplorerSettings::setValue(this->instance(),"PORT",this->UI->portName(),SocExplorerSettings::Session); + SocExplorerSettings::setValue(this->instance(),"SPEED",this->UI->baudRate(),SocExplorerSettings::Session); this->UI->close(); this->UI->~ahbUartPluginUI(); } @@ -169,10 +167,10 @@ void ahbuartplugin::connectPort(QString this->Connected = true; SocExplorerEngine::message(this,QString("Connection success on ")+PortName,2); emit this->activate(true); - if(this->scanDone==false) + if(!socexplorerproxy::haveChild(this,"AMBA_PLUGIN")) { socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); - this->scanDone=true; +// this->scanDone=true; } this->UI->setSystemSpeed(this->detectSpeed()); break; @@ -297,7 +295,7 @@ unsigned int ahbuartplugin::Read(unsigne CMD[4] = (char)((address)&0xFF); SAFEWRITE(CMD,5,timeout,1000,return 0); timeout.restart(); - int avail=0; + unsigned int avail=0; do{ avail=rs232availablebytes(this->port); if(timeout.elapsed()>1000) @@ -357,7 +355,7 @@ unsigned int ahbuartplugin::Write(unsign QProgressBar* progress = NULL; if(count>128) progress = SocExplorerEngine::getProgressBar("Writing on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count); - int offset = 0; + unsigned int offset = 0; char* CMD= (char*)malloc((32*4)+5); writen=0; while(count>32) @@ -469,7 +467,7 @@ QVariantList ahbuartplugin::ReadBytes(un result.append(QVariant((int)(0x0FF&(data[i])))); } - for(int i=0;i<(count%4);i++) + for(unsigned int i=0;i<(count%4);i++) { result.append(QVariant((int)(0x0FF&(data[count/4]>>((3-i)*8))))); } @@ -499,7 +497,7 @@ int ahbuartplugin::detectSpeed() unsigned int scaler = 0,dsuVal1=0,dsuVal2=0; int speed=0; QElapsedTimer time; - if(dsuBaseAddress!=-1) + if((int)dsuBaseAddress!=-1) { time.start(); if( this->Read(&dsuVal1,1,dsuBaseAddress+0x08)==1) @@ -511,7 +509,7 @@ int ahbuartplugin::detectSpeed() return ((dsuVal2-dsuVal1)/el)*1000; } } - if(ahbUartBaseAddress!=-1) + if((int)ahbUartBaseAddress!=-1) { if( this->Read(&scaler,1,ahbUartBaseAddress+0x0C)==1) { @@ -525,10 +523,13 @@ int ahbuartplugin::detectSpeed() void ahbuartplugin::postInstantiationTrigger() { - if(this->scanDone && this->Connected) + if(this->Connected) { this->UI->setSystemSpeed(this->detectSpeed()); } + QString portName = SocExplorerSettings::value(this->instance(),"PORT",this->UI->portName(),SocExplorerSettings::Session).toString(); + int baudRate = SocExplorerSettings::value(this->instance(),"SPEED",this->UI->baudRate(),SocExplorerSettings::Session).toInt(); + this->UI->setconfig(portName,baudRate); } diff --git a/ahbuartplugin/ahbuartplugin.h b/ahbuartplugin/ahbuartplugin.h --- a/ahbuartplugin/ahbuartplugin.h +++ b/ahbuartplugin/ahbuartplugin.h @@ -85,7 +85,7 @@ signals: void addWritenBytes(int count); void addReadBytes(int count); private: - bool scanDone; +// bool scanDone; QProgressDialog* progress; QLayout * mainLayout; ahbUartPluginUI* UI; diff --git a/ahbuartplugin/ahbuartpluginui.cpp b/ahbuartplugin/ahbuartpluginui.cpp --- a/ahbuartplugin/ahbuartpluginui.cpp +++ b/ahbuartplugin/ahbuartpluginui.cpp @@ -109,6 +109,12 @@ int ahbUartPluginUI::baudRate() return ui->portSpeed->text().toInt(); } + QString ahbUartPluginUI::portName() +{ + return this->ui->PortName->text(); +} + + void ahbUartPluginUI::closeEvent(QCloseEvent *event) { event->accept(); diff --git a/ahbuartplugin/ahbuartpluginui.h b/ahbuartplugin/ahbuartpluginui.h --- a/ahbuartplugin/ahbuartpluginui.h +++ b/ahbuartplugin/ahbuartpluginui.h @@ -44,6 +44,7 @@ public: void closeEvent(QCloseEvent *event); void setCompleter(QCompleter* completer); int baudRate(); + QString portName(); public slots: void setConnected(bool connected); void connectPort();