##// END OF EJS Templates
Removed APBUartPlugin bug (when switching between debug and non debug link)....
Removed APBUartPlugin bug (when switching between debug and non debug link). Added APBUart Python wrapper.

File last commit:

r34:ccd56e93ef09 default
r34:ccd56e93ef09 default
Show More
APBUARTPLUGIN.cpp
177 lines | 5.4 KiB | text/x-c | CppLexer
/*------------------------------------------------------------------------------
-- This file is a part of the SocExplorer Software
-- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------*/
/*-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@member.fsf.org
----------------------------------------------------------------------------*/
#include "APBUARTPLUGIN.h"
#include <socexplorerengine.h>
#include <apbuartpywrapper.h>
ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent,false)
{
this->setBaseAddress(-1);
this->p_curentAPBUart = 0;
this->UI = new APBUART_Plugin_ui();
this->setWidget((QWidget*)this->UI);
this->uartConnected = false;
this->UartThread = new UARTPollingThread(this);
this->pyObject = new APBUartPyWrapper(this);
connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(fifoDebugChangeState(int)));
connect(this->UartThread,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString)));
connect(this->UI,SIGNAL(connectPort()),this,SLOT(toggleUartState()));
connect(this->UI,SIGNAL(sendChar(char)),this->UartThread,SLOT(sendChar(char)));
connect(this->UI,SIGNAL(PortNameChanged(QString)),this->UartThread,SLOT(setPortName(QString)));
connect(this->UI,SIGNAL(UartSpeedChanged(QString)),this->UartThread,SLOT(setPortSpeedStr(QString)));
connect(this->UI,SIGNAL(updateAPBUartsList()),this,SLOT(updateAPBUartsList()));
connect(this->UI,SIGNAL(curentAPBUartChanged(int)),this,SLOT(setCurentAPBUart(int)));
connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(openUart()),this,SLOT(openUart()));
connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(closeUart()),this,SLOT(closeUart()));
connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(setFifoDebugEnabled(bool)),this,SLOT(setFifoDebugEnabled(bool)));
connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(setUARTPortNane(QString)),this,SLOT(setUARTPortNane(QString)));
connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(setUARTPortSpeed(int)),this,SLOT(setUARTPortSpeed(int)));
connect(((APBUartPyWrapper*)this->pyObject),SIGNAL(updateAPBUartsList()),this,SLOT(updateAPBUartsList()));
this->UartThread->start();
}
ApbUartPlugin::~ApbUartPlugin()
{
}
int ApbUartPlugin::curentAPBUart()
{
return p_curentAPBUart;
}
void ApbUartPlugin::closeMe()
{
emit this->closePlugin(this);
}
void ApbUartPlugin::toggleUartState()
{
if(!uartConnected)
{
this->openUart();
}
else
{
this->closeUart();
}
}
void ApbUartPlugin::activate(bool flag)
{
socexplorerplugin::activate(flag);
this->updateAPBUartsList();
}
void ApbUartPlugin::updateAPBUartsList()
{
QList<unsigned int> addresses;
int count = SocExplorerEngine::self()->getEnumDeviceCount(this,this->VID(),this->PID());
for(int i=0;i<count;i++)
{
addresses.append(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),i));
}
this->UI->updateAPBUartList(addresses);
}
void ApbUartPlugin::setCurentAPBUart(int index)
{
this->p_curentAPBUart = index;
this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),index));
}
void ApbUartPlugin::openUart()
{
if(this->UartThread->fifoDebugEnabled())
setFifoDebugEnabled(false);
if(!uartConnected)
uartConnected = this->UartThread->openUart();
this->UI->setUartConnected(uartConnected);
}
void ApbUartPlugin::closeUart()
{
if(uartConnected)
this->UartThread->closeUart();
this->uartConnected = false;
this->UI->setUartConnected(uartConnected);
}
void ApbUartPlugin::setFifoDebugEnabled(bool enable)
{
if(uartConnected)
closeUart();
this->UI->setEnableForLoopBack(!enable);
this->UartThread->setFifoDebugEable(enable);
}
void ApbUartPlugin::setAPBUartIndex(int index)
{
this->UI->setAPBUartIndex(index);
}
void ApbUartPlugin::setUARTPortNane(QString name)
{
this->UI->setUartPortName(name);
}
void ApbUartPlugin::setUARTPortSpeed(int speed)
{
this->UI->setUartSpeed(speed);
}
void ApbUartPlugin::fifoDebugChangeState(int state)
{
if(state==Qt::Checked)
{
this->setFifoDebugEnabled(true);
}
else
{
this->setFifoDebugEnabled(false);
}
}
unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
{
if(parent!=NULL)
return parent->Read(Value,count,address);
return 0;
}
unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
{
if(parent!=NULL)
return parent->Write(Value,count,address);
return 0;
}