navit-project.org

forum for navit navigation tool
It is currently 26 Jun 2017, 06:55
View unanswered posts | View active topics


All times are UTC


Forum rules


Feel free to ask anything here related to the development process - coding, creating new features, fixing bugs and custom changes of Navit.

Note: For reporting bugs, use the bug tracker.



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Plugin development: how-to for newbies
PostPosted: 14 Jun 2013, 12:36 
Offline

Joined: 14 Jun 2013, 12:09
Posts: 10
hey,

i try to develop a plugin for navit. But the article about plugins on the wiki did not realy help me.
I think i need a step-by-step instruction for building a plugin.

For example I want to know:
- which Makefiles/CMakeLists.txt I have to change?
- where to store my code?
- how to compile to get changes active?
- how to access the plugin?
- what about changing plugin.c/plugin.h/plugin_def.h?

I think having a easy to use and unterstand "how-to develop plugins" is very important to make navit even more atractive for external developers. Further more a download area for navit-plugins would be very cool, so one could customize navit for users purpose (not only by changing the apearance with navit.xml).
For this purpose one could maybe orientatet on http://eli.thegreenplace.net/2012/08/24/plugins-in-c/. There he tries to explain in a very general way how to use plugins in c.
But these are only some big ideas. I'm thankfull for any help.

thanks in advance


 Profile  
 
 Post subject: Re: Plugin development: how-to for newbies
PostPosted: 15 Jun 2013, 08:25 
Offline
User avatar

Joined: 07 Jun 2013, 17:13
Posts: 146
Location: Tartu, Estonia
Having a better documentation for plugin development is certainly a good idea. I don't know completely how to o this, but let me try to answer some of your questions.

Lusipa wrote:
- which Makefiles/CMakeLists.txt I have to change?

I don't know anything about CMake, since I'm used only to autotools (unfortunately support for this will be removed sooner or later, so one has to deal with CMake). In plugin/Makefile.am I would add the following lines before DIST_SUBDIRS=...:
Code:
if PLUGIN_MYPLUGIN
  SUBDIRS += myplugin
endif

Further, add "myplugin" to the end of the DIST_SUBDIRS=... line (separated with space). Maybe someone can explain how to add the plugin to the CMake part as well.
Lusipa wrote:
- where to store my code?

In my example above I called the plugin MYPLUGIN and the place, where the code should be stored, would be a subfolder of "plugin" in the Navit source tree, which I called myplugin. Of course you can choose any name.
Lusipa wrote:
- how to compile to get changes active?

Are you familiar with compiling Navit in general? I think one also needs to add something to the top level build configuration, so that a variable named PLUGIN_MYPLUGIN is set when you configure Navit with --enable-plugin-myplugin, but I don't see right now, where to do this.
Lusipa wrote:
- how to access the plugin?

For this you need to add this to your navit.xml, where you can find similar plugin lines:
Code:
<plugin path="$NAVIT_LIBDIR/*/${NAVIT_LIBPREFIX}libmyplugin.so" active="yes"/>


 Profile  
 
 Post subject: Re: Plugin development: how-to for newbies
PostPosted: 19 Jun 2013, 12:13 
Offline

Joined: 14 Jun 2013, 12:09
Posts: 10
thank you very much, for your fast answer.
but unfortunatly this does not work for me... i guess it is still my fault, since i dont ḱnow much about plugins and navit...maybe, it is also because i dont know how to activate/call my plugin, during navit is running, because compilation works well. maybe someone can tell me how this works.
so maybe an example plugin could also help me understanding how to write an own plugin.
thx for any hint


 Profile  
 
 Post subject: Re: Plugin development: how-to for newbies
PostPosted: 19 Jun 2013, 14:30 
Offline
User avatar

Joined: 07 Jun 2013, 09:32
Posts: 200
Location: Rostock, North Germany
Could you please provide us a detailed (higher debug level) startup log of your instance starting?

