jaklug
(John Klug)
September 6, 2022, 11:50pm
1
This is g_dbus_connection_call_sync
GError return.
I see this in DBUS-Monitor:
error time=1662507400.884091 sender=:1.128 -> destination=:1.813 error_name=org.bluez.Error.DoesNotExist reply_serial=28
string "Does Not Exist"
When I try to decode it, I get:
domain 179 0xb3: code 36 0x24
g_quark_to_string(error->domain)
gives me:
Domain: g-io-error-quark
What is the correct way to decode this error?
andyholmes
(Andy Holmes)
September 7, 2022, 12:01am
2
Not sure entirely what you want to decode, but you probably want to see Gio.DBusError
which has some related functions and maybe Error Reporting .
Edit: Oh I missed that this was bluez, in which case device-api.txt
may be useful.
jaklug
(John Klug)
September 7, 2022, 12:25am
3
What I meant is a header file.
Looking in adapter-api.txt, it is missing:
DoesNotExist
But I see in BlueZ src/error.c:
DBusMessage *btd_error_does_not_exist(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE “.DoesNotExist”,
“Does Not Exist”);
}
So does this mean they only create a text message? I didn’t really want to have to scan a text message. I was hoping for a domain and code value.
andyholmes
(Andy Holmes)
September 7, 2022, 12:28am
4
Well I think D-Bus has it’s own error thing; GIO just has some utility functions for working with them. A GError
looks like this:
struct GError {
GQuark domain;
gint code;
gchar *message;
};
So you can get the attributes of it with error->domain
, error->code
and error->message
. Typically you will check against known errors like:
if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED)
// etc
G_DBUS_ERROR_FAILED
and G_IO_ERROR_FAILED
are codes you get when there isn’t a more appropriate code like G_DBUS_ERROR_UNKNOWN_OBJECT
, which may be the error code in your case.
DoesNotExist
is on line #120 of device-api.txt
, incidentally.
jaklug
(John Klug)
September 7, 2022, 3:39pm
5
Here is what seems to work:
g_error_matches(error,G_IO_ERROR,G_IO_ERROR_DBUS_ERROR)
That matches the code, and is a general error.
To get the bluez error you must do:
g_dbus_error_get_remote_error(error);
This will contain something like:
"org.bluez.Error.DoesNotExist"
or
"org.bluez.Error.AlreadyExists"
Thanks for the help.
1 Like
system
(system)
Closed
October 7, 2022, 3:39pm
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.