Git Product home page Git Product logo

xs-embedded-llc / l2dbus Goto Github PK

View Code? Open in Web Editor NEW
10.0 6.0 2.0 696 KB

Lua-to-D-Bus (L2DBUS) is a Lua module that provides a *nearly* complete binding to the D-Bus IPC service. It is not, however, a complete re-implementation of the D-Bus protocol in Lua but instead leverages the tested D-Bus reference library which implements the lower-level protocol stack. What L2DBUS does provide, however, is access to lower-level features of D-Bus along with a higher level abstraction to make developing Lua D-Bus clients and services easier. These capabilities make it entirely feasible to re-implement a low level program like *dbus-monitor* in Lua as well more complex client/server applications. In this respect the Lua binding is similar to the popular D-Bus Python binding without the implicit GLib/GObject dependency. Hopefully L2DBUS strikes a balance between both low and high level APIs so that there really isn't any D-Bus related feature that is not available to the developer.

License: MIT License

CMake 3.89% Shell 0.28% Lua 48.71% C 46.78% C++ 0.34%

l2dbus's Introduction

Lua-to-D-Bus (L2DBUS) Library


Introduction

A gentle high-level introduction to the L2DBUS library can be found here.

Dependencies

L2DBUS uses the following external libraries and programs:

Linking will also pull in the math library (-lm).

To run some of the test programs a few additional Lua modules are used and required. These modules include:

Public Lua module documentation is generated using LDoc and internal documentation (currently very minimal) is generated mostly with Doxygen.

  • LDoc (Lua documentation)
  • Doxygen (Module 'C' code documentation)

Building

Before building L2DBUS all of it's dependencies must be built and installed in their proper locations.

Host Build

The L2DBUS build is based on CMake and a convenient script (build_host.sh) is provided to simplify the build process. So to build the library (once the dependencies are built and installed) execute:

# ./build_host.sh

An "debug" option can be specified as the first argument to make a debug version of the library:

# ./build_host.sh debug

Target Build

There is also a script to build a cross-compiled version of the library (build_target.sh). This needs to be modified for the particular build environment. In particular, a CMake toolchain file must be specifed (cmake.toolchain) which should be located in the top-level path defined by CMAKE_TOOLCHAIN_PATH_PREFIX. Furthermore a shell script (environment-setup), if present in the same toolchain path, will be sourced prior to building the target library. Additional details for cross-compiling under CMake can be found here.

Specifying the Lua Version

The L2DBUS module can be built against either the default version of Lua (5.1) or a specific version of Lua by setting the CMake variable L2DBUS_LUA_VERSION. For instance, to explicitly build against the 5.2 version of Lua the following option can be specified for either the host or target build script.

# ./build_host.sh -DL2DBUS_LUA_VERSION=5.2

The build will require this version of Lua to be present in the build environment or CMake will fail with an appropriate message.

Building Main Loop Back-ends

It is possible to control which main loop back-ends are built. By default, the build scripts will attempt to build all the main loop back-ends (libev and Glib). To disable a specific main loop back-end a CMake macro can be defined.

To disable the libev main loop the following CMake macro needs to be defined when generating the Makefile:

./build_host.sh -DL2DBUS_NO_LIBEV_LOOP=1

Likewise, to disable the Glib main loop pass the following macro to CMake:

./build_host.sh -DL2DBUS_NO_GLIB_LOOP=1

At least one main loop back-end must be built in order to effectively use L2DBUS. Also, be aware that the corresponding main loop back-end for the dependent CDBUS library must have also been built. The two libraries (L2DBUS and CDBUS) go together and their corresponding main loop back-ends must be consistent.

Installation

The library installation path prefix (for both host and/or target) can be modified by passing in a CMake variable on the command line:

# ./build_host.sh -DCMAKE_INSTALL_PREFIX=/usr/local

The default C-module (LUA_CMOD) installation path is set to

${CMAKE_INSTALL_PREFIX}/lib/lua/${L2DBUS_LUA_VERSION}

The default Lua module (LUA_LMOD) installation path is set to

${CMAKE_INSTALL_PREFIX}/share/lua/${L2DBUS_LUA_VERSION}

To install the library type:

# make install

