@@ -28,8 +28,31 @@ static int print_help()
return EXIT_FAILURE;
}
-static int parse_args(int argc, char **argv, const char **path, const char **op_name)
+static void handle_responded_signal(EfwProto *proto, HinawaSndEfwStatus status, guint seqnum,
+ guint category, guint command, const guint32 *frame, guint frame_size)
{
+ gchar *label = g_enum_to_string(HINAWA_TYPE_SND_EFW_STATUS, status);
+ int i;
+
+ printf("responded:\n");
+ printf(" status: %s\n", label);
+ printf(" seqnum: %d\n", seqnum);
+ printf(" category; %d\n", category);
+ printf(" command: %d\n", command);
+
+ if (frame_size > 0) {
+ printf(" frame:\n");
+ for (i = 0; i < frame_size; ++i)
+ printf(" [%3x]: %08x\n", i, frame[i]);
+ }
+
+ g_free(label);
+}
+
+static int parse_args(int argc, char **argv, const char **path, const char **op_name, gboolean *debug)
+{
+ int i;
+
if (argc < 2)
return -EINVAL;
assert(strncmp(argv[1], "device", sizeof("device")) == 0);
@@ -42,6 +65,15 @@ static int parse_args(int argc, char **argv, const char **path, const char **op_
return -EINVAL;
*op_name = argv[3];
+ *debug = FALSE;
+ for (i = 0; i < argc; ++i) {
+ if (strncmp(argv[i], "--debug", sizeof(--debug)) == 0 ||
+ strncmp(argv[i], "-d", sizeof(--debug)) == 0) {
+ *debug = TRUE;
+ break;
+ }
+ }
+
return 0;
}
@@ -54,6 +86,7 @@ int subcmd_device(int argc, char **argv)
} *entry, entries[] = {
};
GError *error = NULL;
+ gboolean debug;
const char *path;
const char *op_name;
HinawaFwNode *node;
@@ -65,7 +98,7 @@ int subcmd_device(int argc, char **argv)
int err;
int i;
- err = parse_args(argc, argv, &path, &op_name);
+ err = parse_args(argc, argv, &path, &op_name, &debug);
if (err < 0)
return print_help(0, NULL, NULL, NULL);
@@ -103,6 +136,9 @@ int subcmd_device(int argc, char **argv)
}
proto = efw_proto_new();
+ if (debug)
+ g_signal_connect(proto, "responded", (GCallback)handle_responded_signal, NULL);
+
efw_proto_bind(proto, node, &error);
if (error != NULL) {
if (g_error_matches(error, HINAWA_FW_NODE_ERROR, HINAWA_FW_NODE_ERROR_FAILED)) {
It's helpful to dump communication result optionally. This commit adds debug option for the purpose. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> --- efw-downloader/src/subcmd-device.c | 40 ++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)