iowkit and VB6

This is the English forum for all topics related to IO-Warrior. Please post in English only

Moderator: Guido Körber

Post Reply
Nigel
Posts: 1
Joined: Wed Jul 28, 2004 10:21 am

iowkit and VB6

Post by Nigel »

Hi
I had problems with VB6 crashing when the IO warrior library iowkit.dll was in my system32 folder (w2k) on my old laptop.
I have just received a new laptop and I can't remember what I did to sort this problem.
Has anyone had problems using the SDK samples with VB6 ?

Nigel
formatc1702
Posts: 55
Joined: Thu Apr 15, 2004 11:23 pm
Contact:

Post by formatc1702 »

hey!

im not quite sure im right but...
you need to place the dll in the folder where there are a hell of a lot of files :) on some windowses its \windows\system32, in others its just windows\system
couldnt tell you how it is in w2k
edzer
Posts: 4
Joined: Sat Apr 30, 2005 8:09 pm
Location: Holland

functions GetSerialNumber and GetProductId not working

Post by edzer »

Hi,

Has anyone code examples for IowKitGetProductId and IowKitGetSerialNumber functions in VB6?

I try to use these functions in vb6 but:
- IowKitGetSerialNumber function crashes the vb6-ide
- IowKitGetProductId returns different values each time the function is called.

I think the reason for the IowKitGetProductId function for not working properly, is because the function declaration in iow.bas is possible incorrect: There is no parameter declared for the device handle. I added the handle myself, but the return values are different each time the function is called.

I have a functional program to messure temperature with iow24/iow40 and a ds1621-i2c temperaturesensor. The only thing missing is the possibility to show the ProductId and the SerialNumber of the iow device.

So i'm looking for code example of a correct iow.bas and a code example how to use the functions in my program.

gr
Edzer
Robert Marquardt
Posts: 543
Joined: Mon Dec 01, 2003 6:09 pm

Post by Robert Marquardt »

I will check on Monday. I have called both functions successfully.
Robert Marquardt
Posts: 543
Joined: Mon Dec 01, 2003 6:09 pm

Post by Robert Marquardt »

The problem with IowKitGetProductId has been solved with a new version of the DLL to be delivered soon.
IowKitGetProductId returns a WORD, but the VB6 declaration is Long.
You get a random high word in the result of the function. Try masking it off in your code for now.
The next version of the DLL simply returns a DWORD to solve the problems.

Code: Select all

Private Sub Form_Load()
Dim I As Long
Dim S(18) As Byte
    ' Initialize everything
    ' Open device
    iowHandles(0) = IowKitOpenDevice()
    ' Fail if can't open
    If iowHandles(0) = 0 Then
        ' Barf and exit from program
        MsgBox "Can not open device!", 0, "Error"
        End
    End If
    ' Get number of IO-Warrior devices in system
    numIows = IowKitGetNumDevs()
    ' Get all IO-Warrior handles
    For I = 2 To numIows
        iowHandles(I - 1) = IowKitGetDeviceHandle(I)
    Next I
    Call ClearAllButton_Click
    I = IowKitGetSerialNumber(iowHandles(0), S(0))
    ReadLabel.Caption = S
    ReadLabel.Caption = "Serial number: " + ReadLabel.Caption
    ReadLabel.Refresh
End Sub
The above is from the revised example for the next DLL, but it should work with the current DLL also.
edzer
Posts: 4
Joined: Sat Apr 30, 2005 8:09 pm
Location: Holland

Post by edzer »

Robert, thanks for your post.

VB6 returns an 'ByRef argument type mismatch' error on the IowKitGetSerialNumber function. De function declaration in iow.bas is:

Code: Select all

Public Declare Function IowKitGetSerialNumber _
    Lib "iowkit" _
    (ByVal iowHandle As Long, ByRef buffer As String) _
As Long
It wont accept S(0) as an argument.

Any suggestions?

I have not tried masking the result of IowKitGetProductId, I will try this later.

The next few days i'm not ably to check the forum. I will possibly check it on next Friday.
Robert Marquardt
Posts: 543
Joined: Mon Dec 01, 2003 6:09 pm

Post by Robert Marquardt »

Oops, i forgot that i changed the declaration also.

Code: Select all

Public Declare Function IowKitGetSerialNumber _
    Lib "iowkit" _
    (ByVal iowHandle As Long, ByRef serialNumber As Byte) _
As Long
edzer
Posts: 4
Joined: Sat Apr 30, 2005 8:09 pm
Location: Holland

Post by edzer »

Problems solved! Both IowKitGetProductId and IowKitGetSerialNumber seem to work properly now.
Masking the two most significant bytes from the return value of IowKitGetProductId to zero, does the trick.

The code we talked about in one view.
The declaration part, with corrections on the orginal iow.bas dated sept 29 2003:

Code: Select all

Public Declare Function IowKitGetSerialNumber _
    Lib "iowkit" _
    (ByVal iowHandle As Long, ByRef serialNumber As Byte) _
As Long

Public Declare Function IowKitGetProductId _
    Lib "iowkit" _
    (ByVal iowHandle As Long) _
As Long
The program part:

Code: Select all

    Dim s(18) As Byte
    Dim sTmp As String
    Dim l As Long
    
    ' Get SerialNumber
    l = iow.IowKitGetSerialNumber(iowHandle, s(0))
    sTmp = s
    Debug.Print "SerialNumber(hex): " & sTmp 
    ' In my case, output in immediate window is: SerialNumber(hex): 000007CE

    ' Get ProductID, 
    ' dec 5377=hex 1501=IOW24; 
    ' dec 5376=hex 1500=IOW40;
    Debug.Print "ProductID(dec): " & CStr(iow.IowKitGetProductId(iowHandle) And 65535)
    ' In my case, output in immediate window is: ProductID(dec): 5377
This makes it a lot easier to identify multiple iow devices on my system.

Robert, thanks.
Post Reply