##// END OF EJS Templates
APBUART Working, need some cosmetic now.
Jeandet Alexis -
r29:8466dbc97576 default
parent child
Show More
@@ -29,7 +29,7 APBUART_Plugin_ui::APBUART_Plugin_ui(QWi
29 {
29 {
30 ui->setupUi(this);
30 ui->setupUi(this);
31 connect(this->ui->FIFODebugChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int)));
31 connect(this->ui->FIFODebugChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int)));
32 connect(this,SIGNAL(apbUartTextReceived(QString)),this->ui->UART_TERM,SLOT(append(QString)));
32 connect(this,SIGNAL(apbUartTextReceived(QString)),this->ui->UART_TERM,SLOT(apbUartTextReceived(QString)));
33 connect(this->ui->ConnectQpb,SIGNAL(clicked()),this,SIGNAL(connectPort()));
33 connect(this->ui->ConnectQpb,SIGNAL(clicked()),this,SIGNAL(connectPort()));
34 connect(this->ui->UART_TERM,SIGNAL(sendChar(char)),this,SIGNAL(sendChar(char)));
34 connect(this->ui->UART_TERM,SIGNAL(sendChar(char)),this,SIGNAL(sendChar(char)));
35 connect(this->ui->PortNameLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(PortNameChanged(QString)));
35 connect(this->ui->PortNameLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(PortNameChanged(QString)));
@@ -17,7 +17,7
17 <item>
17 <item>
18 <widget class="QTabWidget" name="TabWidget">
18 <widget class="QTabWidget" name="TabWidget">
19 <property name="currentIndex">
19 <property name="currentIndex">
20 <number>1</number>
20 <number>0</number>
21 </property>
21 </property>
22 <widget class="QWidget" name="Config">
22 <widget class="QWidget" name="Config">
23 <attribute name="title">
23 <attribute name="title">
@@ -33,7 +33,7
33 <string>Enable FIFO debug mode</string>
33 <string>Enable FIFO debug mode</string>
34 </property>
34 </property>
35 <property name="checked">
35 <property name="checked">
36 <bool>true</bool>
36 <bool>false</bool>
37 </property>
37 </property>
38 </widget>
38 </widget>
39 </item>
39 </item>
@@ -24,12 +24,22
24 ApbUartTerminal::ApbUartTerminal(QWidget *parent) :
24 ApbUartTerminal::ApbUartTerminal(QWidget *parent) :
25 QTextEdit(parent)
25 QTextEdit(parent)
26 {
26 {
27 connect(this,SIGNAL(apbUartTextReceived(QString)),this,SLOT(append(QString)));
27 // connect(this,SIGNAL(apbUartTextReceived(QString)),this,SLOT(append(QString)));
28 setReadOnly(true);
28 setReadOnly(true);
29 }
29 }
30
30
31 void ApbUartTerminal::keyPressEvent(QKeyEvent *e)
31 void ApbUartTerminal::keyPressEvent(QKeyEvent *e)
32 {
32 {
33 emit this->sendChar((char)e->key());
33 if((e->modifiers()==(Qt::ShiftModifier | Qt::ControlModifier)) && (e->key()==Qt::Key_L))
34 this->clear();
35 else
36 emit this->sendChar((char)e->key());
34 e->accept();
37 e->accept();
35 }
38 }
39
40 void ApbUartTerminal::apbUartTextReceived(QString text)
41 {
42 moveCursor (QTextCursor::End);
43 insertPlainText (text);
44 moveCursor (QTextCursor::End);
45 }
@@ -34,9 +34,9 public:
34
34
35 protected:
35 protected:
36 void keyPressEvent(QKeyEvent * e);
36 void keyPressEvent(QKeyEvent * e);
37
37 public slots:
38 void apbUartTextReceived(QString text);
38 signals:
39 signals:
39 void apbUartTextReceived(QString text);
40 void sendChar(char c);
40 void sendChar(char c);
41 public slots:
41 public slots:
42
42
@@ -29,9 +29,16 UARTPollingThread::UARTPollingThread(soc
29 uartMutex = new QMutex();
29 uartMutex = new QMutex();
30 uartOpened = false;
30 uartOpened = false;
31 fifoDebugConfigured = false;
31 fifoDebugConfigured = false;
32 fifoDebugEnabled = false;
32 this->moveToThread(this);
33 this->moveToThread(this);
33 }
34 }
34
35
36 UARTPollingThread::~UARTPollingThread()
37 {
38 this->requestInterruption();
39 while(isRunning());
40 }
41
35 void UARTPollingThread::run()
42 void UARTPollingThread::run()
36 {
43 {
37
44
@@ -70,19 +77,21 void UARTPollingThread::run()
70 else
77 else
71 {
78 {
72 int read =0;
79 int read =0;
73 char ch;
80 char ch[1];
74 uartMutex->lock();
81 uartMutex->lock();
75 if(uartOpened)
82 if(uartOpened)
76 {
83 {
77 read =rs232read(this->uart,&ch,1);
84 read =rs232read(this->uart,ch,1);
85 SocExplorerEngine::message(this->plugin,QString("Read %1 bytes on uart").arg(read),3);
78 }
86 }
79 uartMutex->unlock();
87 uartMutex->unlock();
80 if(read==1)
88 if(read>=1)
81 {
89 {
82 emit this->sendChar(ch);
90 SocExplorerEngine::message(this->plugin,QString("Received one char from APBUART"),3);
91 emit this->apbUartTextReceived(QString(ch[0]));
83 }
92 }
93 msleep(1);
84 }
94 }
85 msleep(100);
86 }
95 }
87 }
96 }
88
97
@@ -106,16 +115,20 void UARTPollingThread::sendChar(char c)
106
115
107 bool UARTPollingThread::openUart()
116 bool UARTPollingThread::openUart()
108 {
117 {
118 uartMutex->lock();
109 if(uartOpened)
119 if(uartOpened)
110 {
120 {
111 closeUart();
121 closeUart();
112 }
122 }
123 SocExplorerEngine::message(this->plugin,"Opening UART "+this->portName,3);
113 this->uart = rs232open((char*)this->portName.toStdString().c_str());
124 this->uart = rs232open((char*)this->portName.toStdString().c_str());
114 if(this->uart!=badPortValue)
125 if(this->uart!=badPortValue)
115 {
126 {
127 SocExplorerEngine::message(this->plugin,QString("Configuring UART, speed =%1").arg(this->uartSpeed),3);
116 rs232setup(this->uart,8,this->uartSpeed,rs232parityNo,rs232OneStop);
128 rs232setup(this->uart,8,this->uartSpeed,rs232parityNo,rs232OneStop);
117 uartOpened = true;
129 uartOpened = true;
118 }
130 }
131 uartMutex->unlock();
119 return uartOpened;
132 return uartOpened;
120 }
133 }
121
134
@@ -129,16 +142,19 void UARTPollingThread::closeUart()
129
142
130 void UARTPollingThread::setPortName(QString name)
143 void UARTPollingThread::setPortName(QString name)
131 {
144 {
145 SocExplorerEngine::message(this->plugin,"Changing UART port Name: "+name,3);
132 this->portName = name;
146 this->portName = name;
133 }
147 }
134
148
135 void UARTPollingThread::setPortSpeedStr(QString speed)
149 void UARTPollingThread::setPortSpeedStr(QString speed)
136 {
150 {
151 SocExplorerEngine::message(this->plugin,"Changing UART speed: "+speed,3);
137 this->uartSpeed = speed.toInt();
152 this->uartSpeed = speed.toInt();
138 }
153 }
139
154
140 void UARTPollingThread::setPortSpeed(int speed)
155 void UARTPollingThread::setPortSpeed(int speed)
141 {
156 {
157 SocExplorerEngine::message(this->plugin,QString("Changing UART speed: %1").arg(speed),3);
142 this->uartSpeed = speed;
158 this->uartSpeed = speed;
143 }
159 }
144
160
@@ -39,6 +39,7 class UARTPollingThread : public QThread
39 Q_OBJECT
39 Q_OBJECT
40 public:
40 public:
41 explicit UARTPollingThread(socexplorerplugin *parent = 0);
41 explicit UARTPollingThread(socexplorerplugin *parent = 0);
42 ~UARTPollingThread();
42 void run();
43 void run();
43 signals:
44 signals:
44 void apbUartTextReceived(QString text);
45 void apbUartTextReceived(QString text);
@@ -40,6 +40,8 GR_ESB_bridge::GR_ESB_bridge(socexplorer
40
40
41 GR_ESB_bridge::~GR_ESB_bridge()
41 GR_ESB_bridge::~GR_ESB_bridge()
42 {
42 {
43 this->manager->requestInterruption();
44 while(this->manager->isRunning());
43 }
45 }
44
46
45 void GR_ESB_bridge::toggleBridgeConnection()
47 void GR_ESB_bridge::toggleBridgeConnection()
@@ -37,6 +37,7 stardundeeSPW_USB::stardundeeSPW_USB(soc
37 stardundeeSPW_USB::~stardundeeSPW_USB()
37 stardundeeSPW_USB::~stardundeeSPW_USB()
38 {
38 {
39 this->manager->requestInterruption();
39 this->manager->requestInterruption();
40 while(this->manager->isRunning());
40 }
41 }
41
42
42 void stardundeeSPW_USB::toggleBridgeConnection()
43 void stardundeeSPW_USB::toggleBridgeConnection()
General Comments 0
You need to be logged in to leave comments. Login now