And no, I guess it's more our fault, as we can't currently provide a good plugin doc ;)


 Profile  
 
 Post subject: Re: Plugin development: how-to for newbies
PostPosted: 20 Jun 2013, 13:01 
Offline

Joined: 14 Jun 2013, 12:09
Posts: 10
actually i think that my plugin is recognized now, because if i have a syntax error in myplugin.c the compiler tells me about this error.

But i still dont know, how i can call my plugin while navit is running to do something. e.g. to print a simple cmd-line output.
Refering to http://eli.thegreenplace.net/2012/08/24/plugins-in-c/ i'm looking for a file/function which manages the plugins. Which tells them when and where to hook into navits running process.

I cut the debug log file, because its size was to large to load it up... i cut only one large part in the middle where the word "plugin" isn't mentioned
(if debug level 2 is not detailed enough for you, or you need a not cut debug log file, tell me)


Attachments:
File comment: debug log with debug level = 2
debug_log_global_level_2_snipped.txt [150.26 KiB]
Downloaded 239 times
File comment: cmd-line output from make
make_log.txt [74.69 KiB]
Downloaded 228 times
File comment: cmd-line output from cmake
cmake_log.txt [11.01 KiB]
Downloaded 243 times
 Profile  
 
 Post subject: Re: Plugin development: how-to for newbies
PostPosted: 21 Jun 2013, 14:38 
Offline

Joined: 14 Jun 2013, 12:09
Posts: 10
thanks to xenos1984 i finaly became an comand-line-output from my own plugin called "my_plugin.c"

first of all you have to edit the file "navit/CMakeList.txt" (Attention: not "navit/navit/CMakeList.txt"):
In line 374 under the comment "#Modules without test yet" i added:
Code:
"add_module(plugin/my_plugin "Default" TRUE)"


Now you need to edit "navit/navit/navit_shipped.xml":
in line 16, somewhere between "<plugin> ...</plugin>" add the line:
Code:
<plugin path="$NAVIT_LIBDIR/*/${NAVIT_LIBPREFIX}libplugin_my_plugin.so" active="yes"/>


Now you're able to create your plugin file.
You should store it in the folder "navit/navit/plugin/my_plugin"
here i copied the code from the wikis plugin page

Code:
void plugin_register_something_type(){
        printf("\n\nMy Plugin is now plugged!!!\n\n");
}

void
plugin_init(void)
{
        plugin_register_something_type();
}


you should also create a "Makefile.am" in the same folder, which should look like (derived from "/navit/navit/plugin/pedestrian/Makefile.am):
Code:
include $(top_srcdir)/Makefile.inc
AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/navit -DMODULE=plugin_my_plugin
moduleplugin_LTLIBRARIES = libplugin_my_plugin.la
libplugin_my_plugin_la_LDFLAGS=-module -avoid-version @NAVIT_MODULE_LDFLAGS@ #-Wl,--no-undefined

libplugin_my_plugin_la_SOURCES = my_plugin.c

android: libplugin_my_plugin.la
        cp .libs/libplugin_my_plugin.so ../../android/libs/armeabi
xslt:
        cp *.xslt ../../xslt


And also a file called "CMakeLists.txt" with following content:
Code:
module_add_library(plugin_my_plugin my_plugin.c)


Now we go one folder backwards and adapt there the "navit/navit/plugin/Makefile.am", too:
Code:
SUBDIRS=
if PLUGIN_PEDESTRIAN
  SUBDIRS += pedestrian
endif

if PLUGIN_MY_PLUGIN
  SUBDIRS += my_plugin
endif

DIST_SUBDIRS=pedestrian my_plugin


If you build Navit now from the source (with cmake and make) you should get a comand-line output when starting ./navit

Now I'll look for a way how to access my plugin at a certain while navit is running.
... if i new something new, i'll edit this post.
help welcome. thx.


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Silver Orange 2.0.6 for IPB Designed by Skins and Hosting
Converted for phpBB3, based on Royal Blue template by BigB © 2007 2008 AEON KINGS