Difference between revisions of "NESCDT"

From TinyOS Wiki
Jump to: navigation, search
(Exporting)
 
(17 intermediate revisions by one other user not shown)
Line 1: Line 1:
This is a short description of how to ''use'' and ''develop'' the ''nescdt'' plugin.
+
#REDIRECT [[NESCDT- An editor for nesC in Eclipse]]
It is an editor for working with ''nesC'' code within Eclipse (as an alternative to other editors). Fundamentally, you just create a new project in Eclipse and link those folders from your TinyOS installation and your application tree that are needed. The plugin then scans the linked source code and uses this for auto-completion (press CTRL + SPACE after having partially typed a word). Built-in keywords (which you can change (see Development section)) are used for syntax highlighting.
 
The plugin ''does not touch'', nor does it compete with your build system: you still build your applications with ''make'' in whatever way you do it today.
 
 
 
==Using the ''nescdt'' TinyOS plugin for Eclipse==
 
A basic [http://nescc.sourceforge.net/papers/nesc-ref.pdf '''nesC'''] editor plugin for TinyOS-2.x using Eclipse with syntax highlighting and ''.nc'' file content detection for the follow types (the same symbols are used as in [[Getting_Started_with_TinyOS#Visualizing_a_Component_Graph| nesdoc]]):
 
* ''interface'' [[Image:Inter.gif]],
 
* ''module'' [[Image:Mod.gif]],
 
* ''generic module'' [[Image:Genmod.gif]],
 
* ''configuration'' [[Image:Conf.gif]],
 
* ''generic configuration'' [[Image:Genconf.gif]]
 
* ''safe'' [[Image:Safe.gif]](experimental).
 
 
 
===Installing===
 
The source is included in the plugin jar file, and it is possible to refine it (see the Development section). To install the plugin:
 
* '''Version 0.0.14''': First download the ''nescdt_0.0.14.jar'' file [[http://nxtmote.sf.net/nescdt_0.0.14.jar here]]
 
* Save it in the root of Eclipse plugin directory (where the other (jar) plugins also reside), and delete the previous version of this plugin if you have it. It would usually be c:\eclipse\plugins on a Windows machine.
 
* Restart Eclipse (perhaps verify for yourself that it is installed: ''Help->About Eclipse SDK->Plug-in Details'')
 
 
 
===Using the Plugin===
 
* Associate the *.nc files with this editor: ''Windows->Preferences->General->Editors->File Associations''
 
[[Image:Nxtmote-fileassosi.png]]
 
* Create a new empty project [[Image:Nxtmote-newproject.jpg]] and name it what you want to (for example ''nescsampleproject'')
 
* Create a new folder in the project (right-click on the project) and name it what you want to
 
* Import and link to the part of the TinyOS tree or your own code(right-click on the ''nescsampleproject'' folder and press import)
 
[[Image:Nxtmote-folderlink.jpg]]
 
* Choose the ''Link to folder in the file system'' option and proceed (this will not change your TinyOS code at all and it will not copy any files on your computer)
 
*Repeat the steps above until you have linked all the folders you need for application development
 
* When you are done the Eclipse IDE could look something like this (note that the content of the files have been analyzed and that the icons reveal that we have some configurations, generic configurations, modules, and generic modules in the ''mica2'' folder):
 
[[Image:Nxtmote-editor.png]]
 
*When you open some ''.nc'' file it will be syntax colored (according some some predefined rules in the plugin):
 
[[Image:Nxtmote-editorsyntax2.png]]
 
*There is auto-completion for keywords, types, and all other word found when then plugin scanned the .nc files in the linked folders. Press CTRL + SPACE to get the suggestions.
 
 
 
[[Image:Nxtmote-keywordcompletion1a.png]]
 
 
 
Then select a word and press ENTER to insert the word.
 
 
 
[[Image:Nxtmote-keywordcompletion2.png]]
 
 
 
=== Side notes ===
 
**The ''nescdt'' plugin is < 50 kB
 
**(Experimental) If it detects ''safe'' code (looking for ''@safe'', ''*COUNT'', ''*SIZE'', or ''*SAFE'') a rhombus shape is added to the icon. A ''safe'' module could look like this [[Image:Nxtmote-safedemo.png]] in the file navigator (note that a little rhombus has been added to the module icon).
 
**If the CVS [http://www.eclipse.org/articles/Article-Decorators/decorators.html decorators] annoy you (if, for example, another CVS client than Eclipse is being used), then turn them off from ''Window->Preferences->General->Appearance->Label Decorations''.
 
**You can also consider downloading the CDT plugin for editing header files and perhaps ''C'' files in Eclipse. Enter the [http://download.eclipse.org/tools/cdt/releases/europa http://download.eclipse.org/tools/cdt/releases/europa] as a new ''Remote site'' in the Eclipse update manager and choose the CDT main plugin:
 
[[Image:Nxtmote-cdtdownload.png]]
 
 
 
==Developing/Debugging on the NESCDT Plugin==
 
The last section was about using the plugin. To develop, customize, or debug the ''nescdt'' plugin, you can follow the guide below. In a best-case scenario it would be completed in 15-30 min.
 
 
 
The immediate places for personal enhancement/customization of the ''nescdt''plugin are:
 
*Change keywords coloring (go to ''INescColorConstants.java'')
 
*Add or remove items in the keywords list (go to ''NescKeywords.java'')
 
*Control which words included in the auto-completion scanner (go to the method ''parseLine'' in ''NescParser.java'')
 
*Change the icons used for nc files and type visualization (go to the icons folder)
 
 
 
 
 
===Importing the Plugin into Eclipse for Development===
 
Here we start with a blank Eclipse workspace. You can get a new workspace (if you want to) by creating a shortcut and starting Eclipse with a command line similar to this:
 
C:\eclipse\eclipse.exe -data -consolelog C:\Dokumenter\eclipse\workspace-plugin
 
The '''consolelog''' makes it possible to see '''System.out.println''' from the plugin itself (it is cheating, but useful during development).
 
 
 
[[Image:1-Dev-Blank-Eclipse.png]]
 
 
 
Assuming that you have downloaded the plugin (see start of this wiki page) it is now the time to import it into Eclipse for development. Press ''Import'':
 
 
 
[[Image:2-Dev-Import.png]]
 
 
 
Select ''Plug-ins and Fragments'':
 
 
 
[[Image:3-Dev-pluginselect.png]]
 
 
 
'''Important:''' Choose ''Projects with source folders'':
 
 
 
[[Image:4-Dev-withsource.png]]
 
 
 
Select the ''nescdt'' plugin in the version you happen to have:
 
 
 
[[Image:5-Dev-select.png]]
 
 
 
===Debugging===
 
To show how easy it is to change it, look at the following example. It is code that splits the contents of a ''.nc'' file into string tokens:
 
 
 
[[Image:5a-Dev-coding-example.png]]
 
 
 
Try to place a breakpoint by double-clicking on the bar to the left of the code that you want to inspect (see red arrow below). Then click on the menu to debug an ''Eclipse Application''. It is a second Eclipse instance that will be launched running the imported version of the plugin (not the plugin you downloaded into the ECLIPSEHOME/plugin folder. Eclipse automatically deactivates the permanent plugin in the launched debugging instance of Eclipe):
 
 
 
[[Image:5b-Dev-debug-start.png]]
 
 
 
It will then look like this when you have the two instances of Eclipse running. As a side-note you can see the completion processor has started to scan the .nc source code (red arrow):
 
 
 
[[Image:5c-Dev-debug-ok.png]]
 
 
 
To create a new version of the plugin please double click on the ''plugin.xml'' file in the project. Then select the ''Export Wizard'':
 
 
 
[[Image:6-Dev-start-export.png]]
 
 
 
Check the ''src'' folder for export when doing a binary build (so you export the source code with the plugin and makes it possible for others to do what you are doing now):
 
 
 
[[Image:8-Dev-src-build.png]]
 
 
 
===Exporting===
 
Then export the plugin to the ECLIPSEHOME/plugin directory (it will run next time Eclipse is restarted). It is best to delete the old plugin file (such as ''nescdt_0.0.13.jar'') and change the increment the version number of the new plugin :
 
 
 
[[Image:7-Dev-export.png]]
 
 
 
Finally verify that the plugin jar file is in the plugin directory as expected:
 
 
 
[[Image:9-Dev-plugin-eclipse-dir.png]]
 
 
 
==Contact==
 
If you have some light-weight suggestions for improvements: rup.inf(at)cbs.dk
 

Latest revision as of 01:04, 9 November 2009