Hi Lennart, Thank you for the reply. Please find my comments inline:
On Sat, Jun 24, 2017 at 12:55 AM, Lennart Poettering <lenn...@poettering.net > wrote: > On Fri, 23.06.17 20:45, guhan balasubramanian (guhan....@gmail.com) wrote: > > > Hi, > > > > I'm currently trying out sd-bus methods for my application. I am in a > > situation where I must accept an input and return a byte array based on > the > > input. > > > > In the vtable. the following declaration is present: > > SD_BUS_METHOD("method_id", "x", "ay", method_1, 0) > > > > And inside the definition for method_1, for returning: > > uint8_t b[2] = {0x01, 0x02}; > > sd_bus_reply_method_return(m, "ay", b); > > if you use sd_bus_reply_method_return() (or sd_bus_append()) the > arguments to pass for an array is the array's size followed by the > members. Hence, the following should do what you want: > > sd_bus_reply_method_return(m, "ay", 2, 0x01, 0x02); > This worked for me. But I had the following three questions based on this: 1. Would it be a good design to construct a va_list of the array elements and pass it as the last argument in sd_bus_reply_method_return? 2. I wasn't able to find the definition for sd_bus_append, I think you meant *sd_bus_message_append*() right? But, if I do that and append the array, I wouldn't be able to use *sd_bus_reply_method_return* with the correct type. I was able to achieve this on get-property, since property_handlers wouldn't need a return. I am not sure about how to handle this one. Would I be able to find a reference code/doc for this? 3. Is there an API to pass the entire container (array in this case) for a method return? > Lennart > > -- > Lennart Poettering, Red Hat > Thanks, Guhan
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel