From 01a2ff2d72d9fafb6e26b2ccab46ea33bc8fd46f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 3 Feb 2023 21:30:41 +1000 Subject: [PATCH] brei: pass the proto object through to send_message Makes for easier debugging since we can print names instead of just ids/opcodes. --- proto/ei-proto.c.tmpl | 4 ++-- src/libei-private.h | 2 +- src/libei.c | 12 +++++++++--- src/libeis-client.c | 12 +++++++++--- src/libeis-client.h | 2 +- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/proto/ei-proto.c.tmpl b/proto/ei-proto.c.tmpl index 89e6f5d..aab4735 100644 --- a/proto/ei-proto.c.tmpl +++ b/proto/ei-proto.c.tmpl @@ -39,7 +39,7 @@ struct {{target.name}}; * message sending functions (requests for libei, events for libeis). */ extern int {{target.name}}_send_message( - {{target.as_arg}}, uint32_t object_id, uint32_t opcode, + {{target.as_arg}}, const struct brei_object *obj, uint32_t opcode, const char *signature, size_t nargs, ... ); @@ -80,7 +80,7 @@ int return -ENOTSUP; return {{target.name}}_send_message( - ctx, obj->id, {{outgoing.fqdn.upper()}}, "{{outgoing.signature}}", + ctx, obj, {{outgoing.fqdn.upper()}}, "{{outgoing.signature}}", {{outgoing.arguments|length}}{%- for arg in outgoing.arguments %}, {{arg.name}}{% endfor -%} ); } diff --git a/src/libei-private.h b/src/libei-private.h index eba1b8f..0fecd2f 100644 --- a/src/libei-private.h +++ b/src/libei-private.h @@ -108,7 +108,7 @@ void ei_unregister_object(struct ei *ei, struct brei_object *object); int -ei_send_message(struct ei *ei, uint32_t object_id, +ei_send_message(struct ei *ei, const struct brei_object *object, uint32_t opcode, const char *signature, size_t nargs, ...); void diff --git a/src/libei.c b/src/libei.c index 04cd986..211d6ff 100644 --- a/src/libei.c +++ b/src/libei.c @@ -1441,16 +1441,22 @@ connection_dispatch(struct source *source, void *userdata) } int -ei_send_message(struct ei *ei, uint32_t object_id, +ei_send_message(struct ei *ei, const struct brei_object *object, uint32_t opcode, const char *signature, size_t nargs, ...) { int fd = source_get_fd(ei->source); - log_debug(ei, "sending: %#x:%u signature '%s'", object_id, opcode, signature); + log_debug(ei, "sending: object %#x (%s@v%u:%s(%u)) signature '%s'", + object->id, + object->interface->name, + object->interface->version, + object->interface->requests[opcode].name, + opcode, + signature); va_list args; va_start(args, nargs); - int rc = brei_send_message(fd, object_id, opcode, signature, nargs, args); + int rc = brei_send_message(fd, object->id, opcode, signature, nargs, args); va_end(args); return rc < 0 ? rc : 0; } diff --git a/src/libeis-client.c b/src/libeis-client.c index 10fb50a..91ed6b0 100644 --- a/src/libeis-client.c +++ b/src/libeis-client.c @@ -158,17 +158,23 @@ eis_client_find_device(struct eis_client *client, uint32_t deviceid) } int -eis_client_send_message(struct eis_client *client, uint32_t object_id, +eis_client_send_message(struct eis_client *client, const struct brei_object *object, uint32_t opcode, const char *signature, size_t nargs, ...) { struct eis *eis = eis_client_get_context(client); int fd = source_get_fd(client->source); - log_debug(eis, "sending: %#x:%u signature '%s'", object_id, opcode, signature); + log_debug(eis, "sending: object %#x (%s@v%u:%s(%u)) signature '%s'", + object->id, + object->interface->name, + object->interface->version, + object->interface->events[opcode].name, + opcode, + signature); va_list args; va_start(args, nargs); - int rc = brei_send_message(fd, object_id, opcode, signature, nargs, args); + int rc = brei_send_message(fd, object->id, opcode, signature, nargs, args); va_end(args); return rc < 0 ? rc : 0; } diff --git a/src/libeis-client.h b/src/libeis-client.h index d0a1e56..1d42ef3 100644 --- a/src/libeis-client.h +++ b/src/libeis-client.h @@ -97,7 +97,7 @@ eis_client_setup_done(struct eis_client *client, const char *name, bool is_sende const struct eis_client_interface_versions *versions); int -eis_client_send_message(struct eis_client *client, uint32_t object_id, +eis_client_send_message(struct eis_client *client, const struct brei_object *obj, uint32_t opcode, const char *signature, size_t nargs, ...); void