Subject:
[ruby-ffi] Re: Problem retrieving struct from pointer
From:
Joe
Date:
8/10/10 11:48 AM
To:
ruby-ffi



On Aug 9, 6:40 pm, Wayne Meissner <wmeiss...@gmail.com> wrote:
> On 10 August 2010 07:41, Joe <jm...@yahoo.com> wrote:
>
>
>
> > What I've tried is, created a new class to emulate the C struct:
> >  class HBA_Wwn < FFI::Struct
> >      layout :wwn, [:uint32, 8]
> >  end
>
> Change that to [:uint8, 8], and you should be able to call #to_s on it
> to convert to a string.
>
> Otherwise, you can call #to_ptr on any array field, and use get_string().

Nice catch Wayne, I definitely overlooked that.

This got me to the point where I simply had to convert the 8-byte WWN
array to hex to get the completed WWN string.

Thanks to both of you for you help, I got it running now :)