To uninstall the library type:

# make uninstall

To generate public documention type:

# make pub-docs

To generate private internal documentation type:

# make priv-docs

To install the public documentation type:

# make install-docs

The public documentation is stored in the ${CMAKE_INSTALL_PREFIX}/share/doc/l2dbus directory.

The public documents can be uninstalled using either:

# make uninstall-docs

or

# make uninstall

Both options will remove the documentation while the last option (uninstall) removes the entire installation as well.

To generate a source distribution type:

# make dist-l2dbus

And of course to clean the build you can simply erase the build directory from the project root:

# rm -rf x86_64-Release

Documentation

Besides the introduction the only documentation available for L2DBUS is the Lua API documentation found here. Additionally, there are several test applications that demonstrate many of the features of the binding.

License

The L2DBUS library itself is licensed under the MIT License. See LICENSE in the source distribution for additional details. Additional terms may apply since L2DBUS does have other dependencies. The intent, however, was to utilize components that only have compatible licenses and support both open source and propriety (closed) source applications.

Known Issues / Caveats

There are several known issues or caveats to be aware of for this package:

  • Although this package compiles under Lua 5.2, it has not been tested or run under Lua 5.2. To date the primary development platform and system is Lua 5.1 based. It should work under Lua 5.2 but your mileage may vary. Please help us make the package better by providing feedback on any issues that are encountered when building/running L2DBUS under Lua 5.2 and/or LuaJIT.

  • This package contains a hack/kludge to work around a known Lua bug impacting load-able 'C' modules (e.g. shared libraries). Specifically, the bug impacts dynamically loaded modules with finalizers that may run at program termination. Prior to Lua 5.2.1 it is possible that the Lua GC may unload modules before all finalizers have had an opportunity run (and potentially call code that resides in those modules). This typically results in a segmentation fault when a program is terminating. For more information see the full bug report and Lua VM patch here. Since most people won't patch their Lua VM for one reason or another, a work-around was devised. This work-around has been tested under Linux but it should be applicable to MacOSX and Windows. Shared libraries under all these major platforms are reference counted when loaded. This means, for instance, under Linux dlopen() increments a reference and dlclose() decrements it. When Lua loads a C-module the reference is incremented by one. In order to prevent certain modules from being unloaded prematurely (e.g. the main loop modules for libev and Glib) each module internally loads themselves and thus increments the reference count. This means even though the Lua GC unloads these C-modules at program termination they won't actually be unmapped from memory until the entire program exits.

  • The order in which Lua 'C' modules are garbage collected and unloaded impacts the utilization of the Lua libev main loop. The Lua binding to libev allows you to either use the default main loop or instantiate a new one. These loops can be used to instantiate an L2DBUS libev-flavored main loop which is ultimately used by the Dispatcher object. Unfortunately, if an "instantiated" libev main loop is used (one created by a ev.Loop.new() call) during shutdown it's likely the Lua libev module has aleady been unloaded and the main loop destroyed (even if L2DBUS maintains a reference to it). This results in a libev assertion being fired when the application termiantes. To avoid this only the default Lua libev main loop should be passed to a L2DBUS libev-flavored Main Loop. The reason this works is because the default libev loop is static and is never destroyed prior to L2DBUS being unloaded by Lua. So, if you chose to borrow a main loop from Lua libev to be used by the L2DBUS main loop, choose the default one (ev.Loop.default) over one instantiated via ev.Loop.new().

  • It is possible to exceeded a D-Bus connection's maximum received size limit (default = 63 MByte) if a client/server pair are exchanging very large messages (e.g. payloads > 256KByte) very frequently. Realize, however, this is abusing the intent/purpose of D-Bus which is predominantly intended for use in command/control type applications and services with small messages. What happens is the Lua userdata objects that wraps D-Bus method call/return messages will only unreference a D-Bus message when the Lua userdata wrapper is collected by the Lua garbage collector (GC). If the Lua GC is not running frequently enough (compared to the incoming/outgoing rate of messages) then the number of "active" messages (from the D-Bus reference library's perspective) can pile up and exceed the connection maximum. At that point all communication over that connection stops. There are a couple potential work-arounds. One option is to manually invoke Lua's garbage collector periodically. Likewise it's possible to configure the garbage collector to run more frequently (see the Lua documentation) so that it runs constantly back-to-back after completing a mark-and-sweep. Another option is to increase the connection maximum size limit (this is configurable from Lua). It's also possible to ask the connection to estimate the number of bytes consumed by "active" messages and force a GC when it approaches an application specific threshold. The final option, of course, is to not abuse the D-Bus with huge messages.

l2dbus's People

Contributors

coldfix avatar gschmottlach-xse avatar kfurge-xse avatar

Stargazers

Easion avatar William Adams avatar Shaun Tierney avatar James Harris avatar  avatar  avatar Christian Ege avatar Alek Paunov avatar Tiago Cesar Katcipis avatar Tysen Moore avatar

Watchers

James Harris avatar James Cloos avatar  avatar  avatar Tysen Moore avatar  avatar

l2dbus's Issues

support for cqueues

I'm looking into using lua + dbus on project using heavily cqueues [1]. I'm wondering how big effort it would be to support cqueues as a main loop? Any pointers or documentation how to achieve this integration?

[1] https://github.com/wahern/cqueues

Could you update the codes for 3 compile error?

  1. Line 202 in CMakeLists.text
    pkg_check_modules(CDBUS_GLIB_PKG REQUIRED "cdbus-glib") should be changed into pkg_check_modules(CDBUS_GLIB_PKG REQUIRED "cdbus-glib>=1.0.0").
    Otherwise cdbus-glib can not be found.
  2. include "ev.h" should be deleted in L2dbus_watch.c,otherwise ev.h file can not be found in compling phase.

  3. #include "ev.h" should be deleted in L2dbus_dispatcher.c, otherwise ev.h file can not be found in compling phase.

one warning is that "intl can not be found", but it can not impact successful compile. It seems that intl package is not used to compile l2dbus. please have a check about producting l2dbus-glib.pc file which hintting to find intl package.

Thans a lot.

CMake cannot find lua

Hey,

When running the cmake configuration phase, I get the following error:

...
-- Searching for Lua 5.1
CMake Error at /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
  Could NOT find Lua: Found unsuitable version "", but required is at least
  "5.1" (found /usr/lib64/liblua.so;/usr/lib64/libm.so)
Call Stack (most recent call first):
  /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:372 (_FPHSA_FAILURE_MESSAGE)
  CMakeModules/FindLua.cmake:121 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:70 (find_package)

I'm running archlinux and have both lua51 and lua (52) installed.

I figured out, that the problem can be fixed by the following patch in CMakeLists.txt:

-find_package(Lua ${L2DBUS_LUA_VERSION} REQUIRED)
+find_package(Lua REQUIRED)

I was wondering if you have any experience with this issue and know a better fix?

Best regards,
Thomas

Incorrect DBus method call signature when writing to property using property setter of proxy object.

According to DBus specification on interface "org.freedesktop.DBus.Properties", the "Set" method of that interface has input argument signature of 'ssv'.

However, when writing to property using the proxy object's property setter, the constructed method call message has an extra 4th string argument, causing the signature of the generated method call message to be 'ssvs' rather than 'ssv'. This is caused by the call of msg:addArgs() at line 1032 of lua/l2dbus/proxyctrl.lua module:

                        local msg = l2dbus.Message.newMethodCall({destination=ctrl.busName,
                                                        path=ctrl.objPath,
                                                        interface=l2dbus.Dbus.INTERFACE_PROPERTIES,
                                                        method="Set"})
                        if not msg then
                                error("unable to create D-Bus method call message")
                        end

                        msg:addArgsBySignature("s", metadata.interface)
                        msg:addArgsBySignature("s", propName)
                        msg:addArgs(l2dbus.DbusTypes.Variant.new(value), "v" .. propInfo.sig)

This additional 4th argument, the string of "v" .. propInfo.sig, can cause unexpected error under certain server implementation having stricter method call signature checking, such as getting "unknown method" error when using the setter to write to either the "Powered" property of an adapter of bluez 5, or the "Title" property of the GLib's GDBus example gdbus-example-server.c. Removing the 4th argument using the following patch seems to get rid of this issue:

diff --git a/lua/l2dbus/proxyctrl.lua b/lua/l2dbus/proxyctrl.lua
index 9da0a6b..632fd94 100644
--- a/lua/l2dbus/proxyctrl.lua
+++ b/lua/l2dbus/proxyctrl.lua
@@ -1029,7 +1029,7 @@ newPropertyProxy = function(proxyCtrl, metadata)
 			
 			msg:addArgsBySignature("s", metadata.interface)
 			msg:addArgsBySignature("s", propName)
-			msg:addArgs(l2dbus.DbusTypes.Variant.new(value), "v" .. propInfo.sig)
+			msg:addArgsBySignature("v", value)
 			local reply = nil
 			local errName = nil
 			local errMsg = nil

A compile error in configuring phase

error is below:
Re-run cmake file: Makefile older than: CMakeCache.txt

-- l2dbus building as Release
-- Searching for Lua 5.1
-- Found Lua version 5.1.5
-- ldoc not found - will not be able to generate public API docs.
-- checking for module 'cdbus-glib'
-- package 'cdbus-glib' not found
CMake Error at /FindPkgConfig.cmake:279 (message):
A required package was not found
Call Stack (most recent call first):
/home/guoxinghua/perforce_codes/OTV_OS/Opentv5/MAIN/otvtarg/hdt7231_uclibc_bc/sdk_all/host/usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:333 (_pkg_check_modules_internal)
CMakeLists.txt:202 (pkg_check_modules)

It seems that cdbus-glib is can not be found to configure makefile. But in fact I have compile cdbus earlier. And cdbus-glib.so files can be seen in some places.

Could you tell me that which folder is used to look for cdbus-glib when configuring the makefile?

error when require("l2dbus_glib")

Hi,
I met a error when I run a lua test codes like below:

!/usr/bin/env lua

local state = require("utils.luastate")
local pretty = require("pl.pretty")
local l2dbus = require("l2dbus")
local test1 = require("l2dbus_core")
local test = require("l2dbus_glib")

When require("l2dbus_glib") is called, error "Segmentation fault (core dumped)" will be seen. Actually /usr/lib/lua/5.1/l2dbus_glib.so and /usr/lib/lua/5.1/l2dbus_core.so can be seen , it means l2dbus is installed well.

Why can require("l2dbus_core") well and will require("l2dbus_glib") cause some error ?
Any advice?

Thanks a lot!

Porting of l2dbus onto openwrt-x86

Hello,
I am trying to port l2dbus and their dependencies onto openwrt-x86. For that i am using i486-openwrt-linux-gcc toolchain.
i created cmake.toolchain with following lines:
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER i486-openwrt-linux-gcc)
SET(CMAKE_CXX_COMPILER i486-openwrt-linux-g++)

I exported following environment variables:
export OPENWRT_SOURCE=/home/sachin/OPENWRT
export STAGING_DIR=$OPENWRT_SOURCE/staging_dir
export TOOLCHAIN_DIR=$STAGING_DIR/toolchain-i386_i486_gcc-4.8-linaro_uClibc-0.9.33.2
export PATH=$TOOLCHAIN_DIR/bin:$PATH
export PREFIX_PATH=$STAGING_DIR/host

I installed the all dependencies in this PREFIX_PATH.
Then i did run the ./build_target -DCMAKE_INSTALL_PREFIX=$PREFIX_PATH
after this we got folllowing log:
_log_*************
-- The C compiler identification is unknown
-- Check for working C compiler: i486-openwrt-linux-gcc
CMake Error: your C compiler: "i486-openwrt-linux-gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working C compiler: i486-openwrt-linux-gcc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "i486-openwrt-linux-gcc" is not able to compile a simple
test program.

It fails with the following output:

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (PROJECT)

CMake Error: your C compiler: "i486-openwrt-linux-gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
-- Configuring incomplete, errors occurred!
See also "/home/sachin/IOTAP/BUILD/cdbus-master/armv7l-Release/CMakeFiles/CMakeOutput.log".
See also "/home/sachin/IOTAP/BUILD/cdbus-master/armv7l-Release/CMakeFiles/CMakeError.log".
sachin:cdbus-master$ . ../config.conf
sachin:cdbus-master$ ./build_target.sh
Target environment may not be set up properly!

