Subject: [ruby-ffi] Problem retrieving struct from pointer |
From: Joe |
Date: 8/5/10 8:12 AM |
To: ruby-ffi |
Hello all I'm trying to pull some information from the SNIA's HBA API (http:// hbaapi.sourceforge.net). The function I'm having difficulty with is HBA_GetAdapterAttributes, which according to the API, returns a single pointer to a struct. The struct in C is: typedef struct hba_AdapterAttributes { char Manufacturer[64]; char SerialNumber[64]; char Model[256]; char ModelDescription[256]; HBA_WWN NodeWWN; char NodeSymbolicName[256]; char HardwareVersion[256]; char DriverVersion[256]; char OptionROMVersion[256]; char FirmwareVersion[256]; HBA_UINT32 VendorSpecificID; HBA_UINT32 NumberOfPorts; char DriverName[256]; } HBA_ADAPTERATTRIBUTES, *PHBA_ADAPTERATTRIBUTES; And the function in question is: HBA_API HBA_STATUS HBA_GetAdapterAttributes( HBA_HANDLE handle, HBA_ADAPTERATTRIBUTES *hbaattributes ); ---------- In Ruby, I created the struct as so: class HBA_AdapterAttributes < FFI::Struct layout :Manufacturer, :char :SerialNumber, :char, :Model, :char, :ModelDescription, :char, :NodeWWN, :uint8, :NodeSymbolicName, :char, :HardwareVersion, :char, :DriverVersion, :char, :OptionROMVersion, :char, :FirmwareVersion, :char, :VendorSpecificID, :uint32, :NumberOfPorts, :uint32, :DriverName, :char end Now def get_struct pointer def get_struct pointer HBA::HBA_AdapterAttributes.new pointer end Calling the get_struct_pointer returns an array of fixnums, instead of any string values. Any idea what I'm overlooking here?