##// END OF EJS Templates
SREC file perser WIP.
jeandet -
r44:81145171ec94 default
parent child
Show More
@@ -0,0 +1,154
1 #include "srecfile.h"
2
3 srecFile::srecFile()
4 {
5 }
6
7 srecFile::srecFile(const QString &File)
8 {
9 openFile(File);
10 }
11
12 srecFile::srecFile(const QStringList &Files)
13 {
14 openFiles(Files);
15 }
16
17 srecFile::~srecFile()
18 {
19
20 }
21
22 bool srecFile::openFile(const QString &File)
23 {
24 openFiles(QStringList()<<File);
25 }
26
27 bool srecFile::openFiles(const QStringList &Files)
28 {
29 this->p_fileNames.clear();
30 this->p_fileNames.append(Files);
31 for(int i=0;i<p_files.count();i++)
32 {
33 delete p_files.at(i);
34 }
35 this->p_files.clear();
36 for(int i=0;i<Files.count();i++)
37 {
38 this->p_files.append(new QFile(Files.at(i)));
39 this->p_files.at(i)->open(QIODevice::ReadOnly);
40 parseFile(this->p_files.at(i));
41 }
42 }
43
44 bool srecFile::isopened()
45 {
46 bool opened = true;
47 for(int i=0;i<this->p_files.count();i++)
48 {
49 opened &= p_files.at(i)->isOpen();
50 }
51 return opened;
52 }
53
54 int srecFile::closeFile()
55 {
56
57 }
58
59 QList<codeFragment *> srecFile::getFragments()
60 {
61 return p_fragments;
62 }
63
64 void srecFile::parseFile(QFile *file)
65 {
66 if(file->isOpen())
67 {
68 file->seek(0);
69 codeFragment* fragment=NULL;
70 QByteArray data;
71 quint32 size=0;
72 quint32 address=0;
73 while (!file->atEnd())
74 {
75 QString line = file->readLine();
76 if(line.count()>4)
77 {
78 if(line.at(0)=='S')
79 {
80 bool ok;
81 int count = line.mid(2,2).toInt(&ok,16);
82 if(line.at(1)=='0')
83 {
84 }
85 if(line.at(1)=='1')
86 {
87 }
88 if(line.at(1)=='2')
89 {
90
91 }
92 if(line.at(1)=='3')
93 {
94 int naddress =line.mid(4,8).toInt(&ok,16);
95 if(address !=naddress)
96 {
97 if(fragment!=NULL)
98 {
99 fragment->size = data.size();
100 fragment->data = (char*)malloc(data.size());
101 for(int i =0;i<data.size();i++)
102 {
103 fragment->data[i]=data.at(i);
104 }
105 data.clear();
106 p_fragments.append(fragment);
107 }
108 fragment = new codeFragment();
109 fragment->address = naddress;
110 }
111 address = naddress+count-5;
112 for(int i=0;i<(count-5);i++)
113 {
114 data.append((char)line.mid((2*i)+8,2).toInt(&ok,16));
115 }
116 }
117 if(line.at(1)=='5')
118 {
119
120 }
121 if(line.at(1)=='6')
122 {
123
124 }
125 if(line.at(1)=='7')
126 {
127
128 }
129 if(line.at(1)=='8')
130 {
131
132 }
133 if(line.at(1)=='9')
134 {
135
136 }
137 }
138 }
139 }
140 if(data.size()!=0)
141 {
142 fragment->size = data.size();
143 fragment->data = (char*)malloc(data.size());
144 for(int i =0;i<data.size();i++)
145 {
146 fragment->data[i]=data.at(i);
147 }
148 data.clear();
149 p_fragments.append(fragment);
150 }
151
152 }
153 }
154
@@ -0,0 +1,34
1 #ifndef SRECFILE_H
2 #define SRECFILE_H
3
4 #include <QObject>
5 #include <abstractexecfile.h>
6 #include <QFile>
7 #include <QStringList>
8
9 class srecFile : public abstractExecFile
10 {
11 Q_OBJECT
12 public:
13 explicit srecFile();
14 srecFile(const QString& File);
15 srecFile(const QStringList& Files);
16 ~srecFile();
17 bool openFile(const QString& File);
18 bool openFiles(const QStringList& Files);
19 bool isopened();
20 int closeFile();
21 QList<codeFragment*> getFragments();
22
23 signals:
24
25 public slots:
26 private:
27 void parseFile(QFile* file);
28 QStringList p_fileNames;
29 QList<QFile*>p_files;
30 QList<codeFragment*> p_fragments;
31
32 };
33
34 #endif // SRECFILE_H
@@ -11,3 +11,4
11 #include "elf/elffilewidget.h"
11 #include "elf/elffilewidget.h"
12 #include "elf/elfinfowdgt.h"
12 #include "elf/elfinfowdgt.h"
13 #include "QCustomPlot/qcustomplot.h"
13 #include "QCustomPlot/qcustomplot.h"
14 #include "srec/srecfile.h"
@@ -45,7 +45,7 public:
45 virtual QList<codeFragment*> getFragments()=0;
45 virtual QList<codeFragment*> getFragments()=0;
46
46
47 protected:
47 protected:
48 QString p_fileName;
48 QString p_fileName;
49 };
49 };
50
50
51 #endif // ABSTRACTEXECFILE_H
51 #endif // ABSTRACTEXECFILE_H
@@ -41,7 +41,8 header.files = \
41 elf/elffilewidget.h \
41 elf/elffilewidget.h \
42 qipdialogbox.h \
42 qipdialogbox.h \
43 lppserial/src/RS232.h \
43 lppserial/src/RS232.h \
44 qtablewidgetintitem.h
44 qtablewidgetintitem.h \
45 srec/srecfile.h
45
46
46 win32{
47 win32{
47 elfheader.path = $$[QT_INSTALL_HEADERS]/SocExplorer/common/libelf
48 elfheader.path = $$[QT_INSTALL_HEADERS]/SocExplorer/common/libelf
@@ -87,7 +88,8 HEADERS += \
87 PySocExplorer.h \
88 PySocExplorer.h \
88 SocExplorerPlot.h \
89 SocExplorerPlot.h \
89 elf/elffilewidget.h \
90 elf/elffilewidget.h \
90 qtablewidgetintitem.h
91 qtablewidgetintitem.h \
92 srec/srecfile.h
91
93
92
94
93 SOURCES += \
95 SOURCES += \
@@ -107,7 +109,8 SOURCES += \
107 qipdialogbox.cpp \
109 qipdialogbox.cpp \
108 SocExplorerPlot.cpp \
110 SocExplorerPlot.cpp \
109 elf/elffilewidget.cpp \
111 elf/elffilewidget.cpp \
110 qtablewidgetintitem.cpp
112 qtablewidgetintitem.cpp \
113 srec/srecfile.cpp
111
114
112 FORMS += \
115 FORMS += \
113 elf/elffilewidget.ui
116 elf/elffilewidget.ui
@@ -17,6 +17,7
17 #include <qcoreevent.h>
17 #include <qcoreevent.h>
18 #include <qcursor.h>
18 #include <qcursor.h>
19 #include <qevent.h>
19 #include <qevent.h>
20 #include <qfile.h>
20 #include <qfont.h>
21 #include <qfont.h>
21 #include <qgraphicseffect.h>
22 #include <qgraphicseffect.h>
22 #include <qgraphicsproxywidget.h>
23 #include <qgraphicsproxywidget.h>
@@ -6910,3 +6911,158 int PythonQtWrapper_elfparser::setFilen
6910 }
6911 }
6911
6912
6912
6913
6914
6915 PythonQtShell_srecFile::~PythonQtShell_srecFile() {
6916 PythonQtPrivate* priv = PythonQt::priv();
6917 if (priv) { priv->shellClassDeleted(this); }
6918 }
6919 int PythonQtShell_srecFile::closeFile()
6920 {
6921 if (_wrapper) {
6922 PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "closeFile");
6923 PyErr_Clear();
6924 if (obj && !PythonQtSlotFunction_Check(obj)) {
6925 static const char* argumentList[] ={"int"};
6926 static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
6927 int returnValue;
6928 void* args[1] = {NULL};
6929 PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
6930 if (result) {
6931 args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
6932 if (args[0]!=&returnValue) {
6933 if (args[0]==NULL) {
6934 PythonQt::priv()->handleVirtualOverloadReturnError("closeFile", methodInfo, result);
6935 } else {
6936 returnValue = *((int*)args[0]);
6937 }
6938 }
6939 }
6940 if (result) { Py_DECREF(result); }
6941 Py_DECREF(obj);
6942 return returnValue;
6943 }
6944 }
6945 return srecFile::closeFile();
6946 }
6947 QList<codeFragment* > PythonQtShell_srecFile::getFragments()
6948 {
6949 if (_wrapper) {
6950 PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "getFragments");
6951 PyErr_Clear();
6952 if (obj && !PythonQtSlotFunction_Check(obj)) {
6953 static const char* argumentList[] ={"QList<codeFragment* >"};
6954 static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
6955 QList<codeFragment* > returnValue;
6956 void* args[1] = {NULL};
6957 PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
6958 if (result) {
6959 args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
6960 if (args[0]!=&returnValue) {
6961 if (args[0]==NULL) {
6962 PythonQt::priv()->handleVirtualOverloadReturnError("getFragments", methodInfo, result);
6963 } else {
6964 returnValue = *((QList<codeFragment* >*)args[0]);
6965 }
6966 }
6967 }
6968 if (result) { Py_DECREF(result); }
6969 Py_DECREF(obj);
6970 return returnValue;
6971 }
6972 }
6973 return srecFile::getFragments();
6974 }
6975 bool PythonQtShell_srecFile::isopened()
6976 {
6977 if (_wrapper) {
6978 PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "isopened");
6979 PyErr_Clear();
6980 if (obj && !PythonQtSlotFunction_Check(obj)) {
6981 static const char* argumentList[] ={"bool"};
6982 static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
6983 bool returnValue;
6984 void* args[1] = {NULL};
6985 PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
6986 if (result) {
6987 args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
6988 if (args[0]!=&returnValue) {
6989 if (args[0]==NULL) {
6990 PythonQt::priv()->handleVirtualOverloadReturnError("isopened", methodInfo, result);
6991 } else {
6992 returnValue = *((bool*)args[0]);
6993 }
6994 }
6995 }
6996 if (result) { Py_DECREF(result); }
6997 Py_DECREF(obj);
6998 return returnValue;
6999 }
7000 }
7001 return srecFile::isopened();
7002 }
7003 bool PythonQtShell_srecFile::openFile(const QString& File)
7004 {
7005 if (_wrapper) {
7006 PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "openFile");
7007 PyErr_Clear();
7008 if (obj && !PythonQtSlotFunction_Check(obj)) {
7009 static const char* argumentList[] ={"bool" , "const QString&"};
7010 static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
7011 bool returnValue;
7012 void* args[2] = {NULL, (void*)&File};
7013 PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
7014 if (result) {
7015 args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
7016 if (args[0]!=&returnValue) {
7017 if (args[0]==NULL) {
7018 PythonQt::priv()->handleVirtualOverloadReturnError("openFile", methodInfo, result);
7019 } else {
7020 returnValue = *((bool*)args[0]);
7021 }
7022 }
7023 }
7024 if (result) { Py_DECREF(result); }
7025 Py_DECREF(obj);
7026 return returnValue;
7027 }
7028 }
7029 return srecFile::openFile(File);
7030 }
7031 srecFile* PythonQtWrapper_srecFile::new_srecFile()
7032 {
7033 return new PythonQtShell_srecFile(); }
7034
7035 srecFile* PythonQtWrapper_srecFile::new_srecFile(const QString& File)
7036 {
7037 return new PythonQtShell_srecFile(File); }
7038
7039 srecFile* PythonQtWrapper_srecFile::new_srecFile(const QStringList& Files)
7040 {
7041 return new PythonQtShell_srecFile(Files); }
7042
7043 int PythonQtWrapper_srecFile::closeFile(srecFile* theWrappedObject)
7044 {
7045 return ( ((PythonQtPublicPromoter_srecFile*)theWrappedObject)->promoted_closeFile());
7046 }
7047
7048 QList<codeFragment* > PythonQtWrapper_srecFile::getFragments(srecFile* theWrappedObject)
7049 {
7050 return ( ((PythonQtPublicPromoter_srecFile*)theWrappedObject)->promoted_getFragments());
7051 }
7052
7053 bool PythonQtWrapper_srecFile::isopened(srecFile* theWrappedObject)
7054 {
7055 return ( ((PythonQtPublicPromoter_srecFile*)theWrappedObject)->promoted_isopened());
7056 }
7057
7058 bool PythonQtWrapper_srecFile::openFile(srecFile* theWrappedObject, const QString& File)
7059 {
7060 return ( ((PythonQtPublicPromoter_srecFile*)theWrappedObject)->promoted_openFile(File));
7061 }
7062
7063 bool PythonQtWrapper_srecFile::openFiles(srecFile* theWrappedObject, const QStringList& Files)
7064 {
7065 return ( theWrappedObject->openFiles(Files));
7066 }
7067
7068
@@ -18,6 +18,7
18 #include <qcoreevent.h>
18 #include <qcoreevent.h>
19 #include <qcursor.h>
19 #include <qcursor.h>
20 #include <qevent.h>
20 #include <qevent.h>
21 #include <qfile.h>
21 #include <qfont.h>
22 #include <qfont.h>
22 #include <qgraphicseffect.h>
23 #include <qgraphicseffect.h>
23 #include <qgraphicsproxywidget.h>
24 #include <qgraphicsproxywidget.h>
@@ -48,6 +49,7
48 #include <qstyle.h>
49 #include <qstyle.h>
49 #include <qstyleoption.h>
50 #include <qstyleoption.h>
50 #include <qwidget.h>
51 #include <qwidget.h>
52 #include <srecfile.h>
51 #include <tcp_terminal_client.h>
53 #include <tcp_terminal_client.h>
52 #include <xbytearray.h>
54 #include <xbytearray.h>
53
55
@@ -780,3 +782,47 void delete_elfparser(elfparser* obj) {
780 };
782 };
781
783
782
784
785
786
787
788 class PythonQtShell_srecFile : public srecFile
789 {
790 public:
791 PythonQtShell_srecFile():srecFile(),_wrapper(NULL) {};
792 PythonQtShell_srecFile(const QString& File):srecFile(File),_wrapper(NULL) {};
793 PythonQtShell_srecFile(const QStringList& Files):srecFile(Files),_wrapper(NULL) {};
794
795 ~PythonQtShell_srecFile();
796
797 virtual int closeFile();
798 virtual QList<codeFragment* > getFragments();
799 virtual bool isopened();
800 virtual bool openFile(const QString& File);
801
802 PythonQtInstanceWrapper* _wrapper;
803 };
804
805 class PythonQtPublicPromoter_srecFile : public srecFile
806 { public:
807 inline int promoted_closeFile() { return srecFile::closeFile(); }
808 inline QList<codeFragment* > promoted_getFragments() { return srecFile::getFragments(); }
809 inline bool promoted_isopened() { return srecFile::isopened(); }
810 inline bool promoted_openFile(const QString& File) { return srecFile::openFile(File); }
811 };
812
813 class PythonQtWrapper_srecFile : public QObject
814 { Q_OBJECT
815 public:
816 public slots:
817 srecFile* new_srecFile();
818 srecFile* new_srecFile(const QString& File);
819 srecFile* new_srecFile(const QStringList& Files);
820 void delete_srecFile(srecFile* obj) { delete obj; }
821 int closeFile(srecFile* theWrappedObject);
822 QList<codeFragment* > getFragments(srecFile* theWrappedObject);
823 bool isopened(srecFile* theWrappedObject);
824 bool openFile(srecFile* theWrappedObject, const QString& File);
825 bool openFiles(srecFile* theWrappedObject, const QStringList& Files);
826 };
827
828
@@ -16,5 +16,7 PythonQt::priv()->registerCPPClass("code
16 PythonQt::priv()->registerClass(&elfFileWidget::staticMetaObject, "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfFileWidget>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_elfFileWidget>, module, 0);
16 PythonQt::priv()->registerClass(&elfFileWidget::staticMetaObject, "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfFileWidget>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_elfFileWidget>, module, 0);
17 PythonQt::priv()->registerClass(&elfInfoWdgt::staticMetaObject, "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfInfoWdgt>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_elfInfoWdgt>, module, 0);
17 PythonQt::priv()->registerClass(&elfInfoWdgt::staticMetaObject, "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfInfoWdgt>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_elfInfoWdgt>, module, 0);
18 PythonQt::priv()->registerCPPClass("elfparser", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfparser>, NULL, module, 0);
18 PythonQt::priv()->registerCPPClass("elfparser", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfparser>, NULL, module, 0);
19 PythonQt::priv()->registerClass(&srecFile::staticMetaObject, "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_srecFile>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_srecFile>, module, 0);
20 PythonQt::self()->addParentClass("srecFile", "abstractExecFile",PythonQtUpcastingOffset<srecFile,abstractExecFile>());
19
21
20 }
22 }
@@ -17,6 +17,7
17 <object-type name="SocExplorerPlot" />
17 <object-type name="SocExplorerPlot" />
18 <object-type name="TCP_Terminal_Client" />
18 <object-type name="TCP_Terminal_Client" />
19 <object-type name="codeFragment" />
19 <object-type name="codeFragment" />
20 <object-type name="srecFile" />
20 <rejection class="Elf_Section"/>
21 <rejection class="Elf_Section"/>
21 <object-type name="elfparser" />
22 <object-type name="elfparser" />
22 <interface-type name="abstractExecFile">
23 <interface-type name="abstractExecFile">
@@ -3,4 +3,4
3 #export QTDIR=/usr/include
3 #export QTDIR=/usr/include
4 #export QTDIR=/usr/include/qt5
4 #export QTDIR=/usr/include/qt5
5
5
6 pythonqt_generator --include-paths=./elf:/usr/include/qt5:/usr/include/qt5/QtCore:/usr/include/qt5/QtWidgets --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt
6 pythonqt_generator --include-paths=./elf:./srec:/usr/include/qt5:/usr/include/qt5/QtCore:/usr/include/qt5/QtWidgets --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt
@@ -22,6 +22,7 INCLUDEPATH+=$${PWD} \
22 $${PWD}/common/qhexedit \
22 $${PWD}/common/qhexedit \
23 $${PWD}/common/QCustomPlot \
23 $${PWD}/common/QCustomPlot \
24 $${PWD}/common/elf \
24 $${PWD}/common/elf \
25 $${PWD}/common/srec \
25 SocExplorerEngine/engine \
26 SocExplorerEngine/engine \
26 SocExplorerEngine/pluginloader \
27 SocExplorerEngine/pluginloader \
27 SocExplorerEngine/pluginsInterface \
28 SocExplorerEngine/pluginsInterface \
General Comments 0
You need to be logged in to leave comments. Login now