Build target not found - assuming default (armv7l)
==> Running cmake for armv7l-Release . . .

-- The C compiler identification is GNU 4.8.3
-- Check for working C compiler: /home/sachin/IOTAP/barrier_breaker/staging_dir/toolchain-i386_i486_gcc-4.8-linaro_uClibc-0.9.33.2/bin/i486-openwrt-linux-gcc
-- Check for working C compiler: /home/sachin/IOTAP/barrier_breaker/staging_dir/toolchain-i386_i486_gcc-4.8-linaro_uClibc-0.9.33.2/bin/i486-openwrt-linux-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done

-- cdbus building as Release
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'dbus-1>=1.4.0'
-- found dbus-1, version 1.6.18
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.6")
-- checking for module 'ev'
-- package 'ev' not found
-- Will link with libev found here: /usr/local/lib/libev.so
-- LIBEV_PKG_INCLUDE_DIRS: /usr/local/include
-- LIBEV_PKG_LIBRARY_DIRS: /usr/local/lib
-- checking for module 'glib-2.0>=2.0.0'
-- found glib-2.0, version 2.38.2

-- Compile cdbus using: make
-- Install cdbus using: make install
-- Uninstall cdbus using: make uninstall
-- Compile public API documentation using: make pub-docs
-- Install public API documentation using: make install-docs
-- Uninstall public API documentation using: make uninstall-docs
-- Create cdbus source distribution using: make dist-cdbus
-- (be sure to set the correct CMAKE_INSTALL_PREFIX before)

