##// END OF EJS Templates
Improved AHB UART Plugin, now check how many bytes are available on uart...
Improved AHB UART Plugin, now check how many bytes are available on uart before reading.

File last commit:

r28:0f22f4cfd076 default
r33:de3df68ac881 default
Show More
APBUARTPLUGIN.cpp
102 lines | 3.1 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>
ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent)
{
this->setBaseAddress(-1);
this->UI = new APBUART_Plugin_ui();
this->setWidget((QWidget*)this->UI);
this->uartConnected = false;
this->UartThread = new UARTPollingThread(this);
connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(loopbackChangeState(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)));
this->UartThread->start();
}
ApbUartPlugin::~ApbUartPlugin()
{
}
void ApbUartPlugin::closeMe()
{
emit this->closePlugin(this);
}
void ApbUartPlugin::toggleUartState()
{
if(!uartConnected)
{
uartConnected = this->UartThread->openUart();
}
else
{
this->UartThread->closeUart();
this->uartConnected = false;
}
this->UI->setUartConnected(uartConnected);
}
void ApbUartPlugin::loopbackChangeState(int state)
{
if(state==Qt::Checked)
{
this->UI->setEnableForLoopBack(false);
this->UartThread->setFifoDebugEable(true);
}
else
{
this->UI->setEnableForLoopBack(true);
this->UartThread->setFifoDebugEable(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;
}