<div dir="ltr">Hi Lennart,<div><br></div><div>Thank you for the reply. Please find my comments inline:</div><div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 24, 2017 at 12:55 AM, Lennart Poettering <span dir="ltr"><<a href="mailto:lennart@poettering.net" target="_blank">lennart@poettering.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Fri, 23.06.17 20:45, guhan balasubramanian (<a href="mailto:guhan.sac@gmail.com">guhan.sac@gmail.com</a>) wrote:<br>
<br>
> Hi,<br>
><br>
> I'm currently trying out sd-bus methods for my application. I am in a<br>
> situation where I must accept an input and return a byte array based on the<br>
> input.<br>
><br>
> In the vtable. the following declaration is present:<br>
> SD_BUS_METHOD("method_id", "x", "ay", method_1, 0)<br>
><br>
> And inside the definition for method_1, for returning:<br>
> uint8_t b[2] = {0x01, 0x02};<br>
> sd_bus_reply_method_return(m, "ay", b);<br>
<br>
</span>if you use sd_bus_reply_method_return() (or sd_bus_append()) the<br>
arguments to pass for an array is the array's size followed by the<br>
members. Hence, the following should do what you want:<br>
<br>
sd_bus_reply_method_return(m, "ay", 2, 0x01, 0x02);<br></blockquote><div><br></div><div>This worked for me. But I had the following three questions based on this:</div><div><br></div><div>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? </div><div><br></div><div>2. I wasn't able to find the definition for sd_bus_append, I think you meant <b>sd_bus_message_append</b>() right? But, if I do that and append the array, I wouldn't be able to use <b>sd_bus_reply_method_return</b> with the correct type. I was able to achieve this on get-property, since property_handlers wouldn't need a return. </div><div><br></div><div>I am not sure about how to handle this one. Would I be able to find a reference code/doc for this? </div><div><br></div><div>3. Is there an API to pass the entire container (array in this case) for a method return? </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Lennart<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
--<br>
Lennart Poettering, Red Hat<br>
</font></span></blockquote></div><br></div></div><div class="gmail_extra"><div><br class="gmail-Apple-interchange-newline">Thanks,</div><div>Guhan</div></div></div>