-- Configuring done
-- Generating done
-- Build files have been written to: /home/sachin/IOTAP/BUILD/cdbus-master/armv7l-Release
Scanning dependencies of target CDBUS_MAIN_LOOP_EV_STATIC
[ 2%] Building C object CMakeFiles/CDBUS_MAIN_LOOP_EV_STATIC.dir/src/main-loop/main-loop-ev.c.o
Linking C static library lib/libcdbus-ev.a
[ 2%] Built target CDBUS_MAIN_LOOP_EV_STATIC
Scanning dependencies of target CDBUS_STATIC
[ 4%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/condvar-posix.c.o
[ 6%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/timeout-priv.c.o
[ 8%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/atomic-ops.c.o
[ 10%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/object-priv.c.o
[ 12%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/interface-priv.c.o
[ 14%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/trace.c.o
[ 16%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/watch-priv.c.o
[ 18%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/dbus-watch-ctrl.c.o
[ 20%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/introspect-priv.c.o
[ 22%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/dbus-timeout-ctrl.c.o
[ 25%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/dispatcher-priv.c.o
[ 27%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/string-pointer-map.c.o
[ 29%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/alloc.c.o
[ 31%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/pipe-posix.c.o
[ 33%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/init.c.o
[ 35%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/connection-priv.c.o
[ 37%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/mutex-posix.c.o
[ 39%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/match.c.o
[ 41%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/pointer-pointer-map.c.o
[ 43%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/stringbuffer.c.o
[ 45%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/semaphore-posix.c.o
[ 47%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/object-registry.c.o
Linking C static library lib/libcdbus.a
[ 47%] Built target CDBUS_STATIC
Scanning dependencies of target CDBUS_SHARED
[ 50%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/condvar-posix.c.o
[ 52%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/timeout-priv.c.o
[ 54%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/atomic-ops.c.o
[ 56%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/object-priv.c.o
[ 58%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/interface-priv.c.o
[ 60%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/trace.c.o
[ 62%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/watch-priv.c.o
[ 64%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/dbus-watch-ctrl.c.o
[ 66%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/introspect-priv.c.o
[ 68%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/dbus-timeout-ctrl.c.o
[ 70%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/dispatcher-priv.c.o
[ 72%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/string-pointer-map.c.o
[ 75%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/alloc.c.o
[ 77%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/pipe-posix.c.o
[ 79%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/init.c.o
[ 81%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/connection-priv.c.o
[ 83%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/mutex-posix.c.o
[ 85%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/match.c.o
[ 87%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/pointer-pointer-map.c.o
[ 89%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/stringbuffer.c.o
[ 91%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/semaphore-posix.c.o
[ 93%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/object-registry.c.o
Linking C shared library lib/libcdbus.so
/home/sachin/IOTAP/barrier_breaker/staging_dir/toolchain-i386_i486_gcc-4.8-linaro_uClibc-0.9.33.2/lib/gcc/i486-openwrt-linux-uclibc/4.8.3/../../../../i486-openwrt-linux-uclibc/bin/ld: cannot find -ldbus-1
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libcdbus.so.] Error 1
make[1]: *** [CMakeFiles/CDBUS_SHARED.dir/all] Error 2
make: *** [all] Error 2

_end of log_*

When i did export of PKG_CONFIG_PATH that got compiled and did build libraries correctly.
export PKG_CONFIG_PATH=$PREFIX_PATH/lib/pkgconfig
but the log i seen is:
***_log2_
-- The C compiler identification is GNU 4.8.3
-- Check for working C compiler: /home/sachin/IOTAP/barrier_breaker/staging_dir/toolchain-i386_i486_gcc-4.8-linaro_uClibc-0.9.33.2/bin/i486-openwrt-linux-gcc
-- Check for working C compiler: /home/sachin/IOTAP/barrier_breaker/staging_dir/toolchain-i386_i486_gcc-4.8-linaro_uClibc-0.9.33.2/bin/i486-openwrt-linux-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done

-- cdbus building as Release
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'dbus-1>=1.4.0'
-- found dbus-1, version 1.8.6
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.6")
-- checking for module 'ev'
-- package 'ev' not found
-- Will link with libev found here: /usr/local/lib/libev.so
-- LIBEV_PKG_INCLUDE_DIRS: /usr/local/include
-- LIBEV_PKG_LIBRARY_DIRS: /usr/local/lib
-- checking for module 'glib-2.0>=2.0.0'
-- found glib-2.0, version 2.41.1

-- Compile cdbus using: make
-- Install cdbus using: make install
-- Uninstall cdbus using: make uninstall
-- Compile public API documentation using: make pub-docs
-- Install public API documentation using: make install-docs
-- Uninstall public API documentation using: make uninstall-docs
-- Create cdbus source distribution using: make dist-cdbus
-- (be sure to set the correct CMAKE_INSTALL_PREFIX before)

-- Configuring done
-- Generating done
-- Build files have been written to: /home/sachin/IOTAP/BUILD/cdbus-master/armv7l-Release
Scanning dependencies of target CDBUS_MAIN_LOOP_EV_STATIC
[ 2%] Building C object CMakeFiles/CDBUS_MAIN_LOOP_EV_STATIC.dir/src/main-loop/main-loop-ev.c.o
Linking C static library lib/libcdbus-ev.a
[ 2%] Built target CDBUS_MAIN_LOOP_EV_STATIC
Scanning dependencies of target CDBUS_STATIC
[ 4%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/condvar-posix.c.o
[ 6%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/timeout-priv.c.o
[ 8%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/atomic-ops.c.o
[ 10%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/object-priv.c.o
[ 12%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/interface-priv.c.o
[ 14%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/trace.c.o
[ 16%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/watch-priv.c.o
[ 18%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/dbus-watch-ctrl.c.o
[ 20%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/introspect-priv.c.o
[ 22%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/dbus-timeout-ctrl.c.o
[ 25%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/dispatcher-priv.c.o
[ 27%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/string-pointer-map.c.o
[ 29%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/alloc.c.o
[ 31%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/pipe-posix.c.o
[ 33%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/init.c.o
[ 35%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/connection-priv.c.o
[ 37%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/mutex-posix.c.o
[ 39%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/match.c.o
[ 41%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/pointer-pointer-map.c.o
[ 43%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/stringbuffer.c.o
[ 45%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/semaphore-posix.c.o
[ 47%] Building C object CMakeFiles/CDBUS_STATIC.dir/src/object-registry.c.o
Linking C static library lib/libcdbus.a
[ 47%] Built target CDBUS_STATIC
Scanning dependencies of target CDBUS_SHARED
[ 50%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/condvar-posix.c.o
[ 52%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/timeout-priv.c.o
[ 54%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/atomic-ops.c.o
[ 56%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/object-priv.c.o
[ 58%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/interface-priv.c.o
[ 60%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/trace.c.o
[ 62%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/watch-priv.c.o
[ 64%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/dbus-watch-ctrl.c.o
[ 66%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/introspect-priv.c.o
[ 68%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/dbus-timeout-ctrl.c.o
[ 70%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/dispatcher-priv.c.o
[ 72%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/string-pointer-map.c.o
[ 75%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/alloc.c.o
[ 77%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/pipe-posix.c.o
[ 79%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/init.c.o
[ 81%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/connection-priv.c.o
[ 83%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/mutex-posix.c.o
[ 85%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/match.c.o
[ 87%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/pointer-pointer-map.c.o
[ 89%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/stringbuffer.c.o
[ 91%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/semaphore-posix.c.o
[ 93%] Building C object CMakeFiles/CDBUS_SHARED.dir/src/object-registry.c.o
Linking C shared library lib/libcdbus.so
[ 93%] Built target CDBUS_SHARED
Scanning dependencies of target CDBUS_MAIN_LOOP_EV_SHARED
[ 95%] Building C object CMakeFiles/CDBUS_MAIN_LOOP_EV_SHARED.dir/src/main-loop/main-loop-ev.c.o
Linking C shared library lib/libcdbus-ev.so
[ 95%] Built target CDBUS_MAIN_LOOP_EV_SHARED
Scanning dependencies of target CDBUS_MAIN_LOOP_GLIB_STATIC
[ 97%] Building C object CMakeFiles/CDBUS_MAIN_LOOP_GLIB_STATIC.dir/src/main-loop/main-loop-glib.c.o
Linking C static library lib/libcdbus-glib.a
[ 97%] Built target CDBUS_MAIN_LOOP_GLIB_STATIC
Scanning dependencies of target CDBUS_MAIN_LOOP_GLIB_SHARED
[100%] Building C object CMakeFiles/CDBUS_MAIN_LOOP_GLIB_SHARED.dir/src/main-loop/main-loop-glib.c.o
Linking C shared library lib/libcdbus-glib.so
[100%] Built target CDBUS_MAIN_LOOP_GLIB_SHARED
_end of log2_****

so after successful building i copied all libraries to my openwrt root file system. Then i tried to run one script which requires this l2bus_core.so library.its giving following error:
lua:symbol 'pthread_mutexatttr_destroy' : can't resolve symbol in lib /usr/lib/libcdbus.so.1
lua:error loading module "l2dbus_core" from file l2dbus_core.so

Can anybody help me to overcome this issue?

addArgsBySignature() method of l2dbus.Message namespace seems to ignore l2dbus.DbusTypes wrapping class when adding arguments of composite types such as variant (and dictionary if dictionary value is of variant type).

While constructing a message using the addArgsBySignature() method, if the argument is one of the composite types having other types of data embedded within, such as the type of variant and dictionary, even if the embedded data was wrapped with one of the l2dbus.DbusTypes wrapping class, addArgsBySignature() seems to ignore the wrapping class and compute the signature directly from the value of the wrapping class. This could cause some problem when the embedded data must be unsigned integers, since eventually the l2dbus_calcDbusNumType() function in l2dbus_transcode.c maps non-negative Lua number to DBUS_TYPE_INT32 if the value is less then INT32_MAX. This is the reason why my first patch to #9 does not work correctly under certain circumstances.

To demonstrate this issue, consider the following testing script msgtest2.lua:

#!/usr/bin/env lua
-- msgtest2.lua

local l2dbus = require('l2dbus')
local proxyctrl = require('l2dbus.proxyctrl')
local mainloop = require('l2dbus_ev')

local conn, disp, proxyCtrl, proxy, msg
local status

local INT32_MAX = 2147483647

local testData = {
	DICTIONARY1 = { int32_1 = 1, uint32_1 = 2 },
	DICTIONARY2 = { int32_2 = l2dbus.DbusTypes.Int32.new(3), uint32_2 = l2dbus.DbusTypes.Uint32.new(4) },
	DICTIONARY3 = { int32_3 = l2dbus.DbusTypes.Int32.new(INT32_MAX + 1), uint32_3 = l2dbus.DbusTypes.Uint32.new(INT32_MAX + 2) }
}

disp = l2dbus.Dispatcher.new(mainloop.MainLoop.new())
assert(disp ~= nil)
conn = l2dbus.Connection.openStandard(disp, l2dbus.Dbus.BUS_SESSION)
assert(conn ~= nil)
proxyCtrl = proxyctrl.new(conn, l2dbus.Dbus.SERVICE_DBUS, l2dbus.Dbus.PATH_DBUS)
assert(proxyCtrl ~= nil)
proxyCtrl:bind()
proxyCtrl:setBlockingMode(true)
proxy = proxyCtrl:getProxy(l2dbus.Dbus.INTERFACE_DBUS)
assert(proxy ~= nil)

for k, v in pairs(testData) do
	msg = l2dbus.Message.newSignal("/org/test", "org.test.interface", "TestSignal")
	print("Try to send variant with embedded lua type '" .. k .. "'")
	msg:addArgsBySignature("a{sv}", v)
	status = conn:send(msg)
	print("Signal sent: " .. ((status == true) and "success" or "fail"))
end

In the script, three dictionaries of signature 'a{sv}' are prepared, and two of them wraps the values using l2dbus.DbusTypes to try to enforce the signature of the embedded data. To verify the converted D-Bus type in the actual message, the following dbus-monitor command is issued before executing the script:

$ dbus-monitor --session "type=signal,path='/org/test'"

Now the output of the script:

$ ./msgtest2.lua 
Try to send variant with embedded lua type 'DICTIONARY3'
Signal sent: success
Try to send variant with embedded lua type 'DICTIONARY1'
Signal sent: success
Try to send variant with embedded lua type 'DICTIONARY2'
Signal sent: success

And also the corresponding dbus-monitor output:

$ dbus-monitor --session "type=signal,path='/org/test'"
signal sender=org.freedesktop.DBus -> dest=:1.3320 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.3320"
signal sender=:1.3321 -> dest=(null destination) serial=3 path=/org/test; interface=org.test.interface; member=TestSignal
   array [
      dict entry(
         string "int32_3"
         variant             uint32 2147483648
      )
      dict entry(
         string "uint32_3"
         variant             uint32 2147483649
      )
   ]
signal sender=:1.3321 -> dest=(null destination) serial=4 path=/org/test; interface=org.test.interface; member=TestSignal
   array [
      dict entry(
         string "uint32_1"
         variant             int32 2
      )
      dict entry(
         string "int32_1"
         variant             int32 1
      )
   ]
signal sender=:1.3321 -> dest=(null destination) serial=5 path=/org/test; interface=org.test.interface; member=TestSignal
   array [
      dict entry(
         string "uint32_2"
         variant             int32 4
      )
      dict entry(
         string "int32_2"
         variant             int32 3
      )
   ]

As shown in the dbus-monitor output, for DICTIONARY1 and DICTIONARY2, no matter if the values were wrapped with l2dbus.DbusTypes class or not, the converted type in the constructed message is always int32 since the value is far less than INT32_MAX (2147483647). For DICTIONARY3, the value of the key "int32_3" should, in theory, generates an error/exception since the value is one larger than the allowed range, but there is no exception during conversion and both entries of DICTIONARY3 are converted to uint32 for they both are larger than INT32_MAX.

This issue could have some real world impact when, for example, writing an application registering new profile to the bluetoothd daemon of BlueZ 5. When calling the RegisterProfile(object profile, string uuid, dict options) method of the org.bluez.ProfileManager1 interface, two of the options in the third argument, the "Channel" and "PSM" options", are restricted to be of type "uint16". If calling the method using proxy object for the interface under current implementation, which constructs the method call message using the introspect data with the addArgsBySignature() behind the scene, these two options would be rejected by bluetoothd for signature mismatch:

bluetoothd[1925]: Invalid value for profile option PSM
bluetoothd[1925]: Invalid value for profile option Channel

And since addArgsBySignature() currently ignores the wrapping classes, there is no way to enforce the conversion of those two values to uint16 even wrapping them with l2dbus.DbusTypes.Uint16.new().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.