Forum > Packages and Libraries

[solved] not compiling with dbus

(1/3) > >>

chrigr:
Hi Folks,

there is an old project, which needs a dbus-integration. The project itself compiles as always on:

- Lazarus 1.2.4 with FPC 2.6.4  Raspbian Jessy (I believe)
- Lazarus 1.8.2 with FPC 3.0.0 (via apt-get) on Raspbian Stretch 
- Lazarus 2.0.0 RC3 with FPC 3.0.4  (self compiled) on Raspbian Stretch

As soon as I try to compile my project with the inclusion of "dbus" - I get a linking error EXCEPT on the old system!
Problem is: I have to use the new Raspian as the software im intending to communicate over dbus with requires Qt5

Can somebody please try to compile the example code from https://github.com/graemeg/freepascal/blob/master/packages/dbus/examples/busexample.pp on a Raspberry 3 with raspbian and tell me if it compiles for them?
I'm starting to get grey hair over this issue.

Or is "dbus" already deprecated?
Is there an alternative? Am I missing something?

chrigr:
no luck so far.

Could anybody just do me a small favor and try to compile a FPC-Project using a recent lazarus and FPC installation - and tell me if the inclusion of the "dbus" package into the main does anything unusual for them? Not necessarily on an ARMHF Linux - whatever you usually run on.

would be great, thanks!

Thaddy:
I got it working after I did this (mind the path and the sudo, but you probably have the same configuration as me!)

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---pi@raspberrypi:/lib/arm-linux-gnueabihf $ sudo cp libdbus-1.so.3 libdbus-1.soAfter that the code compiles as before.

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---fpc  -Fl/usr/lib/gcc/arm-linux-gnueabihf/6.3.0 -Fu/usr/local/lib/fpc/3.3.1/units/* -Fi/home/pi/synapse/* -CX -XXs -O4 "busexample.pas" (in directory: /home/pi)Free Pascal Compiler version 3.3.1-r41411 [2019/02/22] for armCopyright (c) 1993-2018 by Florian Klaempfl and othersTarget OS: Linux for ARMHFCompiling busexample.pasbusexample.pas(134,49) Warning: Local variable "sigvalue" does not seem to be initializedbusexample.pas(194,8) Note: Local variable "reply" not usedbusexample.pas(195,3) Note: Local variable "args" not usedbusexample.pas(196,3) Note: Local variable "param" not usedbusexample.pas(323,43) Warning: Local variable "level" does not seem to be initializedbusexample.pas(323,30) Warning: Local variable "stat" does not seem to be initializedLinking busexample358 lines compiled, 1.2 sec3 warning(s) issued3 note(s) issuedCompilation finished successfully. Note those warnings need to be fixed....

And I should actually have created a symlink instead, but this also works (it is a copy of the symlink  8-) O:-) )

There's probably a bit more to do given this:

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Syntax: dbus-example [send|receive|listen|query] [<param>]process 3376: Applications must not close shared connections - see dbus_connection_close() docs. This is a bug in the application.
But on correct use it works without that message from dbus.

I already fixed the warnings, but after I fix (2) above I will submit a patch.

But if you do a cp as per my first you'll be fine.

Thaddy:
I noticed you didn't tell the whole  truth btw < >:D>  ;D :D

--- Quote ---here is an old project, which needs a dbus-integration. The project itself compiles as always on:

- Lazarus 1.2.4 with FPC 2.6.4  Raspbian Jessy (I believe)
- Lazarus 1.8.2 with FPC 3.0.0 (via apt-get) on Raspbian Stretch 
- Lazarus 2.0.0 RC3 with FPC 3.0.4  (self compiled) on Raspbian Stretch

--- End quote ---
true  "- Lazarus 1.2.4 with FPC 2.6.4  Raspbian Jessy (I believe)"
false "- Lazarus 1.8.2 with FPC 3.0.0 (via apt-get) on Raspbian Stretch" 
false "- Lazarus 2.0.0 RC3 with FPC 3.0.4  (self compiled) on Raspbian Stretch"
 
It fails because the default so symlink is missing on stretch, not because a bug on the Freepascal side... as proven by my solution. Be more careful in the future....
You can file a bug report to that extend to Raspbian if you wish.
Did you do a re-install or apt-get dist-upgrade in the mean time? A dist-upgrade would leave the default symlink, but a re-install removes it. (both of them will fail, since the symlink points to oblivion afakt)

chrigr:
Thanks for your help!
I got it running.


Regarding my text:
My old code was compiling with all those configs.

But as soon as I included "dbus" (to my old code) it only compiled on my old config


Im running in a different problem now, it seems to be a more general dbus issue.
I can't append a boolean to a dbus message.



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure BusCall(value1: LongWord; value2: Boolean);var  err: DBusError;  conn: PDBusConnection;  msg: PDBusMessage;  args: DBusMessageIter;  pending: PDBusPendingCall; begin   msg := dbus_message_new_method_call(TARGET,                                      PATH,                                      DBINTERFACE,                                      METHODNAME);       dbus_message_iter_init_append(msg, @args);    if (dbus_message_iter_append_basic(@args, DBUS_TYPE_UINT32, @value1) = 0) then  begin    F_main.Label8.Caption:='Could not append Value1';    Exit;  end;  if (dbus_message_iter_append_basic(@args, DBUS_TYPE_BOOLEAN, @value2) = 0) then  begin    F_main.Label8.Caption:='Could not append Value2';    Exit;  end; 
This code works if I use two UINT32 but as soon as I try to append the Boolean it exits.

In general everything is working nicely, i can communicate over the dbus and have startet rewriting the sample code for my purposes. But I somehow need to get this Boolean in there to call a specific method.


In another part of the example code they are appending an boolean - so my general path seems to be correct:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---rocedure reply_to_method_call(msg: PDBusMessage; conn: PDBusConnection);var  reply: PDBusMessage;  args: DBusMessageIter;  stat: Boolean = true;  level: dbus_uint32_t = 21614;  serial: dbus_uint32_t = 0;  param: PChar = '';begin   // read the arguments   if (dbus_message_iter_init(msg, @args) = 0) then      WriteLn('Message has no arguments!')   else if (DBUS_TYPE_STRING <> dbus_message_iter_get_arg_type(@args)) then      WriteLn('Argument is not string!')   else      dbus_message_iter_get_basic(@args, @param);    WriteLn('Method called with ', param);    // create a reply from the message   reply := dbus_message_new_method_return(msg);    // add the arguments to the reply   dbus_message_iter_init_append(reply, @args);   if (dbus_message_iter_append_basic(@args, DBUS_TYPE_BOOLEAN, @stat) = 0) then   begin     WriteLn('Out Of Memory!');     Exit;   end;   if (dbus_message_iter_append_basic(@args, DBUS_TYPE_UINT32, @level) = 0) then   begin     WriteLn('Out Of Memory!');     Exit;   end;          



I also tried using

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---dbus_message_append_args()as described here:
https://dbus.freedesktop.org/doc/api/html/group__DBusMessage.html#ga591f3aab5dd2c87e56e05423c2a671d9

And it should be as easy as that:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---dbus_message_append_args (msg,                          DBUS_TYPE_UINT32, @value1,                          DBUS_TYPE_BOOLEAN, @value2,                          DBUS_TYPE_INVALID);  

buuuuuuuut:

--- Quote ---busexample.pas(297,1) Error: Wrong number of parameters specified for call to "dbus_message_append_args"
busexample.pas(498) Fatal: There were 1 errors compiling module, stopping

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version