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