Project

General

Profile

How To Write A Plugin » History » Version 1

Alexis Jeandet, 30/03/2014 05:29 PM

1 1 Alexis Jeandet
2
{{>toc}}
3
4
5
h1. How to write a SocExplorer plugin
6
7
8
Once you have installed SocExplorer from sources on your system, it should have added an new template to QtCreator. You can create a new plugin skeleton filling the wizard forms. Your plugin description is written in its qmake project file.
9
A SocExplorer plugin inherits from the socexplorerlugin base class which inherits from QDockWidget. 
10
11
12
h2. SocExplorerEngine services
13
14
Through SocExplorerEngine object you get some shared and centralized services.
15
 
16
h3. Message logging
17
18
Instead of using printf inside a plugin to print some information, you can use this function:
19
<pre><code class="cpp">
20
void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel)
21
22
//From your plugin:
23
24
SocExplorerEngine::message(this,"Here is a message with a debug level of 2",2);
25
26
</code></pre>
27
28
With this function you will centralize all the plugins messages and they will share the same formalism. Note that you can set the debug level of your message, if the message debugLevel is lower than SocEplorer loglevel then the message will be printed else it will be dropped.
29
To set the SocExplorer debug level you can use the -d option like this:
30
<pre>
31
<code class="bash">
32
socexplorer -d 4 #all the message with a debug level or equal lower than 4 will be printed
33
</code>
34
</pre>
35
36
37
h3. Managing peripherals base address (Plugn'Play)
38
39
You don't necessary know the address of the peripherals present in your soc when you write a plugin for SocExplorer. So SocEplorer allows you to enumerate the peripheral inside your soc at run-time and share their base address with other plugins.
40
41
To enumerate a device/peripheral:
42
43
<pre>
44
<code class="cpp">
45
int addEnumDevice(const QString& rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name);
46
47
//From your plugin:
48
QString devname = SocExplorerEngine::getDevName(VID,PID); // If the device is known you will get it name
49
SocExplorerEngine::addEnumDevice(this,VID,PID,BaseAddress,devname);
50
</code>
51
</pre>
52
53
Now to get a peripheral base address:
54
55
56
<pre>
57
<code class="cpp">
58
qint32 getEnumDeviceBaseAddress(const QString& rootPlugin,int VID,int PID,int count=0);
59
     //or
60
qint32 getEnumDeviceBaseAddress(socexplorerplugin* plugin,int VID,int PID,int count=0);
61
62
//From your plugin:
63
unsigned int DSUBASEADDRESS = SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,0x01 , 0x004,0); //you will get the Grlib's DSU3 base address 
64
</code>
65
</pre>
66
67
68
h3. Loading a plugin from an other one
69
70
For example once you get successfully connected to the target through a root plugin you may want to automatically trigger an AMBA bus scan with the AMB plugin.
71
72
<pre>
73
<code class="cpp">
74
void loadChildSysDriver(socexplorerplugin *parent, const QString child);
75
76
//From your plugin:
77
socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
78
</code>
79
</pre>