Implement dbus-send command
I'm a newbie here and I would like to use your d-bus library. I wanted to implement the following call with node-dbus, but I couldn't get it to a successful run:
dbus-send --print-reply --type=method_call --bus='unix:path=/var/run/dbus/my_bus_socket' --dest='de.my.Device' '/de/my/Device/alarm' de.my.common.Alarm.get_alarm_state
Could you give me a hint on how to do it?
Thanks in advance!
var dbus = require('dbus-native');
var bus = dbus.sessionBus({socket: '/var/run/dbus/my_bus_socket'});
bus.invoke({
destination: 'de.my.Device',
path: '/de/my/Device/alarm',
interface: 'de.my.common.Alarm',
member: 'get_alarm_state'
}, function(err, param1, param2, param3) {
// you get as much parameters here as your response signature indicate
});
Does the current version run with Node 0.12.0?
I need to check binary abstractsocket module status but if you connect using tcp or normal unix sockets ( usually the case for system bus ) it does work for any node version from 0.6 to 1.6.1 (iojs) as it uses very little of node api ( basically EventEmitter, Buffer and net )
Well, I tried it with Node 0.10 and I got a TypeError. This is the stack trace:
events.js:74
throw TypeError('Uncaught, unspecified "error" event.');
^
TypeError: Uncaught, unspecified "error" event.
at TypeError (
I logged the error and it says the following:
Error: ENOENT, stat '/root/.dbus-keyrings'
Well, there's no ".dbus-keyrings" folder in the system. Do I need such a directory?
Does dbus-send command work for you? If so, it's a bug in handhake part of this library
Yes, dbus-send works without a problem! Could you provide a bugfix?
I'll need to replicate issue you have
Can you add one line just after readLine at https://github.com/sidorares/node-dbus/blob/master/lib/handshake.js#L74 with
console.log(authMethod, id, line);
And post results?
You can edit your local copy in ./node_modules/dbus-native/lib/handshake.js
Yep, here's the output:
EXTERNAL 30 <Buffer 52 45 4a 45 43 54 45 44 20 45 58 54 45 52 4e 41 4c 20 44 42 55 53 5f 43 4f 4f 4b 49 45 5f 53 48 41 31 20 41 4e 4f 4e 59 4d 4f 55 53 0d>
the buffer part is 'REJECTED EXTERNAL DBUS_COOKIE_SHA1 ANONYMOUS\r'
thanks, I'm looking into it
did you find something for solving it?
can't reproduce locally - handshake succeeds, after "EXTERNAL 30\r" I get "OK .." reply ( I started unity root session )
Why are you running your script as root? Do you have dbus session started for root user?
On that system every process is running as root and I started the script as root.
I tried to run your p2p example on a 32-bit Ubuntu system under a user account and I got the same error at the client script.