##// END OF EJS Templates
dsu3 wip
dsu3 wip

File last commit:

r33:de3df68ac881 default
r37:934336d3c2c5 default
Show More
ahbuartplugin.h
99 lines | 3.2 KiB | text/x-c | CLexer
/*------------------------------------------------------------------------------
-- This file is a part of the SocExplorer Software
-- Copyright (C) 2011, 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 3 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@lpp.polytechnique.fr
----------------------------------------------------------------------------*/
#ifndef AHBUARTPLUGIN_H
#define AHBUARTPLUGIN_H
#include <QMenuBar>
#include <QMenu>
#include <QAction>
#include <QLayout>
#include <QMutex>
#include <QProgressDialog>
#include <QStringListModel>
#include <QTime>
#include <socexplorerplugin.h>
#include "ahbuartpluginui.h"
#include <RS232.h>
#include <unistd.h>
#define SAFEWRITE(data,count,timer,timeout,error) \
while(1)\
{\
unsigned int __writen__=0; \
(timer).restart(); \
while(__writen__!=(count)) \
{\
__writen__ += rs232write(this->port,((data)+__writen__),((count)-__writen__)); \
if((timer).elapsed()>(timeout)) \
{\
this->port = (rs232port_t)NULL; \
this->Connected = false; \
emit this->activateSig(false); \
error; \
} \
} \
break;\
}
class ahbuartplugin : public socexplorerplugin
{
Q_OBJECT
public:
ahbuartplugin(QWidget *parent = 0);
~ahbuartplugin();
int registermenu(QMainWindow *menuHolder);
int VID(){return driver_VID;}
int PID(){return driver_PID;}
public slots:
void togglePort(QString PortName,int baudrate);
unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
void closeMe();
void close();
bool open(QString PortName,int baudrate);
void updatePortList();
QVariantList ReadBytes(unsigned int address,unsigned int count);
void WriteBytes(unsigned int address,QList<QVariant> dataList);
signals:
void setProgressValue(int progress);
void addWritenBytes(int count);
void addReadBytes(int count);
private:
bool scanDone;
QProgressDialog* progress;
QLayout * mainLayout;
ahbUartPluginUI* UI;
QMutex* portMutex;
rs232port_t port;
QCompleter *portListcompleter;
QStringListModel *portListcompleterModel;
void connectPort(QString PortName,int baudrate);
bool checkConnection();
};
#endif // AHBUARTPLUGIN_H