473,666 Members | 2,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_GetAdapterN ame, it
all goes wrong. I've tried variously switching between int32 and uint32,
also using ByVal for the index (produces a "Unhandled Exception:
System.NullRefe renceException: 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_GetAdapterN ame 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_ERRO R As Int32 = 1 '/* Error */
Public HBA_Status_ERRO R_NOT_SUPPORTED As Int32 = 2 '/* Function
not supported.*/
Public HBA_Status_ERRO R_INVALID_HANDL E As Int32 = 3 '/* invalid
handle */
Public HBA_Status_ERRO R_ARG As Int32 = 4 '/* Bad
argument */
Public HBA_Status_ERRO R_ILLEGAL_WWN As Int32 = 5 '/* WWN not
recognized */
Public HBA_Status_ERRO R_ILLEGAL_INDEX As Int32 = 6 '/* Index not
recognized */
Public HBA_Status_ERRO R_MORE_DATA As Int32 = 7 '/* Larger
buffer required */
Public HBA_Status_ERRO R_STALE_DATA As Int32 = 8
Public HBA_Status_SCSI _CHECK_CONDITIO N As Int32 = 9
Public HBA_Status_ERRO R_BUSY As Int32 = 10
Public HBA_Status_ERRO R_TRY_AGAIN As Int32 = 11
Public HBA_Status_ERRO R_ADAPTER_REMOV ED As Int32 = 12

'/* 4.2.3 Port Operational Modes Values */

Public HBA_PortType As Int32 = 0

Public HBA_PortType_UN KNOWN As Int32 = 1 '/* Unknown */
Public HBA_PortType_OT HER As Int32 = 2 '/* Other */
Public HBA_PortType_NO TPRESENT As Int32 = 3 '/* Not present */
Public HBA_PortType_NP ORT As Int32 = 5 '/* Fabric */
Public HBA_PortType_NL PORT As Int32 = 6 '/* Public Loop */
Public HBA_PortType_FL PORT As Int32 = 7
Public HBA_PortType_FP ORT As Int32 = 8 '/* Fabric Port */
Public HBA_PortType_EP ORT As Int32 = 9 '/* Fabric expansion
port */
Public HBA_PortType_GP ORT As Int32 = 10 '/* Generic Fabric
Port */
Public HBA_PortType_LP ORT As Int32 = 20 '/* Private Loop */
Public HBA_PortType_PT P As Int32 = 21 '/* Point to Point */

Public HBA_PortState As Int32 = 0
Public HBA_PortState_U NKNOWN As Int32 = 1 '/* Unknown */
Public HBA_PortState_O NLINE As Int32 = 2 '/* Operational */
Public HBA_PortState_O FFLINE As Int32 = 3 '/* User Offline */
Public HBA_PortState_B YPASSED As Int32 = 4 '/* Bypassed */
Public HBA_PortState_D IAGNOSTICS As Int32 = 5 '/* In diagnostics
mode */
Public HBA_PortState_L INKDOWN As Int32 = 6 '/* Link Down */
Public HBA_PortState_E RROR As Int32 = 7 '/* Port Error */
Public HBA_PortState_L OOPBACK As Int32 = 8 '/* Loopback */

Public HBA_PortSpeed As Int32 = 0
Public HBA_PortSpeed_U NKNOWN As Int32 = 0 '/* Unknown -
transceiver incable of reporting */
Public HBA_PortSpeed_1 GBIT As Int32 = 1 '/* 1 GBit/sec */
Public HBA_PortSpeed_2 GBIT As Int32 = 2 '/* 2 GBit/sec */
Public HBA_PortSpeed_1 0GBIT As Int32 = 4 '/* 10 GBit/sec */
Public HBA_PortSpeed_N OT_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.WriteLi ne("*** ***")
Console.WriteLi ne("Running version " &
HBAView_Class.H BA_GetVersion() & " of the HBA API library.")
Console.WriteLi ne("*** " & HBAView_Class.H BA_LoadLibrary( ) & " ***")
HBA_Count = HBAView_Class.H BA_GetNumberOfA dapters()
Console.WriteLi ne("*** HBA_GetNumberOf Adapters : " & HBA_Count & "
***")

Dim HBA_AdapterDeta ils As New HBAView_Class.H BA_AdapterAttri butes()

For HBA_Count_Loop = 0 To HBA_Count - 1
Console.WriteLi ne("*** Num=" & HBA_Count_Loop)
HBA_Status =
HBAView_Class.H BA_GetAdapterNa me(System.Conve rt.ToUInt32(HBA _Count_Loop),
HBA_Name)
Console.WriteLi ne("*** " & "HBA_GetAdapter Name HBA_Status=" &
HBA_Status & " ***")
Console.WriteLi ne("*** Adapter " & HBA_Count_Loop + 1 & "
HBA_GetAdapterN ame : " & HBA_Name & " ***")
'HBA_Handle = HBAView_Class.H BA_OpenAdapter( HBA_Name)
HBA_Handle = HBAView_Class.H BA_OpenAdapter( "QLogic-ql2300-1")
Console.WriteLi ne("*** Adapter " & HBA_Count_Loop + 1 & "
HBA_OpenAdapter : " & HBA_Handle & " ***")
HBA_Handle_Save = HBA_Handle
HBA_Status = HBAView_Class.H BA_GetAdapterAt tributes(HBA_Ha ndle,
HBA_AdapterDeta ils)
'HBA_Status = HBAView_Class.H BA_GetAdapterAt tributes(HBA_Ha ndle,
HBA_Test)
Console.WriteLi ne("*** " & "HBA_GetAdapter Attributes
HBA_Status=" & HBA_Status & " ***")
'Console.WriteL ine("*** " & HBA_Test & " ***")
Console.WriteLi ne("*** Adapter " & HBA_Count_Loop + 1 & "
Manufacturer : " & HBA_AdapterDeta ils.Manufacture r & " ***")

Console.WriteLi ne("*** Adapter " & HBA_Count_Loop + 1 & " Model
: " & HBA_AdapterDeta ils.Model & " ***")
HBA_Status = HBAView_Class.H BA_CloseAdapter (HBA_Handle_Sav e)
Console.WriteLi ne("*** " & "HBA_CloseAdapt er HBA_Status=" &
HBA_Status & " ***")
Next HBA_Count_Loop
Console.WriteLi ne("*** HBA_FreeLibrary : " &
HBAView_Class.H BA_FreeLibrary( ) & " ***")
Console.WriteLi ne("*** ***")

End Sub

End Module


Imports System.Runtime. InteropServices

Public Class HBAView_Class

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

<DllImport("hba api.dll")> _
Public Shared Function _
HBA_GetVersion( ) As Int32
End Function
<DllImport("hba api.dll")> _
Public Shared Function _
HBA_LoadLibrary () As Int32
End Function
<DllImport("hba api.dll")> _
Public Shared Function _
HBA_FreeLibrary () As Int32
End Function
<DllImport("hba api.dll")> _
Public Shared Function _
HBA_GetNumberOf Adapters() As Int32
End Function
<DllImport("hba api.dll")> _
Public Shared Function _
HBA_GetAdapterN ame(ByRef AdapterIndex As UInt32, ByRef AdapterName
As String) As Int32
End Function
<DllImport("hba api.dll")> _
Public Shared Function _
HBA_OpenAdapter (ByRef AdapterName As String) As Int32
End Function
<DllImport("hba api.dll")> _
Public Shared Function _
HBA_CloseAdapte r(ByRef HandleName As Int32) As Int32
End Function
<DllImport("hba api.dll")> _
Public Shared Function _
HBA_GetAdapterA ttributes(ByRef HandleName As Int32, ByRef
HBA_AdapterAttr ib As HBA_AdapterAttr ibutes) As Int32
End Function

End Class
Nov 21 '05 #1
0 2195

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

Similar topics

1
1993
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, this layer manage the underlying COM Objects and upon request, provide a pointer to those objects to the 'API Consumer', following is an illustration of the system: API Consumer ( Native C++/C# ) || ******************************************* * ...
8
3412
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 added. Converting the type library to a .Net assembly failed. A depended type library 'CDO' could not be converted to a .NET assembly. A dependent type library 'ADODB' could not be converted to a .NET assembly. Item has already been added." ...
9
4091
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 the "old" VB it works but not in .NET. I think it is a problem with marshalling but I could not find a solution yet. First I included the Type Library in VS.NET 2003. Other functions of the TL work so the reference to the Lib must be correct.
3
2770
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 native DLL but the native DLL fails to load the managed DLL. The paper that addresses the 'mixed DLL problem' below does not offer any understandable workaround....
12
1928
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 is a "Array index out of bounds".
2
7292
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 "Array index out of bounds". Microsoft.Office.Interop.Outlook._Application olApp = new Microsoft.Office.Interop.Outlook.ApplicationClass(); Microsoft.Office.Interop.Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
2
1672
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 object (shows type as System.__COMObject). I have no idea what someObj is, but it is likely to be some sort of wrapper around an image : con.Peek(1) is ultimately retrieving a
1
4557
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 number of other C# dlls referencing Interfaces.dll and using logger.dll interop for logging.
2
4920
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 message in the environment shown here: Operating System: Microsoft Windows Version 5.1 (Build
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.