473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

HBAAPI.dll - possible interop problem

I am attempting to utilise the HBAAPI.dll that can be found at
http://hbaapi.sourceforge.net/ (which is also used in hbaverify at
http://hbaverify.sourceforge.net/) as I need to get a small subset of the
data that it provides. However, although I can get the initialisations to
work, I cannot manage to get responses that require data to pass to the dll.
(The latest API details are at :
ftp://ftp.t11.org/t11/pub/sm/hba/05-056v0.pdf)

The basic functions work fine e.g HBA_GetVersion and HBA_LoadLibrary.
However once I attempt to pass values to the dll e.g. HBA_GetAdapterName, it
all goes wrong. I've tried variously switching between int32 and uint32,
also using ByVal for the index (produces a "Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an
object." error) and using ByRef (produces a status code indicating an
'invalid index'). The HBAVerify code works fine on my test system and I
cannot see what differs in the way that I am calling the dll from my VB.Net
code.

Can anyone suggest what might be wrong with the HBA_GetAdapterName function,
given that the dll is meant to be called from C.

Cheers,

Vizzybit.

My code is as follows (all HBAAPI functions are not yet currently
implemented, just enought for testing) :

Option Strict On
Imports System
Imports System.Runtime.InteropServices

Module HBAView

' sundry fields for VB translation and processing
Public Blank As String = ""
Public HBA_Count As Int32 = 0
Public HBA_Count_Loop As Int32 = 0
Public HBA_Name As String = ""
Public HBA_Handle_Save As Int32 = 0

'/* 4.2.1 Handle to Device */
Public HBA_Handle As Int32 = 0

'/* 4.2.2 Status Return Values */
Public HBA_Status As Int32 = 0

Public HBA_Status_OK As Int32 = 0
Public HBA_Status_ERROR As Int32 = 1 '/* Error */
Public HBA_Status_ERROR_NOT_SUPPORTED As Int32 = 2 '/* Function
not supported.*/
Public HBA_Status_ERROR_INVALID_HANDLE As Int32 = 3 '/* invalid
handle */
Public HBA_Status_ERROR_ARG As Int32 = 4 '/* Bad
argument */
Public HBA_Status_ERROR_ILLEGAL_WWN As Int32 = 5 '/* WWN not
recognized */
Public HBA_Status_ERROR_ILLEGAL_INDEX As Int32 = 6 '/* Index not
recognized */
Public HBA_Status_ERROR_MORE_DATA As Int32 = 7 '/* Larger
buffer required */
Public HBA_Status_ERROR_STALE_DATA As Int32 = 8
Public HBA_Status_SCSI_CHECK_CONDITION As Int32 = 9
Public HBA_Status_ERROR_BUSY As Int32 = 10
Public HBA_Status_ERROR_TRY_AGAIN As Int32 = 11
Public HBA_Status_ERROR_ADAPTER_REMOVED As Int32 = 12

'/* 4.2.3 Port Operational Modes Values */

Public HBA_PortType As Int32 = 0

Public HBA_PortType_UNKNOWN As Int32 = 1 '/* Unknown */
Public HBA_PortType_OTHER As Int32 = 2 '/* Other */
Public HBA_PortType_NOTPRESENT As Int32 = 3 '/* Not present */
Public HBA_PortType_NPORT As Int32 = 5 '/* Fabric */
Public HBA_PortType_NLPORT As Int32 = 6 '/* Public Loop */
Public HBA_PortType_FLPORT As Int32 = 7
Public HBA_PortType_FPORT As Int32 = 8 '/* Fabric Port */
Public HBA_PortType_EPORT As Int32 = 9 '/* Fabric expansion
port */
Public HBA_PortType_GPORT As Int32 = 10 '/* Generic Fabric
Port */
Public HBA_PortType_LPORT As Int32 = 20 '/* Private Loop */
Public HBA_PortType_PTP As Int32 = 21 '/* Point to Point */

Public HBA_PortState As Int32 = 0
Public HBA_PortState_UNKNOWN As Int32 = 1 '/* Unknown */
Public HBA_PortState_ONLINE As Int32 = 2 '/* Operational */
Public HBA_PortState_OFFLINE As Int32 = 3 '/* User Offline */
Public HBA_PortState_BYPASSED As Int32 = 4 '/* Bypassed */
Public HBA_PortState_DIAGNOSTICS As Int32 = 5 '/* In diagnostics
mode */
Public HBA_PortState_LINKDOWN As Int32 = 6 '/* Link Down */
Public HBA_PortState_ERROR As Int32 = 7 '/* Port Error */
Public HBA_PortState_LOOPBACK As Int32 = 8 '/* Loopback */

Public HBA_PortSpeed As Int32 = 0
Public HBA_PortSpeed_UNKNOWN As Int32 = 0 '/* Unknown -
transceiver incable of reporting */
Public HBA_PortSpeed_1GBIT As Int32 = 1 '/* 1 GBit/sec */
Public HBA_PortSpeed_2GBIT As Int32 = 2 '/* 2 GBit/sec */
Public HBA_PortSpeed_10GBIT As Int32 = 4 '/* 10 GBit/sec */
Public HBA_PortSpeed_NOT_NEGOTIATED As Int32 = 5 '/* Speed not
established */

'/* 4.2.4 Class of Service Values - See GS-2 Spec.*/

Public HBA_COS As Int32 = 0

Sub Main()

Console.WriteLine("*** ***")
Console.WriteLine("Running version " &
HBAView_Class.HBA_GetVersion() & " of the HBA API library.")
Console.WriteLine("*** " & HBAView_Class.HBA_LoadLibrary() & " ***")
HBA_Count = HBAView_Class.HBA_GetNumberOfAdapters()
Console.WriteLine("*** HBA_GetNumberOfAdapters : " & HBA_Count & "
***")

Dim HBA_AdapterDetails As New HBAView_Class.HBA_AdapterAttributes()

For HBA_Count_Loop = 0 To HBA_Count - 1
Console.WriteLine("*** Num=" & HBA_Count_Loop)
HBA_Status =
HBAView_Class.HBA_GetAdapterName(System.Convert.To UInt32(HBA_Count_Loop),
HBA_Name)
Console.WriteLine("*** " & "HBA_GetAdapterName HBA_Status=" &
HBA_Status & " ***")
Console.WriteLine("*** Adapter " & HBA_Count_Loop + 1 & "
HBA_GetAdapterName : " & HBA_Name & " ***")
'HBA_Handle = HBAView_Class.HBA_OpenAdapter(HBA_Name)
HBA_Handle = HBAView_Class.HBA_OpenAdapter("QLogic-ql2300-1")
Console.WriteLine("*** Adapter " & HBA_Count_Loop + 1 & "
HBA_OpenAdapter : " & HBA_Handle & " ***")
HBA_Handle_Save = HBA_Handle
HBA_Status = HBAView_Class.HBA_GetAdapterAttributes(HBA_Handle,
HBA_AdapterDetails)
'HBA_Status = HBAView_Class.HBA_GetAdapterAttributes(HBA_Handle,
HBA_Test)
Console.WriteLine("*** " & "HBA_GetAdapterAttributes
HBA_Status=" & HBA_Status & " ***")
'Console.WriteLine("*** " & HBA_Test & " ***")
Console.WriteLine("*** Adapter " & HBA_Count_Loop + 1 & "
Manufacturer : " & HBA_AdapterDetails.Manufacturer & " ***")

Console.WriteLine("*** Adapter " & HBA_Count_Loop + 1 & " Model
: " & HBA_AdapterDetails.Model & " ***")
HBA_Status = HBAView_Class.HBA_CloseAdapter(HBA_Handle_Save)
Console.WriteLine("*** " & "HBA_CloseAdapter HBA_Status=" &
HBA_Status & " ***")
Next HBA_Count_Loop
Console.WriteLine("*** HBA_FreeLibrary : " &
HBAView_Class.HBA_FreeLibrary() & " ***")
Console.WriteLine("*** ***")

End Sub

End Module


Imports System.Runtime.InteropServices

Public Class HBAView_Class

'/* 4.2.7 Adapter Attributes */
Public Structure HBA_AdapterAttributes
Dim Manufacturer As String '64 Emulex
Dim SerialNumber As String '64 A12345
Dim Model As String '256 QLA2200
Dim ModelDescription As String '256 Agilent TachLite
Dim NodeWWN As String '8 HBA_WWN
Dim NodeSymbolicName As String '256 From GS-3
Dim HardwareVersion As String '256 Vendor use
Dim DriverVersion As String '256 Vendor use
Dim OptionROMVersion As String '256 Vendor use - i.e. hardware
boot ROM
Dim FirmwareVersion As String '256 Vendor use
Dim VendorSpecificID As Int32 ' Vendor specific
Dim NumberOfPorts As Int32 '
Dim DriverName As String '256 Binary path and/or name of
driver file.
End Structure

<DllImport("hbaapi.dll")> _
Public Shared Function _
HBA_GetVersion() As Int32
End Function
<DllImport("hbaapi.dll")> _
Public Shared Function _
HBA_LoadLibrary() As Int32
End Function
<DllImport("hbaapi.dll")> _
Public Shared Function _
HBA_FreeLibrary() As Int32
End Function
<DllImport("hbaapi.dll")> _
Public Shared Function _
HBA_GetNumberOfAdapters() As Int32
End Function
<DllImport("hbaapi.dll")> _
Public Shared Function _
HBA_GetAdapterName(ByRef AdapterIndex As UInt32, ByRef AdapterName
As String) As Int32
End Function
<DllImport("hbaapi.dll")> _
Public Shared Function _
HBA_OpenAdapter(ByRef AdapterName As String) As Int32
End Function
<DllImport("hbaapi.dll")> _
Public Shared Function _
HBA_CloseAdapter(ByRef HandleName As Int32) As Int32
End Function
<DllImport("hbaapi.dll")> _
Public Shared Function _
HBA_GetAdapterAttributes(ByRef HandleName As Int32, ByRef
HBA_AdapterAttrib As HBA_AdapterAttributes) As Int32
End Function

End Class
Nov 21 '05 #1
0 2185

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nadav | last post by:
Hi, Introduction *************** I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer,...
8
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be...
9
by: mupe | last post by:
Hi, i have a problem with a Type Library, which is written in C++. I am developing an application in C#.NET and have to use functions from this COM-Type Library. When I use these functions in...
3
by: Mali Guven | last post by:
Hello, I have a native DLL (written in C) which is supposed to call a managed DLL (was written in C#, and an entry point was injected modifying the ildasm'd code). The exectuable calls the...
12
by: JC | last post by:
Hi... Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error...
2
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a...
2
by: Philip Daniels | last post by:
I am doing some work with a client API via COM interop. I have reached the situation where after this call to their API: object someObj = con.Peek(1); "someObj" contains some type of COM...
1
by: Don.Leri | last post by:
Hi, I have a logger.dll (unmanaged c++ dll compiled in vs2005). I have a C# interop to use that dll in managed code implemented in Interfaces.dll (used by other C# dlls). I also have a...
2
by: Nicholas Dreyer | last post by:
The following error Run-time exception thrown : System.Runtime.InteropServices.COMException - Error loading type library/DLL. happens while running the code listed at the bottom of this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.