##// END OF EJS Templates
AHBUART plugin now saves data.
jeandet -
r66:a69da3403983 default
parent child
Show More
@@ -31,6 +31,7
31 31 #include <QStringList>
32 32 #include <QLineEdit>
33 33 #include <socexplorerproxy.h>
34 #include <socexplorersettings.h>
34 35
35 36 ahbuartplugin::ahbuartplugin(QWidget *parent):socexplorerplugin(parent,false)
36 37 {
@@ -40,16 +41,11 ahbuartplugin::ahbuartplugin(QWidget *pa
40 41 this->setWidget((QWidget*)this->UI);
41 42 QObject::connect(this,SIGNAL(activateSig(bool)),this->UI,SLOT(setConnected(bool)));
42 43 QObject::connect(this->UI,SIGNAL(connectPortsig(QString,int)),this,SLOT(togglePort(QString,int)));
43 // this->pyObject = new ahbuartPywrapper(this);
44 // QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(open(QString,int)),this,SLOT(open(QString,int)));
45 // QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(close()),this,SLOT(close()));
46 // QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(ReadBytes(uint,uint)),this,SLOT(ReadBytes(uint,uint)));
47 // QObject::connect(((ahbuartPywrapper*)this->pyObject),SIGNAL(WriteBytes(uint,QList<QVariant>)),this,SLOT(WriteBytes(uint,QList<QVariant>)));
48 44 QObject::connect(this->UI,SIGNAL(rescanPorts()),this,SLOT(updatePortList()));
49 45 QObject::connect(this,SIGNAL(addReadBytes(int)),this->UI,SLOT(addReadBytes(int)));
50 46 QObject::connect(this,SIGNAL(addWritenBytes(int)),this->UI,SLOT(addWritenBytes(int)));
51 47 this->portListcompleter = NULL;
52 this->scanDone = false;
48 // this->scanDone = false;
53 49 updatePortList();
54 50 }
55 51
@@ -61,6 +57,8 ahbuartplugin::~ahbuartplugin()
61 57 rs232close(this->port);
62 58 this->port = (rs232port_t)NULL;
63 59 }
60 SocExplorerSettings::setValue(this->instance(),"PORT",this->UI->portName(),SocExplorerSettings::Session);
61 SocExplorerSettings::setValue(this->instance(),"SPEED",this->UI->baudRate(),SocExplorerSettings::Session);
64 62 this->UI->close();
65 63 this->UI->~ahbUartPluginUI();
66 64 }
@@ -169,10 +167,10 void ahbuartplugin::connectPort(QString
169 167 this->Connected = true;
170 168 SocExplorerEngine::message(this,QString("Connection success on ")+PortName,2);
171 169 emit this->activate(true);
172 if(this->scanDone==false)
170 if(!socexplorerproxy::haveChild(this,"AMBA_PLUGIN"))
173 171 {
174 172 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
175 this->scanDone=true;
173 // this->scanDone=true;
176 174 }
177 175 this->UI->setSystemSpeed(this->detectSpeed());
178 176 break;
@@ -297,7 +295,7 unsigned int ahbuartplugin::Read(unsigne
297 295 CMD[4] = (char)((address)&0xFF);
298 296 SAFEWRITE(CMD,5,timeout,1000,return 0);
299 297 timeout.restart();
300 int avail=0;
298 unsigned int avail=0;
301 299 do{
302 300 avail=rs232availablebytes(this->port);
303 301 if(timeout.elapsed()>1000)
@@ -357,7 +355,7 unsigned int ahbuartplugin::Write(unsign
357 355 QProgressBar* progress = NULL;
358 356 if(count>128)
359 357 progress = SocExplorerEngine::getProgressBar("Writing on uart @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
360 int offset = 0;
358 unsigned int offset = 0;
361 359 char* CMD= (char*)malloc((32*4)+5);
362 360 writen=0;
363 361 while(count>32)
@@ -469,7 +467,7 QVariantList ahbuartplugin::ReadBytes(un
469 467 result.append(QVariant((int)(0x0FF&(data[i]))));
470 468 }
471 469
472 for(int i=0;i<(count%4);i++)
470 for(unsigned int i=0;i<(count%4);i++)
473 471 {
474 472 result.append(QVariant((int)(0x0FF&(data[count/4]>>((3-i)*8)))));
475 473 }
@@ -499,7 +497,7 int ahbuartplugin::detectSpeed()
499 497 unsigned int scaler = 0,dsuVal1=0,dsuVal2=0;
500 498 int speed=0;
501 499 QElapsedTimer time;
502 if(dsuBaseAddress!=-1)
500 if((int)dsuBaseAddress!=-1)
503 501 {
504 502 time.start();
505 503 if( this->Read(&dsuVal1,1,dsuBaseAddress+0x08)==1)
@@ -511,7 +509,7 int ahbuartplugin::detectSpeed()
511 509 return ((dsuVal2-dsuVal1)/el)*1000;
512 510 }
513 511 }
514 if(ahbUartBaseAddress!=-1)
512 if((int)ahbUartBaseAddress!=-1)
515 513 {
516 514 if( this->Read(&scaler,1,ahbUartBaseAddress+0x0C)==1)
517 515 {
@@ -525,10 +523,13 int ahbuartplugin::detectSpeed()
525 523
526 524 void ahbuartplugin::postInstantiationTrigger()
527 525 {
528 if(this->scanDone && this->Connected)
526 if(this->Connected)
529 527 {
530 528 this->UI->setSystemSpeed(this->detectSpeed());
531 529 }
530 QString portName = SocExplorerSettings::value(this->instance(),"PORT",this->UI->portName(),SocExplorerSettings::Session).toString();
531 int baudRate = SocExplorerSettings::value(this->instance(),"SPEED",this->UI->baudRate(),SocExplorerSettings::Session).toInt();
532 this->UI->setconfig(portName,baudRate);
532 533 }
533 534
534 535
@@ -85,7 +85,7 signals:
85 85 void addWritenBytes(int count);
86 86 void addReadBytes(int count);
87 87 private:
88 bool scanDone;
88 // bool scanDone;
89 89 QProgressDialog* progress;
90 90 QLayout * mainLayout;
91 91 ahbUartPluginUI* UI;
@@ -109,6 +109,12 int ahbUartPluginUI::baudRate()
109 109 return ui->portSpeed->text().toInt();
110 110 }
111 111
112 QString ahbUartPluginUI::portName()
113 {
114 return this->ui->PortName->text();
115 }
116
117
112 118 void ahbUartPluginUI::closeEvent(QCloseEvent *event)
113 119 {
114 120 event->accept();
@@ -44,6 +44,7 public:
44 44 void closeEvent(QCloseEvent *event);
45 45 void setCompleter(QCompleter* completer);
46 46 int baudRate();
47 QString portName();
47 48 public slots:
48 49 void setConnected(bool connected);
49 50 void connectPort();
General Comments 0
You need to be logged in to leave comments. Login now