This is at least a partial fix, but it should be enough for you to
solve at this point:
:~/dbus-cxxp-project/caller$ git diff
diff --git a/callee/functions.hpp b/callee/functions.hpp
index 658e569..eda3f23 100644
--- a/callee/functions.hpp
+++ b/callee/functions.hpp
@@ -35,7 +35,7 @@ sResult doRead(std::vector<uint8_t> blockN)
-std::vector<uint8_t> write(std::vector<sBlock> blocks)
+std::vector<uint8_t> doWrite(std::vector<sBlock> blocks)
{
std::vector<uint8_t> response(blocks.size(), 0);
return response;
diff --git a/callee/struct_dbus.cpp b/callee/struct_dbus.cpp
index 5eb6ddc..016bc5a 100644
--- a/callee/struct_dbus.cpp
+++ b/callee/struct_dbus.cpp
@@ -37,14 +37,19 @@ DBus::MessageIterator&
operator>>(DBus::MessageIterator& i, struct sResult& t)
DBus::MessageAppendIterator& operator<<(DBus::MessageAppendIterator&
i, const struct sResult& t)
{
-// i.open_container(DBus::CONTAINER_STRUCT, std::string());
-// i.sub_iterator()->append(t.res);
-// i.sub_iterator()->append(t.blocks);
-// i.close_container();
-
- i.append(t.res);
- i.append(t.blocks);
+std::cout << "OPER << SRESULT" << std::endl;
+ i.open_container(DBus::CONTAINER_STRUCT, std::string());
+fflush(stdout);
+fflush(stderr);
+ i.sub_iterator()->append(t.res);
+ i.sub_iterator()->append(t.blocks);
+ i.close_container();
+std::cout << "CONTAINTER STRUCT DONE" << std::endl;
return i;
+
+// i.append(t.res);
+ // i.append(t.blocks);
+ // return i;
}
diff --git a/callee/variables.hpp b/callee/variables.hpp
index 567b3a0..dca57f0 100644
--- a/callee/variables.hpp
+++ b/callee/variables.hpp
@@ -5,14 +5,14 @@
struct sBlock{
- static constexpr const char* DBUS_SIGNATURE = "(ya)";
+ static constexpr const char* DBUS_SIGNATURE = "(yay)";
uint8_t block;
std::vector<uint8_t> data;
};
struct sResult {
- static constexpr const char* DBUS_SIGNATURE = "(ya)";
+ static constexpr const char* DBUS_SIGNATURE = "(ya(yay))";
uint8_t res;
std::vector<sBlock> blocks;
};
diff --git a/caller/struct_dbus.cpp b/caller/struct_dbus.cpp
index 5eb6ddc..1caf1ae 100644
--- a/caller/struct_dbus.cpp
+++ b/caller/struct_dbus.cpp
@@ -13,14 +13,15 @@ DBus::MessageIterator&
operator>>(DBus::MessageIterator& i, struct sBlock& t)
DBus::MessageAppendIterator& operator<<(DBus::MessageAppendIterator&
i, const struct sBlock& t)
{
- i.append(t.block);
- i.append(t.data);
+// i.append(t.block);
+// i.append(t.data);
+// return i;
+
+ i.open_container(DBus::CONTAINER_STRUCT, std::string());
+ i.sub_iterator()->append(t.data);
+ i.sub_iterator()->append(t.block);
+ i.close_container();
return i;
-
-// i.open_container(DBus::CONTAINER_STRUCT, std::string());
-// i.sub_iterator()->append(t.data);
-// i.sub_iterator()->append(t.block);
-// i.close_container();
}
diff --git a/caller/variables.hpp b/caller/variables.hpp
index 567b3a0..dca57f0 100644
--- a/caller/variables.hpp
+++ b/caller/variables.hpp
@@ -5,14 +5,14 @@
struct sBlock{
- static constexpr const char* DBUS_SIGNATURE = "(ya)";
+ static constexpr const char* DBUS_SIGNATURE = "(yay)";
uint8_t block;
std::vector<uint8_t> data;
};
struct sResult {
- static constexpr const char* DBUS_SIGNATURE = "(ya)";
+ static constexpr const char* DBUS_SIGNATURE = "(ya(yay))";
uint8_t res;
std::vector<sBlock> blocks;
};
THE IMPORTANT PARTS:
/////////// Array signatures MUST have the type that they include in
the array. Just saying "there's an array here" is not sufficient.
See the documentation on the type system for more information:
https://dbus.freedesktop.org/doc/dbus-specification.html#type-system
struct sBlock{
- static constexpr const char* DBUS_SIGNATURE = "(ya)";
+ static constexpr const char* DBUS_SIGNATURE = "(yay)";
uint8_t block;
std::vector<uint8_t> data;
};
/////////// Similar to the above, since our array has another struct
inside of it, we must include the signature of the struct in our total
signature.
struct sResult {
- static constexpr const char* DBUS_SIGNATURE = "(ya)";
+ static constexpr const char* DBUS_SIGNATURE = "(ya(yay))";
uint8_t res;
std::vector<sBlock> blocks;
};
//////////// Whenever you have a struct, you must open the container
and insert everything into it. The implementation of
MessageAppendIterator::append(vector<T>) shows how this needs to be
done:
https://github.com/dbus-cxx/dbus-cxx/blob/3ff5c62bcd0c653be8d7c49ec25d46fb189ecb3c/dbus-cxx/messageappenditerator.h#L100
/////////// You don't need to do the open_container on any arrays, as
that implementation is already provided for you.
DBus::MessageAppendIterator& operator<<(DBus::MessageAppendIterator&
i, const struct sResult& t)
{
+ i.open_container(DBus::CONTAINER_STRUCT, std::string());
+ i.sub_iterator()->append(t.res);
+ i.sub_iterator()->append(t.blocks);
+ i.close_container();
return i;
}
Also if you are having trouble with the signatures, I recommend that
you run dbus-monitor in another terminal; it will show you exactly
what is being sent over the wire. Here's the output from the partial
patch above:
method call sender=:1.79 -> dest=org.freedesktop.DBus serial=1
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;
member=Hello
method call sender=:1.79 -> dest=dev.example.example1 serial=2
path=/home/dev/Example; interface=dev.example.example1; member=state
method return sender=:1.78 -> dest=:1.79 reply_serial=2
byte 0
method call sender=:1.79 -> dest=dev.example.example1 serial=3
path=/home/dev/Example; interface=dev.example.example1; member=stop
method return sender=:1.78 -> dest=:1.79 reply_serial=3
method call sender=:1.79 -> dest=dev.example.example1 serial=4
path=/home/dev/Example; interface=dev.example.example1; member=start
method return sender=:1.78 -> dest=:1.79 reply_serial=4
method call sender=:1.79 -> dest=dev.example.example1 serial=5
path=/home/dev/Example; interface=dev.example.example2; member=read
array of bytes [
05 05 05 05 05
]
method return sender=:1.78 -> dest=:1.79 reply_serial=5
struct {
byte 0
array [
]
}
Note that we send an array of 5 bytes(each with the value 5), and then
we send back the struct with two members: one byte(value 0) and one
array with no values.
-Robert Middleton
> To unsubscribe from this group and stop receiving emails from it, send an email to
dbus-cxx+u...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/dbus-cxx/955a5661-367c-48fb-afae-551cad9614af%40googlegroups.com.