I/O-Warrior

  • Der Download "Windows SDK" enthält die DLL, Dokuentation und Beispiele. C musst du nicht wirklich lernen, du solltest aber genug verstehen, um die Datei "\Windows\library_1_5\iowkit.h" in AutoIt Konstanten und DLLCalls umzuschreiben. (ab Zeile 54)

  • Also, ich habe mit diese PDF Datei "Dealing with Dlls" durchgelesen, auch teile davon übersetzten lassen, in AutoIt mitgeschriben, udn versucht. Mir ist der Aufbau einer Dll-Funktion klar. Bzw. die Funktion in AutoIt.

    Wenn ich da diese .h Datei habe, verstehe ich nur Bahnhof.

    Ich habe auch schon gegoogelt, doch kann ich leider ncihts finden ;(.

    Ich will ja nicht nerfen, doch wünsche ich mir das das Projekt I/O Warrior nicht unter geht.

    DANKE Tim

    PS: Auf deine Frage zurückzukommen, ja leider komme ich nicht zurecht. Was habe ich für möglichkeiten???

  • Dann mach ich dir ein paar Beispiele:

    Spoiler anzeigen
    [autoit]

    ;// IO-Warrior vendor & product IDs
    ;#define IOWKIT_VENDOR_ID 0x07c0
    ;#define IOWKIT_VID IOWKIT_VENDOR_ID
    Global Const $IOWKIT_VENDOR_ID = 0x07c0
    Global Const $IOWKIT_VID = $IOWKIT_VENDOR_ID

    [/autoit] [autoit][/autoit] [autoit]

    ...

    [/autoit] [autoit][/autoit] [autoit]

    ;// Don't forget to pack it!
    ;#pragma pack(push, 1) --> alle Strukturen sind mit align 1

    [/autoit] [autoit][/autoit] [autoit]

    #cs
    typedef struct _IOWKIT_REPORT
    {
    UCHAR ReportID;
    union
    {
    DWORD Value;
    BYTE Bytes[4];
    };
    }
    IOWKIT_REPORT, *PIOWKIT_REPORT;
    #ce
    Global Const $tagIOWKIT_REPORT = "align 1;byte ReportID; DWORD Value;"

    [/autoit] [autoit][/autoit] [autoit]

    ...

    [/autoit] [autoit][/autoit] [autoit]

    ;#define IOWKIT_REPORT_SIZE sizeof(IOWKIT_REPORT)
    Global Const $IOWKIT_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_REPORT, 1))

    [/autoit] [autoit][/autoit] [autoit]

    ;// Opaque IO-Warrior handle
    ;typedef PVOID IOWKIT_HANDLE; --> in AutoIt den Typ ptr verwenden für alle Stellen, wo IOWKIT_HANDLE steht

    [/autoit] [autoit][/autoit] [autoit]

    Global $ghIOWkitDll=-1
    Func _IowKitStartUp($sDLL="iowkit.dll") ; DLL laden, für alle anderen Funktionen wichtig
    If $ghIOWkitDll = -1 Then
    $ghIOWkitDll = DLLOpen($sDLL)
    EndIf
    Return $ghIOWkitDll <> -1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;IOWKIT_HANDLE IOWKIT_API IowKitOpenDevice(void);
    Func _IowKitOpenDevice()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitOpenDevice")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;void IOWKIT_API IowKitCloseDevice(IOWKIT_HANDLE devHandle);
    Func _IowKitCloseDevice($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitCloseDevice", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ...

    [/autoit]
  • Ok, super, danke dir. Ich habe alles mir verständliche nach deiner super Hilfe verändert. Allerdings, bleibe ich noch ganz unten etwas hängen. Ich glaube ich stehe auf dem Schlauch. Die ganzen ULONG und BOOL machen mir zu schaffen. Sind die genauso zu erledigen wie voids ? Hier mein bisheriger Erfolg:

    Spoiler anzeigen
    [autoit]

    //
    // IO-Warrior kit library V1.5 include file
    //

    [/autoit] [autoit][/autoit] [autoit]

    // IOW Library definitions
    #ifndef _IOW_KIT_H_
    #define _IOW_KIT_H_

    [/autoit] [autoit][/autoit] [autoit]

    #ifndef _IOWKIT_BUILD_RUN
    #ifdef _IOWKIT2_H_
    #error "including both iowkit2.h and iowkit.h is not allowed"
    #endif // _IOWKIT2_H_
    #endif // _IOWKIT_BUILD_RUN

    [/autoit] [autoit][/autoit] [autoit]

    #ifdef _WIN32

    [/autoit] [autoit][/autoit] [autoit]

    #define IOWKIT_API __stdcall

    [/autoit] [autoit][/autoit] [autoit]

    #else

    [/autoit] [autoit][/autoit] [autoit]

    #define IOWKIT_API

    [/autoit] [autoit][/autoit] [autoit]

    // the following legacy types can only be defined once
    #ifndef _IOW_WINTYPES_H_
    #define _IOW_WINTYPES_H_

    [/autoit] [autoit][/autoit] [autoit]

    /*
    * Windows specific types and defines
    */
    typedef unsigned long ULONG;
    typedef long LONG;
    typedef unsigned short USHORT;
    typedef unsigned short WORD;
    typedef unsigned char UCHAR;
    typedef unsigned char BYTE;
    typedef char * PCHAR;
    typedef unsigned short * PWCHAR;
    typedef int BOOL;
    typedef unsigned char BOOLEAN;
    typedef unsigned long DWORD;
    typedef DWORD * PDWORD;
    typedef void * PVOID;
    typedef DWORD HANDLE;
    typedef ULONG * PULONG;
    typedef const char * PCSTR;
    typedef const unsigned short * PWCSTR;

    [/autoit] [autoit][/autoit] [autoit]

    #define FALSE 0
    #define TRUE 1

    [/autoit] [autoit][/autoit] [autoit]

    #endif // _IOW_WINTYPES_H_

    [/autoit] [autoit][/autoit] [autoit]

    #endif // _WIN32

    [/autoit] [autoit][/autoit] [autoit]

    // IO-Warrior vendor & product IDs
    Global Const $IOWKIT_VENDOR_ID = 0x07c0
    Global Const $IOWKIT_VID = $IOWKIT_VENDOR_ID
    // IO-Warrior 40
    Global Const $IOWKIT_PRODUCT_ID_IOW40= 0x1500
    Global Const $IOWKIT_PID_IOW40= $IOWKIT_PRODUCT_ID_IOW40
    // IO-Warrior 24
    Global Const $IOWKIT_PRODUCT_ID_IOW24= 0x1501
    Global Const $IOWKIT_PID_IOW24 = $IOWKIT_PRODUCT_ID_IOW24
    // IO-Warrior PowerVampire
    Global Const $IOWKIT_PRODUCT_ID_IOWPV1= 0x1511
    Global Const $IOWKIT_PID_IOWPV1= $IOWKIT_PRODUCT_ID_IOWPV1
    Global Const $IOWKIT_PRODUCT_ID_IOWPV2= 0x1512
    Global Const $IOWKIT_PID_IOWPV2 = $IOWKIT_PRODUCT_ID_IOWPV2
    // IO-Warrior 56
    Global Const $IOWKIT_PRODUCT_ID_IOW56= 0x1503
    Global Const $IOWKIT_PID_IOW56= $IOWKIT_PRODUCT_ID_IOW56

    [/autoit] [autoit][/autoit] [autoit]

    // Max number of pipes per IOW device
    Global Const $IOWKIT_MAX_PIPES= 2

    [/autoit] [autoit][/autoit] [autoit]

    // pipe names
    Global Const $IOW_PIPE_IO_PINS= 0
    Global Const $IOW_PIPE_SPECIAL_MODE= 1

    [/autoit] [autoit][/autoit] [autoit]

    // Max number of IOW devices in system
    Global Const $IOWKIT_MAX_DEVICES= 16
    // IOW Legacy devices open modes
    Global Const $IOW_OPEN_SIMPLE= 1
    Global Const $IOW_OPEN_COMPLEX = 2

    [/autoit] [autoit][/autoit] [autoit]

    // first IO-Warrior revision with serial numbers
    Global Const $IOW_NON_LEGACY_REVISION= 0x1010

    [/autoit] [autoit][/autoit] [autoit]

    // Don't forget to pack it!
    #pragma pack(push, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $tagIOWKIT_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT40_IO_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT24_IO_REPORT = "align 1;byte ReportID; WORD Value;"
    Global Const $tagIOWKIT_SPECIAL_REPORT = "align 1;byte ReportID;" ; Muss hier auch DWORD Value stehen ?
    Global Const $tagIOWKIT56_IO_REPORT = "align 1;byte ReportID;" ; Muss hier auch DWORD Value stehen ?
    Global Const $tagIOWKIT56_SPECIAL_REPORT = "align 1;byte ReportID;"; Muss hier auch DWORD Value stehen ?

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $IOWKIT_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_REPORT, 1))
    Global Const $IOWKIT40_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT40_IO_REPORT, 1))
    Global Const $IOWKIT24_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT24_IO_REPORT, 1))
    Global Const $IOWKIT_SPECIAL_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_SPECIAL_REPORT, 1))
    Global Const $IOWKIT56_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT56_IO_REPORT, 1))
    Global Const $IOWKIT56_SPECIAL_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT56_SPECIAL_REPORT, 1))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #pragma pack(pop)

    [/autoit] [autoit][/autoit] [autoit]

    // Opaque IO-Warrior handle
    Global $ghIOWkitDll=-1
    Func _IowKitStartUp($sDLL="iowkit.dll") ; DLL laden, für alle anderen Funktionen wichtig
    If $ghIOWkitDll = -1 Then
    $ghIOWkitDll = DLLOpen($sDLL)
    EndIf
    Return $ghIOWkitDll <> -1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    // Function prototypes

    [/autoit] [autoit][/autoit] [autoit]

    #ifdef __cplusplus
    extern "C" {
    #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    IOWKIT_HANDLE IOWKIT_API IowKitOpenDevice(void);
    Func _IowKitOpenDevice()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitOpenDevice")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    void IOWKIT_API IowKitCloseDevice(IOWKIT_HANDLE devHandle);
    Func _IowKitCloseDevice($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitCloseDevice", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ULONG IOWKIT_API IowKitWrite(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);
    ULONG IOWKIT_API IowKitRead(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);
    ULONG IOWKIT_API IowKitReadNonBlocking(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);
    BOOL IOWKIT_API IowKitReadImmediate(IOWKIT_HANDLE devHandle, PDWORD value);
    ULONG IOWKIT_API IowKitGetNumDevs(void);
    IOWKIT_HANDLE IOWKIT_API IowKitGetDeviceHandle(ULONG numDevice);
    BOOL IOWKIT_API IowKitSetLegacyOpenMode(ULONG legacyOpenMode);
    ULONG IOWKIT_API IowKitGetProductId(IOWKIT_HANDLE devHandle);
    ULONG IOWKIT_API IowKitGetRevision(IOWKIT_HANDLE devHandle);
    HANDLE IOWKIT_API IowKitGetThreadHandle(IOWKIT_HANDLE devHandle);
    BOOL IOWKIT_API IowKitGetSerialNumber(IOWKIT_HANDLE devHandle, PWCHAR serialNumber);
    BOOL IOWKIT_API IowKitSetTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    BOOL IOWKIT_API IowKitSetWriteTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    BOOL IOWKIT_API IowKitCancelIo(IOWKIT_HANDLE devHandle, ULONG numPipe);
    PCSTR IOWKIT_API IowKitVersion(void);

    [/autoit] [autoit][/autoit] [autoit]

    #ifdef __cplusplus
    }
    #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    #endif // _IOW_KIT_H_

    [/autoit]


    Nachtrag:

    Habe mir das nochmal angeschaut, und verstanden: Momentan stehe ich hier. Mir fehlt unten noch ein paar Zeilen:

    Spoiler anzeigen
    [autoit]

    //
    //
    // IO-Warrior kit library V1.5 include file
    //

    [/autoit] [autoit][/autoit] [autoit]

    // IOW Library definitions
    #ifndef _IOW_KIT_H_
    #define _IOW_KIT_H_

    [/autoit] [autoit][/autoit] [autoit]

    #ifndef _IOWKIT_BUILD_RUN
    #ifdef _IOWKIT2_H_
    #error "including both iowkit2.h and iowkit.h is not allowed"
    #endif // _IOWKIT2_H_
    #endif // _IOWKIT_BUILD_RUN

    [/autoit] [autoit][/autoit] [autoit]

    #ifdef _WIN32

    [/autoit] [autoit][/autoit] [autoit]

    #define IOWKIT_API __stdcall

    [/autoit] [autoit][/autoit] [autoit]

    #else

    [/autoit] [autoit][/autoit] [autoit]

    #define IOWKIT_API

    [/autoit] [autoit][/autoit] [autoit]

    // the following legacy types can only be defined once
    #ifndef _IOW_WINTYPES_H_
    #define _IOW_WINTYPES_H_

    [/autoit] [autoit][/autoit] [autoit]

    /*
    * Windows specific types and defines
    */
    typedef unsigned long ULONG;
    typedef long LONG;
    typedef unsigned short USHORT;
    typedef unsigned short WORD;
    typedef unsigned char UCHAR;
    typedef unsigned char BYTE;
    typedef char * PCHAR;
    typedef unsigned short * PWCHAR;
    typedef int BOOL;
    typedef unsigned char BOOLEAN;
    typedef unsigned long DWORD;
    typedef DWORD * PDWORD;
    typedef void * PVOID;
    typedef DWORD HANDLE;
    typedef ULONG * PULONG;
    typedef const char * PCSTR;
    typedef const unsigned short * PWCSTR;

    [/autoit] [autoit][/autoit] [autoit]

    #define FALSE 0
    #define TRUE 1

    [/autoit] [autoit][/autoit] [autoit]

    #endif // _IOW_WINTYPES_H_

    [/autoit] [autoit][/autoit] [autoit]

    #endif // _WIN32

    [/autoit] [autoit][/autoit] [autoit]

    // IO-Warrior vendor & product IDs
    Global Const $IOWKIT_VENDOR_ID = 0x07c0
    Global Const $IOWKIT_VID = $IOWKIT_VENDOR_ID
    // IO-Warrior 40
    Global Const $IOWKIT_PRODUCT_ID_IOW40 = 0x1500
    Global Const $IOWKIT_PID_IOW40 = $IOWKIT_PRODUCT_ID_IOW40
    // IO-Warrior 24
    Global Const $IOWKIT_PRODUCT_ID_IOW24 = 0x1501
    Global Const $IOWKIT_PID_IOW24 = $IOWKIT_PRODUCT_ID_IOW24
    // IO-Warrior PowerVampire
    Global Const $IOWKIT_PRODUCT_ID_IOWPV1 = 0x1511
    Global Const $IOWKIT_PID_IOWPV1 = $IOWKIT_PRODUCT_ID_IOWPV1
    Global Const $IOWKIT_PRODUCT_ID_IOWPV2 = 0x1512
    Global Const $IOWKIT_PID_IOWPV2 = $IOWKIT_PRODUCT_ID_IOWPV2
    // IO-Warrior 56
    Global Const $IOWKIT_PRODUCT_ID_IOW56 = 0x1503
    Global Const $IOWKIT_PID_IOW56 = $IOWKIT_PRODUCT_ID_IOW56

    [/autoit] [autoit][/autoit] [autoit]

    // Max number of pipes per IOW device
    Global Const $IOWKIT_MAX_PIPES = 2

    [/autoit] [autoit][/autoit] [autoit]

    // pipe names
    Global Const $IOW_PIPE_IO_PINS = 0
    Global Const $IOW_PIPE_SPECIAL_MODE = 1

    [/autoit] [autoit][/autoit] [autoit]

    // Max number of IOW devices in system
    Global Const $IOWKIT_MAX_DEVICES = 16
    // IOW Legacy devices open modes
    Global Const $IOW_OPEN_SIMPLE = 1
    Global Const $IOW_OPEN_COMPLEX = 2

    [/autoit] [autoit][/autoit] [autoit]

    // first IO-Warrior revision with serial numbers
    Global Const $IOW_NON_LEGACY_REVISION = 0x1010

    [/autoit] [autoit][/autoit] [autoit]

    // Don't forget to pack it!
    #pragma pack(push, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $tagIOWKIT_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT40_IO_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT24_IO_REPORT = "align 1;byte ReportID; WORD Value;"
    Global Const $tagIOWKIT_SPECIAL_REPORT = "align 1;byte ReportID;" ; Muss hier auch DWORD Value stehen ?
    Global Const $tagIOWKIT56_IO_REPORT = "align 1;byte ReportID;" ; Muss hier auch DWORD Value stehen ?
    Global Const $tagIOWKIT56_SPECIAL_REPORT = "align 1;byte ReportID;" ; Muss hier auch DWORD Value stehen ?

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $IOWKIT_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_REPORT, 1))
    Global Const $IOWKIT40_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT40_IO_REPORT, 1))
    Global Const $IOWKIT24_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT24_IO_REPORT, 1))
    Global Const $IOWKIT_SPECIAL_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_SPECIAL_REPORT, 1))
    Global Const $IOWKIT56_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT56_IO_REPORT, 1))
    Global Const $IOWKIT56_SPECIAL_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT56_SPECIAL_REPORT, 1))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #pragma pack(pop)

    [/autoit] [autoit][/autoit] [autoit]

    // Opaque IO-Warrior handle
    Global $ghIOWkitDll=-1
    Func _IowKitStartUp($sDLL="iowkit.dll") ; DLL laden, für alle anderen Funktionen wichtig
    If $ghIOWkitDll = -1 Then
    $ghIOWkitDll = DLLOpen($sDLL)
    EndIf
    Return $ghIOWkitDll <> -1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    // Function prototypes

    [/autoit] [autoit][/autoit] [autoit]

    #ifdef __cplusplus
    extern "C" {
    #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    ;~ IOWKIT_HANDLE IOWKIT_API IowKitOpenDevice(void);
    Func _IowKitOpenDevice()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitOpenDevice")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ void IOWKIT_API IowKitCloseDevice(IOWKIT_HANDLE devHandle);
    Func _IowKitCloseDevice($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitCloseDevice", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ULONG IOWKIT_API IowKitWrite(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);

    ULONG IOWKIT_API IowKitRead(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);

    ULONG IOWKIT_API IowKitReadNonBlocking(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);

    BOOL IOWKIT_API IowKitReadImmediate(IOWKIT_HANDLE devHandle, PDWORD value);

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitGetNumDevs(void);
    Func _IowKitGetNumDevs()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitGetNumDevs")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ IOWKIT_HANDLE IOWKIT_API IowKitGetDeviceHandle(ULONG numDevice);
    Func _IowKitGetDeviceHandle($numDevice)
    DLLCall($ghIOWkitDll, "none", "IowKitGetDeviceHandle", "ptr", $numDevice)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitSetLegacyOpenMode(ULONG legacyOpenMode);
    Func _IowKitSetLegacyOpenMode($legacyOpenMode)
    DLLCall($ghIOWkitDll, "none", "IowKitSetLegacyOpenMode", "ptr", $legacyOpenMode)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ ULONG IOWKIT_API IowKitGetProductId(IOWKIT_HANDLE devHandle);
    Func _IowKitGetProductId($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetProductId", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ ULONG IOWKIT_API IowKitGetRevision(IOWKIT_HANDLE devHandle);
    Func _IowKitGetRevision($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetRevision", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ HANDLE IOWKIT_API IowKitGetThreadHandle(IOWKIT_HANDLE devHandle);
    Func _IowKitGetThreadHandle($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetThreadHandle", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ BOOL IOWKIT_API IowKitGetSerialNumber(IOWKIT_HANDLE devHandle, PWCHAR serialNumber);
    Func _IowKitGetSerialNumber($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetSerialNumber", "ptr", $devHandle) ; Fehlt hier noch die serialNumber ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ BOOL IOWKIT_API IowKitSetTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    Func _IowKitSetTimeout($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitSetTimeout", "ptr", $devHandle); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ BOOL IOWKIT_API IowKitSetWriteTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    Func _IowKitSetWriteTimeout($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitSetWriteTimeout", "ptr", $devHandle); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ BOOL IOWKIT_API IowKitCancelIo(IOWKIT_HANDLE devHandle, ULONG numPipe);
    Func _IowKitCancelIo($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitCancelIo", "ptr", $devHandle); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ PCSTR IOWKIT_API IowKitVersion(void);
    Func _IowKitVersion()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitVersion")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    #ifdef __cplusplus
    }
    #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    #endif // _IOW_KIT_H_

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • Also, alles, was vor Zeile 54 steht, kannst du einfach weglassen. Was du beim DLLCall mit den Typen machen musst, steht in der AutoIt-Hilfe unter DLLCall.
    (ULONG bleibt ULONG, BOOL bleibt BOOL, PCSTR wird STR usw ;) )
    Die ganzen Zeilen, die mit // Anfangen sind Kommentare, also das AutoIt-KOmmentarzeichen davorsetzen.
    Zeile 90, 107, 121-123 und 157-161 brauchst du auch nicht --> auskommentieren (im ersten Spoiler, beim 2. sind die Nummern anders)

    Die DLLStructs sind so:

    [autoit]

    Global Const $tagIOWKIT_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT40_IO_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT24_IO_REPORT = "align 1;byte ReportID; WORD Value;"
    Global Const $tagIOWKIT_SPECIAL_REPORT = "align 1;byte ReportID; byte Bytes[7];"
    Global Const $tagIOWKIT56_IO_REPORT = "align 1;byte ReportID; byte Bytes[7];"
    Global Const $tagIOWKIT56_SPECIAL_REPORT = "align 1;byte ReportID; byte Bytes[63];"

    [/autoit][autoit][/autoit][autoit][/autoit]

    PS: PDWORD wird DWORD*, also Pointer auif DWORD. Das muss dann auch in der AutoIt-Funktion ein byREf-Parameter sein. Wenn du alles fertig hast, kann ich ja nochmal drüberschauen.

  • Ok, die Zeilen bis 54 sind weg. Die DLLStructs sind verändert. Nun fehlt nurnoch die Zeilen, die Du meinst auszuklammern, Das Problem ist, das ich in den von dir angegebenen Zeilen leider keine Befehle drinnen habe. Die sind leer. Nun weis ich nciht, ob du meinst, das es zu viele leerzeilen sind, oder Befehle. Hier ist nochmal mein Script. Weil ich gesehen habe, das wenn ich es hier einbinde, das die Zeilenzahl mit den Zeilen verrutscht sind ;( kann ich leider nciht rausfinden welche Zeilen du meinst. Wenn du mir z.B. Zeile 90 sagst, udn den Befehlhinschreibst, dann wäre das super. Dann kann ich mich ab der Zeile orientieren.
    Dann kenne ich auch die anderen Zeilen.
    Ach, die Komentarzeichen sind nun auch verändert.

    Kann es sein, das du folgende Zeilen meinst:

    #pragma pack(push, 1)
    #pragma pack(pop)
    #ifdef __cplusplus
    extern "C" {
    #endif // __cplusplus
    #ifdef __cplusplus
    }
    #endif // __cplusplus

    #endif // _IOW_KIT_H_

    Spoiler anzeigen
    [autoit]

    ;~ IO-Warrior vendor & product IDs
    Global Const $IOWKIT_VENDOR_ID = 0x07c0
    Global Const $IOWKIT_VID = $IOWKIT_VENDOR_ID
    ;~ IO-Warrior 40
    Global Const $IOWKIT_PRODUCT_ID_IOW40= 0x1500
    Global Const $IOWKIT_PID_IOW40 = $IOWKIT_PRODUCT_ID_IOW40
    ;~ IO-Warrior 24
    Global Const $IOWKIT_PRODUCT_ID_IOW24= 0x1501
    Global Const $IOWKIT_PID_IOW24 = $IOWKIT_PRODUCT_ID_IOW24
    ;~ IO-Warrior PowerVampire
    Global Const $IOWKIT_PRODUCT_ID_IOWPV1= 0x1511
    Global Const $IOWKIT_PID_IOWPV1 = $IOWKIT_PRODUCT_ID_IOWPV1
    Global Const $IOWKIT_PRODUCT_ID_IOWPV2= 0x1512
    Global Const $IOWKIT_PID_IOWPV2 = $IOWKIT_PRODUCT_ID_IOWPV2
    ;~ IO-Warrior 56
    Global Const $IOWKIT_PRODUCT_ID_IOW56= 0x1503
    Global Const $IOWKIT_PID_IOW56 = $IOWKIT_PRODUCT_ID_IOW56

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Max number of pipes per IOW device
    Global Const $IOWKIT_MAX_PIPES = 2

    [/autoit] [autoit][/autoit] [autoit]

    ;~ pipe names
    Global Const $IOW_PIPE_IO_PINS = 0
    Global Const $IOW_PIPE_SPECIAL_MODE = 1

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Max number of IOW devices in system
    Global Const $IOWKIT_MAX_DEVICES = 16
    ;~ IOW Legacy devices open modes
    Global Const $IOW_OPEN_SIMPLE = 1
    Global Const $IOW_OPEN_COMPLEX = 2

    [/autoit] [autoit][/autoit] [autoit]

    ;~ first IO-Warrior revision with serial numbers
    Global Const $IOW_NON_LEGACY_REVISION= 0x1010

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Don't forget to pack it!
    #pragma pack(push, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $tagIOWKIT_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT40_IO_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT24_IO_REPORT = "align 1;byte ReportID; WORD Value;"
    Global Const $tagIOWKIT_SPECIAL_REPORT = "align 1;byte ReportID; byte Bytes[7];"
    Global Const $tagIOWKIT56_IO_REPORT = "align 1;byte ReportID; byte Bytes[7];"
    Global Const $tagIOWKIT56_SPECIAL_REPORT = "align 1;byte ReportID; byte Bytes[63];"

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $IOWKIT_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_REPORT, 1))
    Global Const $IOWKIT40_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT40_IO_REPORT, 1))
    Global Const $IOWKIT24_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT24_IO_REPORT, 1))
    Global Const $IOWKIT_SPECIAL_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_SPECIAL_REPORT, 1))
    Global Const $IOWKIT56_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT56_IO_REPORT, 1))
    Global Const $IOWKIT56_SPECIAL_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT56_SPECIAL_REPORT, 1))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #pragma pack(pop)

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Opaque IO-Warrior handle
    Global $ghIOWkitDll=-1
    Func _IowKitStartUp($sDLL="iowkit.dll") ; DLL laden, für alle anderen Funktionen wichtig
    If $ghIOWkitDll = -1 Then
    $ghIOWkitDll = DLLOpen($sDLL)
    EndIf
    Return $ghIOWkitDll <> -1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;~ Function prototypes

    [/autoit] [autoit][/autoit] [autoit]

    #ifdef __cplusplus
    extern "C" {
    #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    ;~ IOWKIT_HANDLE IOWKIT_API IowKitOpenDevice(void);
    Func _IowKitOpenDevice()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitOpenDevice")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ void IOWKIT_API IowKitCloseDevice(IOWKIT_HANDLE devHandle);
    Func _IowKitCloseDevice($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitCloseDevice", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ULONG IOWKIT_API IowKitWrite(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);

    ULONG IOWKIT_API IowKitRead(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);

    ULONG IOWKIT_API IowKitReadNonBlocking(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);

    BOOL IOWKIT_API IowKitReadImmediate(IOWKIT_HANDLE devHandle, PDWORD value);

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitGetNumDevs(void);
    Func _IowKitGetNumDevs()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitGetNumDevs")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ IOWKIT_HANDLE IOWKIT_API IowKitGetDeviceHandle(ULONG numDevice);
    Func _IowKitGetDeviceHandle($numDevice)
    DLLCall($ghIOWkitDll, "none", "IowKitGetDeviceHandle", "ptr", $numDevice)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitSetLegacyOpenMode(ULONG legacyOpenMode);
    Func _IowKitSetLegacyOpenMode($legacyOpenMode)
    DLLCall($ghIOWkitDll, "none", "IowKitSetLegacyOpenMode", "ptr", $legacyOpenMode)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitGetProductId(IOWKIT_HANDLE devHandle);
    Func _IowKitGetProductId($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetProductId", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitGetRevision(IOWKIT_HANDLE devHandle);
    Func _IowKitGetRevision($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetRevision", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ HANDLE IOWKIT_API IowKitGetThreadHandle(IOWKIT_HANDLE devHandle);
    Func _IowKitGetThreadHandle($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetThreadHandle", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitGetSerialNumber(IOWKIT_HANDLE devHandle, PWCHAR serialNumber);
    Func _IowKitGetSerialNumber($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetSerialNumber", "ptr", $devHandle) ; Fehlt hier noch die serialNumber ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitSetTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    Func _IowKitSetTimeout($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitSetTimeout", "ptr", $devHandle); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitSetWriteTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    Func _IowKitSetWriteTimeout($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitSetWriteTimeout", "ptr", $devHandle); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitCancelIo(IOWKIT_HANDLE devHandle, ULONG numPipe);
    Func _IowKitCancelIo($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitCancelIo", "ptr", $devHandle); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ PCSTR IOWKIT_API IowKitVersion(void);
    Func _IowKitVersion()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitVersion")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    #ifdef __cplusplus
    }
    #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    #endif // _IOW_KIT_H_

    [/autoit]


    Ich glaube schon ;) So, und die Dlls mache ich morgen.

    PS: Ich habe dein PS erst jetzt gesehen. Ja, also gut ich habe mir in der Hilfe Datei aben die Dll-Funktion angeschaut, und werde das dann morgen fertigstellen. Auch hier nochmal ein großes Danke an Dich, und hast ne schöne HP ;)

    PSS: Zeile 90, 107, 121-123 und 157-161 brauchst du auch nicht --> auskommentieren (im ersten Spoiler, beim 2. sind die Nummern anders) <-- Kann ich leider nicht finden, was du mit 2. meinst

  • Genau, ich meine das #ifdef, #pragma usw ;)

    Edit: Der 2. Spoiler ist der Spoiler aus deinem Nachtrag.

  • Also beim ersten Spoiler der 2. Spoiler. Welche Nummern.. ?

    Sorry wenn ich so dumm Frage, und du soviel Gedult mit mir brauchst, aber es gibt so viele Zahlen 8o

    Edit:
    Ah, also die Zeilen meinst du...

    Ja, aber am Script ist ja damit nichts falsch... Hast mir schon einen Schrecken eingejagt ;)

    lg Tim


    PS: Stop der Verwirrung :cursing: . Ich habe es nun endgültig verstanden !!! Du meinst deine Zeilenangaben beziehen sich auf meinen ersten Spoiler. Nicht auf meinen Zweiten. OK !!! DANKE DIR ^^

  • Also, nun habe ich soweit eigentlich alles geändert. Musst unten mal schauen, ob das so ok ist. Habe es grün eingerahmt.

    Spoiler anzeigen
    [autoit]

    ;~ IO-Warrior vendor & product IDs
    Global Const $IOWKIT_VENDOR_ID = 0x07c0
    Global Const $IOWKIT_VID = $IOWKIT_VENDOR_ID
    ;~ IO-Warrior 40
    Global Const $IOWKIT_PRODUCT_ID_IOW40 = 0x1500
    Global Const $IOWKIT_PID_IOW40 = $IOWKIT_PRODUCT_ID_IOW40
    ;~ IO-Warrior 24
    Global Const $IOWKIT_PRODUCT_ID_IOW24 = 0x1501
    Global Const $IOWKIT_PID_IOW24 = $IOWKIT_PRODUCT_ID_IOW24
    ;~ IO-Warrior PowerVampire
    Global Const $IOWKIT_PRODUCT_ID_IOWPV1 = 0x1511
    Global Const $IOWKIT_PID_IOWPV1 = $IOWKIT_PRODUCT_ID_IOWPV1
    Global Const $IOWKIT_PRODUCT_ID_IOWPV2 = 0x1512
    Global Const $IOWKIT_PID_IOWPV2 = $IOWKIT_PRODUCT_ID_IOWPV2
    ;~ IO-Warrior 56
    Global Const $IOWKIT_PRODUCT_ID_IOW56 = 0x1503
    Global Const $IOWKIT_PID_IOW56 = $IOWKIT_PRODUCT_ID_IOW56

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Max number of pipes per IOW device
    Global Const $IOWKIT_MAX_PIPES = 2

    [/autoit] [autoit][/autoit] [autoit]

    ;~ pipe names
    Global Const $IOW_PIPE_IO_PINS = 0
    Global Const $IOW_PIPE_SPECIAL_MODE = 1

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Max number of IOW devices in system
    Global Const $IOWKIT_MAX_DEVICES = 16
    ;~ IOW Legacy devices open modes
    Global Const $IOW_OPEN_SIMPLE = 1
    Global Const $IOW_OPEN_COMPLEX = 2

    [/autoit] [autoit][/autoit] [autoit]

    ;~ first IO-Warrior revision with serial numbers
    Global Const $IOW_NON_LEGACY_REVISION = 0x1010

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Don't forget to pack it!
    ;~ #pragma pack(push, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $tagIOWKIT_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT40_IO_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT24_IO_REPORT = "align 1;byte ReportID; WORD Value;"
    Global Const $tagIOWKIT_SPECIAL_REPORT = "align 1;byte ReportID; byte Bytes[7];"
    Global Const $tagIOWKIT56_IO_REPORT = "align 1;byte ReportID; byte Bytes[7];"
    Global Const $tagIOWKIT56_SPECIAL_REPORT = "align 1;byte ReportID; byte Bytes[63];"

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $IOWKIT_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_REPORT, 1))
    Global Const $IOWKIT40_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT40_IO_REPORT, 1))
    Global Const $IOWKIT24_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT24_IO_REPORT, 1))
    Global Const $IOWKIT_SPECIAL_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT_SPECIAL_REPORT, 1))
    Global Const $IOWKIT56_IO_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT56_IO_REPORT, 1))
    Global Const $IOWKIT56_SPECIAL_REPORT_SIZE = DLLStructGetSize(DLLStructCreate($tagIOWKIT56_SPECIAL_REPORT, 1))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;~ #pragma pack(pop)

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Opaque IO-Warrior handle
    Global $ghIOWkitDll=-1
    Func _IowKitStartUp($sDLL="iowkit.dll") ; DLL laden, für alle anderen Funktionen wichtig
    If $ghIOWkitDll = -1 Then
    $ghIOWkitDll = DLLOpen($sDLL)
    EndIf
    Return $ghIOWkitDll <> -1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;~ Function prototypes

    [/autoit] [autoit][/autoit] [autoit]

    ;~ #ifdef __cplusplus
    ;~ extern "C" {
    ;~ #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    ;~ IOWKIT_HANDLE IOWKIT_API IowKitOpenDevice(void);
    Func _IowKitOpenDevice()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitOpenDevice")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ void IOWKIT_API IowKitCloseDevice(IOWKIT_HANDLE devHandle);
    Func _IowKitCloseDevice($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitCloseDevice", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;--------------------------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitWrite(IOWKIT_HANDLE devHandle, ULONG numPipe,
    ;~ PCHAR buffer, ULONG length);
    Func _IowKitWrite($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitWrite", "ptr", $devHandle,"ULONG ","PCHAR","ULONG")
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ ULONG IOWKIT_API IowKitRead(IOWKIT_HANDLE devHandle, ULONG numPipe,
    ;~ PCHAR buffer, ULONG length);
    Func _IowKitRead($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitRead", "ptr", $devHandle,"ULONG ","PCHAR","ULONG")
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ ULONG IOWKIT_API IowKitReadNonBlocking(IOWKIT_HANDLE devHandle, ULONG numPipe,
    ;~ PCHAR buffer, ULONG length);
    Func _IowKitReadNonBlocking($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitReadNonBlocking", "ptr", $devHandle,"ULONG ","PCHAR","ULONG")
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ BOOL IOWKIT_API IowKitReadImmediate(IOWKIT_HANDLE devHandle, PDWORD value);
    Func _IowKitReadImmediate($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitReadImmediate", "ptr", $devHandle,"PDWORD ")
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;--------------------------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitGetNumDevs(void);
    Func _IowKitGetNumDevs()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitGetNumDevs")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ IOWKIT_HANDLE IOWKIT_API IowKitGetDeviceHandle(ULONG numDevice);
    Func _IowKitGetDeviceHandle($numDevice)
    DLLCall($ghIOWkitDll, "none", "IowKitGetDeviceHandle", "ptr", $numDevice)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitSetLegacyOpenMode(ULONG legacyOpenMode);
    Func _IowKitSetLegacyOpenMode($legacyOpenMode)
    DLLCall($ghIOWkitDll, "none", "IowKitSetLegacyOpenMode", "ptr", $legacyOpenMode)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ ULONG IOWKIT_API IowKitGetProductId(IOWKIT_HANDLE devHandle);
    Func _IowKitGetProductId($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetProductId", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ ULONG IOWKIT_API IowKitGetRevision(IOWKIT_HANDLE devHandle);
    Func _IowKitGetRevision($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetRevision", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ HANDLE IOWKIT_API IowKitGetThreadHandle(IOWKIT_HANDLE devHandle);
    Func _IowKitGetThreadHandle($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetThreadHandle", "ptr", $devHandle)
    If @error Then Return SetError(1,@error, 0)
    EndFunc


    ;--------------------------------------------------------------------------------------------------

    ;~ BOOL IOWKIT_API IowKitGetSerialNumber(IOWKIT_HANDLE devHandle, PWCHAR serialNumber);
    Func _IowKitGetSerialNumber($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitGetSerialNumber", "ptr", $devHandle, "PWCHAR") ; Fehlt hier noch die serialNumber ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ BOOL IOWKIT_API IowKitSetTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    Func _IowKitSetTimeout($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitSetTimeout", "ptr", $devHandle, "ULONG"); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ BOOL IOWKIT_API IowKitSetWriteTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    Func _IowKitSetWriteTimeout($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitSetWriteTimeout", "ptr", $devHandle, "ULONG"); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;~ BOOL IOWKIT_API IowKitCancelIo(IOWKIT_HANDLE devHandle, ULONG numPipe);
    Func _IowKitCancelIo($devHandle)
    DLLCall($ghIOWkitDll, "none", "IowKitCancelIo", "ptr", $devHandle, "ULONG"); Fehlt hier noch der ULONG ?
    If @error Then Return SetError(1,@error, 0)
    EndFunc

    ;--------------------------------------------------------------------------------------------------


    ;~ PCSTR IOWKIT_API IowKitVersion(void);
    Func _IowKitVersion()
    Local $aResult = DLLCall($ghIOWkitDll, "ptr", "IowKitVersion")
    If @error Then Return SetError(1,@error, 0)
    Return $aResult[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ #ifdef __cplusplus
    ;~ }
    ;~ #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    ;~ #endif // _IOW_KIT_H_

    [/autoit]
  • Ein paar Fehler waren noch drin. Vergleiche doch bitte meine Korrekturen mit deiner Datei, dann kannst du es in Zukunft auch.
    PS: Ich konnte es nicht testen.

    Spoiler anzeigen
    [autoit]

    #include-once
    ;~ IO-Warrior vendor & product IDs
    Global Const $IOWKIT_VENDOR_ID = 0x07c0
    Global Const $IOWKIT_VID = $IOWKIT_VENDOR_ID
    ;~ IO-Warrior 40
    Global Const $IOWKIT_PRODUCT_ID_IOW40 = 0x1500
    Global Const $IOWKIT_PID_IOW40 = $IOWKIT_PRODUCT_ID_IOW40
    ;~ IO-Warrior 24
    Global Const $IOWKIT_PRODUCT_ID_IOW24 = 0x1501
    Global Const $IOWKIT_PID_IOW24 = $IOWKIT_PRODUCT_ID_IOW24
    ;~ IO-Warrior PowerVampire
    Global Const $IOWKIT_PRODUCT_ID_IOWPV1 = 0x1511
    Global Const $IOWKIT_PID_IOWPV1 = $IOWKIT_PRODUCT_ID_IOWPV1
    Global Const $IOWKIT_PRODUCT_ID_IOWPV2 = 0x1512
    Global Const $IOWKIT_PID_IOWPV2 = $IOWKIT_PRODUCT_ID_IOWPV2
    ;~ IO-Warrior 56
    Global Const $IOWKIT_PRODUCT_ID_IOW56 = 0x1503
    Global Const $IOWKIT_PID_IOW56 = $IOWKIT_PRODUCT_ID_IOW56

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Max number of pipes per IOW device
    Global Const $IOWKIT_MAX_PIPES = 2

    [/autoit] [autoit][/autoit] [autoit]

    ;~ pipe names
    Global Const $IOW_PIPE_IO_PINS = 0
    Global Const $IOW_PIPE_SPECIAL_MODE = 1

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Max number of IOW devices in system
    Global Const $IOWKIT_MAX_DEVICES = 16
    ;~ IOW Legacy devices open modes
    Global Const $IOW_OPEN_SIMPLE = 1
    Global Const $IOW_OPEN_COMPLEX = 2

    [/autoit] [autoit][/autoit] [autoit]

    ;~ first IO-Warrior revision with serial numbers
    Global Const $IOW_NON_LEGACY_REVISION = 0x1010

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Don't forget to pack it!
    ;~ #pragma pack(push, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $tagIOWKIT_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT40_IO_REPORT = "align 1;byte ReportID; DWORD Value;"
    Global Const $tagIOWKIT24_IO_REPORT = "align 1;byte ReportID; WORD Value;"
    Global Const $tagIOWKIT_SPECIAL_REPORT = "align 1;byte ReportID; byte Bytes[7];"
    Global Const $tagIOWKIT56_IO_REPORT = "align 1;byte ReportID; byte Bytes[7];"
    Global Const $tagIOWKIT56_SPECIAL_REPORT = "align 1;byte ReportID; byte Bytes[63];"

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $IOWKIT_REPORT_SIZE = DllStructGetSize(DllStructCreate($tagIOWKIT_REPORT, 1))
    Global Const $IOWKIT40_IO_REPORT_SIZE = DllStructGetSize(DllStructCreate($tagIOWKIT40_IO_REPORT, 1))
    Global Const $IOWKIT24_IO_REPORT_SIZE = DllStructGetSize(DllStructCreate($tagIOWKIT24_IO_REPORT, 1))
    Global Const $IOWKIT_SPECIAL_REPORT_SIZE = DllStructGetSize(DllStructCreate($tagIOWKIT_SPECIAL_REPORT, 1))
    Global Const $IOWKIT56_IO_REPORT_SIZE = DllStructGetSize(DllStructCreate($tagIOWKIT56_IO_REPORT, 1))
    Global Const $IOWKIT56_SPECIAL_REPORT_SIZE = DllStructGetSize(DllStructCreate($tagIOWKIT56_SPECIAL_REPORT, 1))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _IowKitDWORDToBytes($dword)
    ; Author: ProgAndy
    Return BinaryMid($dword, 1, 4)
    EndFunc
    Func _IowKitWORDToBytes($word)
    ; Author: ProgAndy
    Return BinaryMid($word, 1, 2)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;~ #pragma pack(pop)

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Opaque IO-Warrior handle
    Global $ghIOWkitDll = -1
    Func _IowKitStartUp($sDLL = "iowkit.dll") ; DLL laden, für alle anderen Funktionen wichtig
    If $ghIOWkitDll = -1 Then
    $ghIOWkitDll = DllOpen($sDLL)
    EndIf
    Return $ghIOWkitDll <> -1
    EndFunc ;==>_IowKitStartUp

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Function prototypes

    [/autoit] [autoit][/autoit] [autoit]

    ;~ #ifdef __cplusplus
    ;~ extern "C" {
    ;~ #endif // __cplusplus

    [/autoit] [autoit][/autoit] [autoit]

    ;~ IOWKIT_HANDLE IOWKIT_API IowKitOpenDevice(void);
    Func _IowKitOpenDevice()
    Local $aResult = DllCall($ghIOWkitDll, "ptr", "IowKitOpenDevice")
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitOpenDevice

    [/autoit] [autoit][/autoit] [autoit]

    ;~ void IOWKIT_API IowKitCloseDevice(IOWKIT_HANDLE devHandle);
    Func _IowKitCloseDevice($devHandle)
    DllCall($ghIOWkitDll, "none", "IowKitCloseDevice", "ptr", $devHandle)
    If @error Then Return SetError(1, @error, 0)
    EndFunc ;==>_IowKitCloseDevice

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;--------------------------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitWrite(IOWKIT_HANDLE devHandle, ULONG numPipe,
    ;~ PCHAR buffer, ULONG length);
    Func _IowKitWrite($devHandle, $numPipe, $buffer, $length=-1)
    ; Author: ProgAndy
    Local $pBuffer
    If IsDllStruct($buffer) Then
    $pBuffer = DllStructGetPtr($buffer)
    If $length < 1 Or $length > DllStructGetSize($buffer) Then $length = DllStructGetSize($buffer)
    ElseIf IsPtr($buffer) Then
    If $length < 0 Then Return SetError(2,0,0)
    $pBuffer = $buffer
    Else
    If $length < 1 Then $length = BinaryLen($buffer)
    Local $tBuffer = DllStructCreate("byte[" & $length & "]")
    DllStructSetData($tBuffer, 1, Binary($buffer))
    $buffer = 0 ; Speicher freigeben
    $pBuffer = DllStructGetPtr($tBuffer)
    EndIf
    Local $aResult = DllCall($ghIOWkitDll, "ulong", "IowKitWrite", "ptr", $devHandle, "ULONG", $numPipe, "ptr", $pBuffer, "ULONG", $length)
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitWrite

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitRead(IOWKIT_HANDLE devHandle, ULONG numPipe,
    ;~ PCHAR buffer, ULONG length);
    Func _IowKitRead($devHandle, $numPipe, ByRef $buffer, $length)
    ; Author: ProgAndy
    Local $pBuffer, $fInternal=False
    If IsDllStruct($buffer) Then
    $pBuffer = DllStructGetPtr($buffer)
    If $length < 1 Or $length > DllStructGetSize($buffer) Then $length = DllStructGetSize($buffer)
    ElseIf $length < 1 Then
    Return SetError(2,0,0)
    ElseIf IsPtr($buffer) Then
    $pBuffer = $buffer
    Else
    Local $tBuffer = DllStructCreate("byte[" & $length & "]")
    $pBuffer = DllStructGetPtr($tBuffer)
    $buffer = Binary('')
    $fInternal = True
    EndIf
    Local $aResult = DllCall($ghIOWkitDll, "ulong", "IowKitRead", "ptr", $devHandle, "ULONG", $numPipe, "ptr", $pBuffer, "ULONG", $length)
    If @error Then Return SetError(1, @error, 0)
    If $fInternal Then
    $buffer = DllStructGetData($tBuffer,1)
    $tBuffer = 0
    EndIf
    Return $aResult[0]
    EndFunc ;==>_IowKitRead

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitReadNonBlocking(IOWKIT_HANDLE devHandle, ULONG numPipe,
    ;~ PCHAR buffer, ULONG length);
    Func _IowKitReadNonBlocking($devHandle, $numPipe, ByRef $buffer, $length)
    ; Author: ProgAndy
    Local $pBuffer, $fInternal=False
    If IsDllStruct($buffer) Then
    $pBuffer = DllStructGetPtr($buffer)
    If $length < 1 Or $length > DllStructGetSize($buffer) Then $length = DllStructGetSize($buffer)
    ElseIf $length < 1 Then
    Return SetError(2,0,0)
    ElseIf IsPtr($buffer) Then
    $pBuffer = $buffer
    Else
    Local $tBuffer = DllStructCreate("byte[" & $length & "]")
    $pBuffer = DllStructGetPtr($tBuffer)
    $buffer = Binary('')
    $fInternal = True
    EndIf
    Local $aResult = DllCall($ghIOWkitDll, "ulong", "IowKitReadNonBlocking", "ptr", $devHandle, "ULONG", $numPipe, "ptr", $pBuffer, "ULONG", $length)
    If @error Then Return SetError(1, @error, 0)
    If $fInternal Then
    $buffer = DllStructGetData($tBuffer,1)
    $tBuffer = 0
    EndIf
    Return $aResult[0]
    EndFunc ;==>_IowKitReadNonBlocking

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitReadImmediate(IOWKIT_HANDLE devHandle, PDWORD value);
    Func _IowKitReadImmediate($devHandle, ByRef $value)
    ; Author: ProgAndy
    $value = 0
    Local $aResult = DllCall($ghIOWkitDll, "none", "IowKitReadImmediate", "ptr", $devHandle, "dword*", 0)
    If @error Then Return SetError(1, @error, 0)
    $value = $aResult[2]
    Return $aResult[0]
    EndFunc ;==>_IowKitReadImmediate

    [/autoit] [autoit][/autoit] [autoit]

    ;--------------------------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitGetNumDevs(void);
    Func _IowKitGetNumDevs()
    Local $aResult = DllCall($ghIOWkitDll, "ulong", "IowKitGetNumDevs")
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitGetNumDevs

    [/autoit] [autoit][/autoit] [autoit]

    ;~ IOWKIT_HANDLE IOWKIT_API IowKitGetDeviceHandle(ULONG numDevice);
    Func _IowKitGetDeviceHandle($numDevice)
    Local $aResult = DllCall($ghIOWkitDll, "ptr", "IowKitGetDeviceHandle", "ulong", $numDevice)
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitGetDeviceHandle

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitSetLegacyOpenMode(ULONG legacyOpenMode);
    Func _IowKitSetLegacyOpenMode($legacyOpenMode)
    Local $aResult = DllCall($ghIOWkitDll, "bool", "IowKitSetLegacyOpenMode", "ulong", $legacyOpenMode)
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitSetLegacyOpenMode

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitGetProductId(IOWKIT_HANDLE devHandle);
    Func _IowKitGetProductId($devHandle)
    Local $aResult = DllCall($ghIOWkitDll, "ulong", "IowKitGetProductId", "ptr", $devHandle)
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitGetProductId

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ULONG IOWKIT_API IowKitGetRevision(IOWKIT_HANDLE devHandle);
    Func _IowKitGetRevision($devHandle)
    Local $aResult = DllCall($ghIOWkitDll, "ulong", "IowKitGetRevision", "ptr", $devHandle)
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitGetRevision

    [/autoit] [autoit][/autoit] [autoit]

    ;~ HANDLE IOWKIT_API IowKitGetThreadHandle(IOWKIT_HANDLE devHandle);
    Func _IowKitGetThreadHandle($devHandle)
    Local $aResult = DllCall($ghIOWkitDll, "ptr", "IowKitGetThreadHandle", "ptr", $devHandle)
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitGetThreadHandle

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;--------------------------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitGetSerialNumber(IOWKIT_HANDLE devHandle, PWCHAR serialNumber);
    Func _IowKitGetSerialNumber($devHandle, ByRef $serialNumber)
    $serialNumber = ''
    Local $aResult = DllCall($ghIOWkitDll, "bool", "IowKitGetSerialNumber", "ptr", $devHandle, "wstr", '')
    If @error Then Return SetError(1, @error, 0)
    $serialNumber = $aResult[2]
    Return $aResult[0]
    EndFunc ;==>_IowKitGetSerialNumber

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitSetTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    Func _IowKitSetTimeout($devHandle, $timeout)
    Local $aResult = DllCall($ghIOWkitDll, "bool", "IowKitSetTimeout", "ptr", $devHandle, "ULONG", $timeout)
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitSetTimeout

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitSetWriteTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    Func _IowKitSetWriteTimeout($devHandle, $timeout)
    Local $aResult = DllCall($ghIOWkitDll, "bool", "IowKitSetWriteTimeout", "ptr", $devHandle, "ULONG", $timeout)
    If @error Then Return SetError(1, @error, 0)
    EndFunc ;==>_IowKitSetWriteTimeout

    [/autoit] [autoit][/autoit] [autoit]

    ;~ BOOL IOWKIT_API IowKitCancelIo(IOWKIT_HANDLE devHandle, ULONG numPipe);
    Func _IowKitCancelIo($devHandle, $numPipe)
    Local $aResult = DllCall($ghIOWkitDll, "bool", "IowKitCancelIo", "ptr", $devHandle, "ULONG", $numPipe)
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitCancelIo

    [/autoit] [autoit][/autoit] [autoit]

    ;--------------------------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;~ PCSTR IOWKIT_API IowKitVersion(void);
    Func _IowKitVersion()
    Local $aResult = DllCall($ghIOWkitDll, "str", "IowKitVersion")
    If @error Then Return SetError(1, @error, 0)
    Return $aResult[0]
    EndFunc ;==>_IowKitVersion

    [/autoit]
  • Hey, super für deine suuuuuuuuuuuuuuuuperlaaaaaaaaaaaaaaaaaaaange Gedult mit mir. Habe mir deine Verbesserung nocheinmal angeschaut, und habe das nun verstanden. Nun weis ich aus wie die einzelnen Parameter ausgewertet werden.

    Ich konnte mir vorher nichts drunnter vorstellen.

    Ähm, eine Frage noch. Als welche Datei muss ich die speichern (.h), und binde ich die dann normal mit #include blablub.h ein ? Und soll in system 32 ?

    Diese Fragen fehlen mir noch, aber dann wenn ich das Teil gekauft habe, denke ich das es super wird ;)

    mfg Tim

  • Speichere das einfach als .au3 entweder in das Include-Verzeichnis oder in das gleiche Verzeichnis wie dein Hauptskript.
    Dann kannst du es per include einbinden. Die DLL muss immer im Skriptverzeichnis oder in System32 liegen oder du musst den absoluten Pfad (C:\Ordner\die.dll) angeben.

  • So, nun ist es soweit. Er ist da. Ich habe Ihn zusammengebaut, und die Samples die als exe dabei waren ausprobiert. Das klappt schonmal super. Nun aber habe ich mir Gedanken gemacht. Wie ich es in AutoIt umsetzten soll. z.B. einen einzelnen ausgang anzusprechen. Das mus ja mit FileWrite passieren. Ich habe mir dazu auch die .pdf durchgelesen. Aber habe ich das Problem, das ich es nciht hinbekomme das wider mals in Autoit anzuwenden. Hier mal die .pdf. Eventuell kannst du Progandy mir mal wider helfen ;)

    Spoiler anzeigen

    IO-Warrior Dynamic Library
    V1.5 for Windows
    Applicable for all IO-Warriors
    Code Mercenaries
    Overview
    The IO-Warrior Kit Dynamic Library provides a simple API to access all IO-Warrior products from Code
    Mercenaries. It is intended to be used with any programming language available on Windows or Linux.
    Sample programs are included for Microsoft VC++ 6, MS Visual Basic 6 and Borland Delphi 6 for
    Windows and C for Linux. The name of the library is iowkit.dll for Windows and libiowkit.so for Linux.
    The API is deliberately simple. It does not address plug and unplug of IO-Warriors for example.
    It allows access to several IO-Warriors in parallel though. The limit is 16 IO-Warriors. If this limit is too
    low then it is possible to recompile the Windows DLL with a higher limit. The source code is included in
    the SDK.
    The starting point of all activity is the function IowKitOpenDevice(). It opens all IO-Warriors
    connected to the computer. Likewise IowKitCloseDevice() closes all open devices.
    IowKitGetNumDevs() tells you how many devices have been found and
    IowKitGetDeviceHandle() gives access to the individual devices of the list. From there on it is
    mainly IowKitRead(), IowKitReadNonBlockinge() and IowKitWrite() to communicate
    with the device. The precise data to read and write is explained in the IO-Warrior data sheet
    "IOWarriorDatasheet.pdf".
    The IO-Warriors have two communication channels. In USB terminology this is called an interface or
    pipe. Pipe 0 is used to directly access the I/O pins, whereas pipe 1 allows access to the special functions
    of the IO-Warrior. Consequently IowKitRead() and IowKitWrite() have a numPipe parameter.
    IowKitReadImmediate() is only for access to the I/O pins so it abstracts from the pipes and always
    returns 32 bits in a DWORD.
    As of version 1.4 the dynmaic library is threadsafe. Also the DLL loads in Windows 95 and Windows NT,
    but does not find any IO-Warriors due to the lack of USB support in these Windows versions.
    For Linux libiowkit.so has been implemented which exposes the same API as iowkit.dll. It needs the
    driver module iowkit.ko to be installed in the Linux kernel. Do not be afraid. Installing a kernel module is
    simple.
    iowkit.dll and libiowkit.so also expose the API functions as methods for a Java class to allow Java
    programs to access the IO-Warrior directly. This is documented separately.
    The API has been expanded to handle the new IOW56. Some examples (mainly „Simple IO“) have been
    expanded to handle IOW56. The expansion is preliminary and needs some finetuning.
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 1
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    Data structures
    Data with the devices is exchanged in the form of reports. Each report is identified by a report ID which
    is the first byte of any report. For Linux the missing ReportID for Pipe0 is simulated to make the API
    identical to the Windows API.
    The report ID assignment is per pipe. Pipe 0 for the I/O pins has only one type of report so it does not use
    a reportID. But Windows requires that a reportID is provided, even though the reportID is always 0. The
    difference between IO-Warrior24 and IO-Warrior40 is that the former has a report size of 3 bytes (report
    ID and 2 bytes payload), whereas the latter has a report size of 5 bytes (reportID and 4 bytes payload).It is
    possible to always read 5 bytes with IowKitRead() no matter which IO-Warrior is accessed because
    the read only returns in chunks of full reports and 5 bytes is too small to hold two 3 byte reports. Clean
    programming with correct sizes is a wiser idea though.
    Pipe 1 for the special mode functions has a report size of 8 bytes for all IO-Warriors (report ID and 7
    bytes payload). See "IOWarriorDatasheet.pdf" for details on allowed report IDs and the data payload for
    them. The header files provide some predefined structures for ease of use:
    C:
    typedef struct _IOWKIT_REPORT
    {
    UCHAR ReportID;
    union
    {
    DWORD Value;
    BYTE Bytes[4];
    };
    }
    IOWKIT_REPORT, *PIOWKIT_REPORT;
    typedef struct _IOWKIT40_IO_REPORT
    {
    UCHAR ReportID;
    union
    {
    DWORD Value;
    BYTE Bytes[4];
    };
    }
    IOWKIT40_IO_REPORT, *PIOWKIT40_IO_REPORT;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 2
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    typedef struct _IOWKIT24_IO_REPORT
    {
    UCHAR ReportID;
    union
    {
    WORD Value;
    BYTE Bytes[2];
    };
    }
    IOWKIT24_IO_REPORT, *PIOWKIT24_IO_REPORT;
    typedef struct _IOWKIT_SPECIAL_REPORT
    {
    UCHAR ReportID;
    UCHAR Bytes[7];
    }
    IOWKIT_SPECIAL_REPORT, *PIOWKIT_SPECIAL_REPORT;
    Delphi:
    type
    PIOWKIT_REPORT = ^IOWKIT_REPORT;
    IOWKIT_REPORT = packed record
    ReportID: Byte;
    case Boolean of
    False: (Value: DWORD;);
    True: (Bytes: array [0..3] of Byte;);
    end;
    PIOWKIT40_IO_REPORT = ^IOWKIT40_IO_REPORT;
    IOWKIT40_IO_REPORT = packed record
    ReportID: Byte;
    case Boolean of
    False: (Value: DWORD;);
    True: (Bytes: array [0..3] of Byte;);
    end;
    PIOWKIT24_IO_REPORT = ^IOWKIT24_IO_REPORT;
    IOWKIT24_IO_REPORT = packed record
    ReportID: Byte;
    case Boolean of
    False: (Value: WORD;);
    True: (Bytes: array [0..1] of Byte;);
    end;
    PIOWKIT_SPECIAL_REPORT = ^IOWKIT_SPECIAL_REPORT;
    IOWKIT_SPECIAL_REPORT = packed record
    ReportID: Byte;
    Bytes: array [0..6] of Byte;
    end;
    IOWKIT_REPORT dates from the 1.2 version of the API and is the same as IOWKIT40_IO_REPORT.
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 3
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitOpenDevice
    Declaration:
    IOWKIT_HANDLE IOWKIT_API IowKitOpenDevice(void);
    function IowKitOpenDevice: IOWKIT_HANDLE; stdcall;
    Opens all available IO-Warrior devices and returns the handle to the first device found.
    The value returned is an opaque handle to the specific device to be used in most of the other functions of
    the API.
    The return value for failure is NULL (which is nil for Delphi and 0 for VB6). Use GetLastError()
    to learn more about the reason for failure. The most common reason for failure is of course that no IO-Warrior
    is connected. GetLastError() returns ERROR_DEV_NOT_EXIST for that.
    Calling this function several times is possible, but not advisable. The devices get reenumerated and
    therefore the position in the list for a specific device may change.
    Returning the first IO-Warrior found makes it simpler for programmers to handle the use of only one IOWarrior.
    Linux only handles a maximum of 8 IO-Warriors.
    Sample usage C:
    IOWKIT_HANDLE ioHandle;
    ioHandle = IowKitOpenDevice();
    if (ioHandle != NULL)
    {
    // ... success, access devices
    }
    else
    {
    // ... didn't open IoWarrior, handle error
    }
    Sample usage Delphi:
    var
    ioHandle: IOWKIT_HANDLE;
    begin
    ioHandle := IowKitOpenDevice;
    if Assigned(ioHandle) then
    begin
    // ... success, access devices
    end
    else
    begin
    // ... didn't open IoWarrior, handle error
    end;
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 4
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitSetLegacyOpenMode
    This function is only for IO-Warrior40 older than V1.0.1.0!
    Declaration:
    BOOL IOWKIT_API IowKitSetLegacyOpenMode(ULONG legacyOpenMode);
    function IowKitSetLegacyOpenMode(legacyOpenMode: ULONG): BOOL; stdcall;
    Set legacy devices open mode.
    IowKitLegacyOpenMode() specifies which open mode to use if old IO-Warrior40 chips are present.
    IOW_OPEN_SIMPLE - open simple endpoints only.
    IOW_OPEN_COMPLEX - open complex endpoints only.
    Legacy open mode does not affect new IO-Warrior chips which have serial number support (Firmware
    V1.0.1.0 and later), IOW SDK always opens both endpoints for new IO-Warriors.
    The return value is TRUE (1) for the parameters IOW_OPEN_SIMPLE and IOW_OPEN_COMPLEX
    and FALSE (0) otherwise.
    By default IOW SDK opens only simple endpoints on old IO-Warrior 40 chips, so if you want to open
    the complex endpoints, you must call IowKitSetLegacyOpenMode(IOW_OPEN_COMPLEX)
    before calling IowKitOpenDevice().
    Note that because the SDK opens only one endpoint for each legacy device, there will always be only one
    pipe for each device, thus you should always use 0 as numPipe in calls to IowKitRead()/
    IowKitWrite() functions.
    As of dynamic library version 1.4 this function is deprecated. The dynamic library can now handle even
    old IO-Warrior40 chips without serial number fully. The only difference is now that the older firmware
    revisions do not implement all Special Mode functions.
    Sample usage C:
    IOWKIT_HANDLE ioHandle;
    IowKitSetLegacyOpenMode(IOW_OPEN_COMPLEX);
    ioHandle = IowKitOpenDevice();
    Sample usage Delphi:
    var
    ioHandle: IOWKIT_HANDLE;
    begin
    IowKitSetLegacyOpenMode(IOW_OPEN_COMPLEX);
    ioHandle := IowKitOpenDevice;
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 5
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitGetProductId
    Declaration:
    ULONG IOWKIT_API IowKitProductId(IOWKIT_HANDLE iowHandle);
    function IowKitGetProductId(devHandle: IOWKIT_HANDLE): ULONG; stdcall;
    Return the Product ID of the IO-Warrior device identified by iowHandle.
    The Product ID is a 16-bit Word identifying the specific kind of IO-Warrior. For easier compatibility with
    VB6 the function returns a 32-bit DWORD with the upper word set to 0.
    IOWKIT_PRODUCT_ID_IOW40 (0x1500, $1500, &H1500) is returned for an IO-Warrior 40
    whereas IOWKIT_PRODUCT_ID_IOW24 (0x1501, $1501, &H1501) is returned for an IO-Warrior
    24. 0 is returned for an invalid iowHandle.
    The value is cached in the dynamic library because access to the device needs some msecs.
    Sample usage C:
    BOOLEAN IsIOWarrior24(IOWKIT_HANDLE ioHandle)
    {
    return IowKitGetProductId(ioHandle) == IOWKIT_PRODUCT_ID_IOW24;
    }
    BOOLEAN IsIOWarrior40(IOWKIT_HANDLE ioHandle)
    {
    return IowKitGetProductId(ioHandle) == IOWKIT_PRODUCT_ID_IOW40;
    }
    Sample usage Delphi:
    function IsIOWarrior24(ioHandle: IOWKIT_HANDLE): Boolean;
    begin
    Result := IowKitGetProductId(ioHandle) = IOWKIT_PRODUCT_ID_IOW24;
    end;
    function IsIOWarrior40(ioHandle: IOWKIT_HANDLE): Boolean;
    begin
    Result := IowKitGetProductId(ioHandle) = IOWKIT_PRODUCT_ID_IOW40;
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 6
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitGetNumDevs
    Declaration:
    ULONG IOWKIT_API IowKitGetNumDevs(void);
    function IowKitGetNumDevs: ULONG; stdcall;
    Returns the number of IO-Warrior devices present.
    The function has to be called after IowKitOpenDevice() to return meaningful results.
    Plugging or unplugging IO-Warriors after calling IowKitOpenDevice() is not handled. The number
    IowKitGetNumDevs() returns stays the same.
    Sample usage C:
    IOWKIT_HANDLE ioHandle;
    ULONG numDevs;
    ioHandle = IowKitOpenDevice();
    if (ioHandle != NULL)
    {
    // ... success, count devices
    numDevs = IowKitGetNumDevs();
    }
    Sample usage Delphi:
    var
    ioHandle: IOWKIT_HANDLE;
    numDevs: ULONG;
    begin
    ioHandle := IowKitOpenDevice;
    if Assigned(ioHandle) then
    begin
    // ... success, count devices
    numDevs := IowKitGetNumDevs;
    end;
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 7
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitGetDeviceHandle
    Declaration:
    IOWKIT_HANDLE IOWKIT_API IowKitGetDeviceHandle(ULONG numDevice);
    function IowKitGetDeviceHandle(numDevice: ULONG): IOWKIT_HANDLE; stdcall;
    Access a specific IO-Warrior present. numDevice is an index into the available IO-Warrior devices.
    The number range is 1 to IowKitGetNumDevs(). Any value outside that range returns NULL/nil.
    IowKitGetDeviceHandle(1) returns the same handle as IowKitOpenDevice().
    Understand this function as an extension to IowKitOpenDevice(). IowKitOpenDevice() has
    opened all IO-Warriors but has only returned the first one found. IowKitGetDeviceHandle() allows
    to access the other devices found.
    Sample usage C:
    IOWKIT_HANDLE ioHandles[IOWKIT_MAX_DEVICES];
    ULONG numDevs, i;
    ioHandles[0] = IowKitOpenDevice();
    if (ioHandles[0] != NULL)
    {
    // ... success, count devices
    numDevs = IowKitGetNumDevs();
    // get all IO-Warriors
    for(i = 2; i <= numDevs; i++)
    ioHandles[i-1] = IowKitGetDeviceHandle(i);
    }
    Sample usage Delphi:
    var
    ioHandles: array [1..IOWKIT_MAX_DEVICES] of IOWKIT_HANDLE;
    I: ULONG;
    begin
    ioHandles[1] := IowKitOpenDevice;
    if Assigned(ioHandles[1]) then
    // get all IO-Warriors
    for I := 2 to IowKitGetNumDevs do
    ioHandles := IowKitGetDeviceHandle(I);
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 8
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitGetRevision
    Declaration:
    ULONG IOWKIT_API IowKitGetRevision(IOWKIT_HANDLE iowHandle);
    function IowKitGetRevision(devHandle: IOWKIT_HANDLE): ULONG; stdcall;
    A new function of dynamic library version 1.4.
    Return the revision of the firmware of the IO-Warrior device identified by iowHandle.
    The revision is a 16-bit Word telling the revision of the firmware. For easier compatibility with VB6 the
    function returns a 32-bit DWORD with the upper word set to 0.
    The revision consists of 4 hex digits. $1021 designates the current revision 1.0.2.1. 0 is returned for an
    invalid iowHandle.
    Legacy IO-Warriors (without serial number) have a revision < 1.0.1.0 (0x1010, $1010, &H1010).
    The value is cached in the dynamic library because access to the device needs some msecs.
    Sample usage C:
    BOOLEAN IsLegacyIOWarrior(IOWKIT_HANDLE ioHandle)
    {
    return IowKitGetRevision(ioHandle) < IOW_NON_LEGACY_REVISION;
    }
    Sample usage Delphi:
    function IsLegacyIOWarrior(ioHandle: IOWKIT_HANDLE): Boolean;
    begin
    Result := IowKitGetRevision(ioHandle) < IOW_NON_LEGACY_REVISION;
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 9
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitGetSerialNumber
    Declaration:
    BOOL IOWKIT_API IowKitGetSerialNumber(IOWKIT_HANDLE iowHandle, PWCHAR serialNumber);
    function IowKitGetSerialNumber(devHandle: IOWKIT_HANDLE;
    serialNumber: PWideChar): BOOL; stdcall;
    Fills a buffer with the serial number string of the specific IO-Warrior identified by iowHandle.
    All IO-Warriors (for IOW40 only those with firmware V1.0.1.0 and later) contain an 8 digit serial
    number. The serial number is represented as an Unicode string. The buffer pointed to by
    serialNumber must be big enough to hold 9 Unicode characters (18 bytes), because the string is
    terminated in the usual C way with a 0 character.
    On success, this function copies the IO-Warrior serial number string to the buffer and returns TRUE. It
    fails and returns FALSE if the IO-Warrior does not have a serial number or if either iowHandle or
    serialNumber buffer are invalid.
    Sample usage C:
    void ShowSerialNumber(IOWKIT_HANDLE ioHandle)
    {
    WCHAR buffer[9];
    IowKitGetSerialNumber(ioHandle, buffer);
    printf("%ws\n", buffer);
    }
    Sample usage Delphi:
    procedure ShowSerialNumber(ioHandle: IOWKIT_HANDLE);
    var
    Buffer: array [0..8] of WideChar;
    begin
    IowKitGetSerialNumber(ioHandle, @Buffer[0]);
    ShowMessage(Buffer);
    end;
    Sample usage Visual Basic 6:
    Dim N As Long
    Dim S(18) As Byte
    N = IowKitGetSerialNumber(IowKitGetDeviceHandle(1), S(0))
    Label.Caption = S
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 10
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitCloseDevice
    Declaration:
    void IOWKIT_API IowKitCloseDevice(IOWKIT_HANDLE devHandle);
    procedure IowKitCloseDevice(devHandle: IOWKIT_HANDLE); stdcall;
    Close all IO-Warriors.
    You must call this function when you are done using IO-Warriors in your program.
    If multiple IO-Warriors are present all will be closed by this function.
    IowKitOpenDevice() and IowKitCloseDevice() use a IOWKIT_HANDLE for the most
    common case of only one IO-Warrior connected to the computer. This way you do not have to think about
    IowKitGetNumDevs() or IowKitGetDeviceHandle() at all.
    As of dynamic library version 1.4 the function ignores the parameter completely. Since it closes all
    opened IO-Warriors anyway, there is no real need to check if the parameter is the IOWKIT_HANDLE
    returned by IowKitOpenDevice().
    The parameter is now only retained for compatibility and cleaner looking sources. If you handle only a
    single IO-Warrior in your program then IowKitOpenDevice() and IowKitCloseDevice() look
    and work as intuition suggests.
    Sample usage C and Delphi:
    // OK, we're done, close IO-Warrior
    IowKitCloseDevice(ioHandle);
    ...
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 11
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitRead
    Declaration:
    ULONG IOWKIT_API IowKitRead(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);
    function IowKitRead(devHandle: IOWKIT_HANDLE; numPipe: ULONG;
    buffer: PChar; length: ULONG): ULONG; stdcall;
    Read data from IO-Warrior.
    This function reads length bytes from IO-Warrior and returns the number of bytes read if successful.
    Note that you must specify the number of the pipe (see IO-Warrior specs) to read from. numPipe ranges
    from 0 to IOWKIT_MAX_PIPES-1.
    Since the IO-Warriors are HID devices, you can only read the data in chunks called reports. Each report is
    preceded by a ReportID byte. The "IOWarriorDatasheet.pdf" elaborates about that.
    The function returns the number of bytes read, so you should always check if it reads the correct number
    of bytes, you can use GetLastError() to get error details. Keep in mind that data is always returned
    in report chunks, so reading 5 bytes from the IO-pins of an IO-Warrior 24 would only return 3 bytes of
    data because the IO-Warrior 24 has a 3 byte report whereas an IO-Warrior 40 has a 5 byte report.
    The Special Mode pipe has a report size of 8 bytes for all IO-Warriors.
    Linux does not have a ReportID byte of 0 for pipe 0 (I/O pins). To be completely compatible with
    Windows libiowkit.so adds that ReportID to the data.
    As of dynamic library version 1.4 and later the function correctly reads several reports at once.
    ATTENTION!
    This function blocks the current thread until something changes on IO-Warrior (i.e. until user presses a
    button connected to an input pin, or until IIC data arrives), so if you do not want your program to be
    blocked you should use a separate thread for reading from IO-Warrior. If you do not want a blocking read
    use IowKitReadNonBlocking().
    Alternatively you can set the read timeout with IowKitSetTimeout() to force IowKitRead() to
    fail when the timeout elapsed.
    Sample usage C:
    IOWKIT40_IO_REPORT report;
    ULONG res;
    // Read IO pins of IO-Warrior 40
    res = IowKitRead(ioHandle, IOW_PIPE_IO_PINS,
    &report, IOWKIT40_IO_REPORT_SIZE);
    if (res != IOWKIT40_IO_REPORT_SIZE)
    {
    // Didn't read, handle error
    ...
    }
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 12
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitReadNonBlocking
    Declaration:
    ULONG IOWKIT_API IowKitReadNonBlocking(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);
    function IowKitReadNonBlocking(devHandle: IOWKIT_HANDLE; numPipe: ULONG;
    buffer: PChar; length: ULONG): ULONG; stdcall;
    New function of the 1.5 API.
    Read data from IO-Warrior, but do not block if no data is available.
    This function reads length bytes from IO-Warrior and returns the number of bytes read if successful.
    Note that you must specify the number of the pipe (see IO-Warrior specs) to read from. numPipe ranges
    from 0 to IOWKIT_MAX_PIPES-1. On error or if no data is available the function returns 0.
    Since the IO-Warriors are HID devices, you can only read the data in chunks called reports. Each report is
    preceded by a ReportID byte. The "IOWarriorDatasheet.pdf" elaborates about that.
    The function returns the number of bytes read, so you should always check if it reads the correct number
    of bytes, you can use GetLastError() to get error details. Keep in mind that data is always returned
    in report chunks, so reading 5 bytes from the IO-pins of an IO-Warrior 24 would only return 3 bytes of
    data because the IO-Warrior 24 has a 3 byte report whereas an IO-Warrior 40 has a 5 byte report.
    The Special Mode pipe has a report size of 8 bytes for IO-Warriors 24 and 40.
    Linux does not have a ReportID byte of 0 for pipe 0 (I/O pins). To be completely compatible with
    Windows libiowkit.so adds that ReportID to the data.
    The function can read several reports at once. It reads as many reports as available. The internal buffering can
    hold up to 128 reports.
    Sample usage C:
    IOWKIT40_IO_REPORT report;
    ULONG res;
    // Read IO pins of IO-Warrior 40
    res = IowKitReadNonBlocking(ioHandle, IOW_PIPE_IO_PINS,
    &report, IOWKIT40_IO_REPORT_SIZE);
    if (res == 0)
    {
    // Didn't read, handle error
    }
    Sample usage Delphi:
    var
    Report: IOWKIT40_IO_REPORT;
    Ret: ULONG;
    begin
    // Read IO pins of IO-Warrior 40
    Ret := IowKitReadNonBlocking(ioHandle, IOW_PIPE_IO_PINS,
    @report, IOWKIT40_IO_REPORT_SIZE);
    if Ret = 0 then
    begin
    // Didn't read, handle error
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 13
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitReadImmediate
    Declaration:
    BOOL IOWKIT_API IowKitReadImmediate(IOWKIT_HANDLE devHandle, PDWORD value);
    function IowKitReadImmediate(devHandle: IOWKIT_HANDLE; var value: DWORD): BOOL; stdcall;
    Return current value directly read from the IO-Warrior I/O pins.
    The function returns TRUE if a new value has arrived otherwise it returns FALSE and places the last
    value read into value.
    The function can only read the I/O pins so it does not need a numPipe parameter. It also abstracts from the
    number of I/O pins the device has. It always returns 32 bits as a DWORD. For the IOWarrior24 which has only
    16 I/O pins the upper WORD of the DWORD is set to 0.
    The function internally uses the Special Mode Function „Read current pin status“ if available. For chip
    revisions predating revision 1.0.1.0 it returns the most recent value read from the IO-Pins or returns FALSE if no
    value has been read yet.
    The 1.4 version of the API implements another strategy. That strategy is now available through
    IowKitReadNonBlocking. 1.5 reverts to the implementation of the 1.2 API to provide compatibility.
    This function fails unconditionally for IOW56 devices because it cannot handle more than 32 bits. For the
    IOW56 you can always use the special mode function „Get Current Pin Status“ directly instead.
    Sample usage C:
    DWORD bits;
    if (IowKitReadImmediate(ioHandle, &bits))
    {
    // new data from IO-Warrior pins
    ...
    }
    Sample usage Delphi:
    var
    Bits: DWORD;
    begin
    if IowKitReadImmediate(ioHandle, Bits) then
    begin
    // new data from IO-Warrior pins
    ...
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 14
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitSetTimeout
    Declaration:
    BOOL IOWKIT_API IowKitSetTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    function IowKitSetTimeout(devHandle: IOWKIT_HANDLE; timeout: ULONG): BOOL; stdcall;
    Set read I/O timeout in milliseconds.
    It is possible to lose reports with HID devices. Since reading a HID device is a blocking call it is possible
    to block your application in that case.
    IowKitSetTimeout() makes IowKitRead() fail if it does not read a report in the allotted time.
    If IowKitRead() times out, you have to restart any pending transaction (for example, IIC write or read
    transaction) from the beginning.
    It is recommended to use 1 second (1000) or bigger timeout values.
    Sample usage C and Delphi:
    // set read timeout to 1000 msecs
    IowKitSetTimeout(ioHandle, 1000);
    ...
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 15
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitSetWriteTimeout
    Declaration:
    BOOL IOWKIT_API IowKitSetWriteTimeout(IOWKIT_HANDLE devHandle, ULONG timeout);
    function IowKitSetWriteTimeout(devHandle: IOWKIT_HANDLE; timeout: ULONG): BOOL; stdcall;
    Set write I/O timeout in milliseconds.
    IowKitSetWriteTimeout() makes IowKitWrite() fail if it does not write a report in the
    allotted time. If IowKitWrite() times out, you have to restart any pending transaction (for example, IIC write
    transaction) from the beginning.
    Failure of IowKitWrite() is uncommon. Check your hardware if you encounter write errors.
    libiowkit.so does not implement IowKitSetWriteTimeout() yet.
    It is recommended to use 1 second (1000) or bigger timeout values.
    Sample usage C and Delphi:
    // set write timeout to 1000 msecs
    IowKitSetWriteTimeout(ioHandle, 1000);
    ...
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 16
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitCancelIo
    Description:
    BOOL IOWKIT_API IowKitCancelIo(IOWKIT_HANDLE devHandle, ULONG numPipe);
    function IowKitCancelIo(devHandle: IOWKIT_HANDLE; numPipe: ULONG): BOOL; stdcall;
    Cancel a read or write operation under way on one of the pipes.
    This function is seldom used, because you need several threads in your program to be able to call it at all.
    IowKitRead() blocks the thread so you need another thread for canceling. Setting the timeouts is an
    easier way for handling read or write problems.
    The function cancels pending read and write operations simultaneously.
    Sample usage:
    // cancel I/O for I/O pins
    IowKitCancelIo(ioHandle, IOW_PIPE_IO_PINS);
    ...
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 17
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitWrite
    Declaration:
    ULONG IOWKIT_API IowKitWrite(IOWKIT_HANDLE devHandle, ULONG numPipe,
    PCHAR buffer, ULONG length);
    function IowKitWrite(devHandle: IOWKIT_HANDLE; numPipe: ULONG;
    buffer: PChar; length: ULONG): ULONG; stdcall;
    Write length bytes of data to pipe numPipe of IO-Warrior. The return value is the number of bytes
    written. Writing something else than a single report of the correct size and a valid report ID for the pipe
    fails for Windows. The function allows writing to the I/O pins through pipe 0 and Special Mode functions
    through pipe 1. To be completely compatible with the Windows version libiowkit.so expects a ReportID 0
    for pipe 0 (I/O pins) even if Linux does not have a ReportID on pipe 0. The ReportID is stripped from the
    data sent to the device.
    Sample write to pipe 0 of an IO-Warrior 40:
    DWORD value consists of 32 bits, which correspond to the 32 IO-Warrior 40 I/O pins. Each bit has the
    following meaning:
    When a 1 is written to a pin the output driver of that pin is off and the pin is pulled high by an internal
    resistor. The pin can now be used as an input or an output with high state.
    When a 0 is written to a pin the output driver is switched on pulling the pin to ground. The pin is now a
    output driving low.
    For example, writing 0 (all 32 bits are zero) to IO-Warrior sets all pins as outputs driving low (so if you
    have LEDs connected to them they will be on).
    Reading the status of the pins does always return the logic level on the pins, not the value written to the
    pin drivers.
    Writing 0xFFFFFFFF (value in hex, all 32 bits set) sets all pins as inputs.
    Note that if you want to use a pin as an input, you must first set it up as input, in other words, you must
    write 1 to it. For connected LEDs this means they go off.
    Sample usage C:
    IOWKIT40_IO_REPORT report;
    ULONG res;
    // Write IO pins of IO-Warrior 40
    report.ReportID = 0;
    report.Value = 0; // all LEDs *on*
    res = IowKitWrite(ioHandle, IOW_PIPE_IO_PINS,
    &report, IOWKIT40_IO_REPORT_SIZE);
    if (res != IOWKIT40_IO_REPORT_SIZE)
    {
    // Didn't write, handle error
    ...
    }
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 18
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitGetThreadHandle
    Description:
    HANDLE IOWKIT_API IowKitGetThreadHandle(IOWKIT_HANDLE iowHandle);
    function IowKitGetThreadHandle(devHandle: IOWKIT_HANDLE): THandle; stdcall;
    A new function of dynamic library version 1.4.
    It returns the internal Windows thread handle used to read the I/O pins of the IO-Warrior.
    The function is only for programmers with expert knowledge about threads. It is provided for
    manipulations like raising or lowering thread priority.
    Since Linux does not need a thread for implementing the IO-Warrior functions,
    IowKitGetThreadHandle() always returns 0 then.
    Sample usage C:
    HANDLE threadHandle;
    threadHandle = IowKitGetThreadHandle(ioHandle);
    if (threadHandle != NULL)
    {
    // lower thread priority
    SetThreadPriority(threadHandle, THREAD_PRIORITY_BELOW_NORMAL);
    }
    Sample usage Delphi:
    var
    ThreadHandle: Thandle;
    begin
    ThreadHandle := IowKitGetThreadHandle(ioHandle);
    if ThreadHandle <> 0 then
    begin
    // lower thread priority
    SetThreadPriority(ThreadHandle, THREAD_PRIORITY_BELOW_NORMAL);
    end;
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 19
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    IowKitVersion
    Description:
    PCHAR IOWKIT_API IowKitVersion(void);
    function IowKitVersion: PChar; stdcall;
    Return a static C string identifying the dynamic library version. This function has been added with 1.3
    version of the dynamic library. Currently it returns "IO-Warrior Kit V1.5".
    Sample usage C:
    printf("%s\n", IowKitVersion());
    ...
    Sample usage Delphi:
    ShowMessage(IowKitVersion);
    ...
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 20
    IO-Warrior Dynamic Library Code Mercenaries
    for Windows V1.5
    Programming by Robert Marquardt.
    Legal Stuff
    This document is ©2005 by Code Mercenaries.
    The information contained herein is subject to change
    without notice. Code Mercenaries makes no claims as
    to the completeness or correctness of the information
    contained in this document.
    Code Mercenaries assumes no responsibility for the use
    of any circuitry other than circuitry embodied in a Code
    Mercenaries product. Nor does it convey or imply any
    license under patent or other rights.
    Code Mercenaries products may not be used in any
    medical apparatus or other technical products that are
    critical for the functioning of lifesaving or supporting
    systems. We define these systems as such that in the
    case of failure may lead to the death or injury of a
    person. Incorporation in such a system requires the
    explicit written permission of the president of Code
    Mercenaries.
    Trademarks used in this document are properties of
    their respective owners.
    Code Mercenaries
    Hard- und Software GmbH
    Karl-Marx-Str. 147a
    12529 Schönefeld / Grossziethen
    Germany
    Tel: x49-3379-20509-20
    Fax: x49-3379-20509-30
    Mail: support@codemercs.com
    Web: https://autoit.de/www.codemercs.com
    HRB 16007 P
    Geschäftsführer: Guido Körber, Christian Lucht
    IO-Warrior Dynamic Library V1.5 8. Dez 2005 21

    So, habe mal diese Test Datei in einem C-Editor aufgemacht, und da stand folgendes drinnen:

    Spoiler anzeigen
    [autoit]

    //
    // ioblink.cpp - Blinking LEDs sample
    //

    [/autoit] [autoit][/autoit] [autoit]

    #include "stdafx.h"
    #include "time.h"
    #include "iowkit.h"

    [/autoit] [autoit][/autoit] [autoit]

    // Write simple value
    BOOLEAN WriteSimple(IOWKIT_HANDLE devHandle, DWORD value)
    {
    IOWKIT56_IO_REPORT rep;

    [/autoit] [autoit][/autoit] [autoit]

    // Init report
    memset(&rep, 0xff, IOWKIT56_IO_REPORT_SIZE);
    rep.ReportID = 0;
    switch (IowKitGetProductId(devHandle))
    {
    // Write simple value to IOW40
    case IOWKIT_PRODUCT_ID_IOW40:
    rep.Bytes[3] = (BYTE) value;
    return IowKitWrite(devHandle, IOW_PIPE_IO_PINS,
    (PCHAR) &rep, IOWKIT40_IO_REPORT_SIZE) == IOWKIT40_IO_REPORT_SIZE;
    // Write simple value to IOW24
    case IOWKIT_PRODUCT_ID_IOW24:
    rep.Bytes[0] = (BYTE) value;
    return IowKitWrite(devHandle, IOW_PIPE_IO_PINS,
    (PCHAR) &rep, IOWKIT24_IO_REPORT_SIZE) == IOWKIT24_IO_REPORT_SIZE;
    case IOWKIT_PRODUCT_ID_IOW56:
    // Write simple value to IOW56
    rep.Bytes[6] = (BYTE) value;
    return IowKitWrite(devHandle, IOW_PIPE_IO_PINS,
    (PCHAR) &rep, IOWKIT56_IO_REPORT_SIZE) == IOWKIT56_IO_REPORT_SIZE;
    default:
    return FALSE;
    }
    }

    [/autoit] [autoit][/autoit] [autoit]

    int main(int argc, char* argv[])
    {
    IOWKIT_HANDLE iows[IOWKIT_MAX_DEVICES];
    int i, j;
    ULONG bits;
    int numIows;
    IOWKIT56_IO_REPORT rep;
    WCHAR sn[9];
    ULONG rc;
    DWORD pid;
    IOWKIT_HANDLE devHandle;

    [/autoit] [autoit][/autoit] [autoit]

    // Open device
    devHandle = IowKitOpenDevice();
    if (devHandle == NULL)
    {
    printf("Failed to open device\n");
    goto out;
    }
    // Get number of IOWs in system
    numIows = IowKitGetNumDevs();
    printf("%d IOWs in system\n", numIows);
    // Get all IOW handles
    for (i = 0; i < numIows; i++)
    {
    // Get device handle and init object
    iows[i] = IowKitGetDeviceHandle(i + 1);
    // Get serial number
    IowKitGetSerialNumber(iows[i], sn);
    pid = IowKitGetProductId(iows[i]);
    printf("%d PID %x, S/N \"%ws\"\n", i + 1, pid, sn);
    }
    // Init report
    // Report ID 0 is for writing to 32 input/output pins
    rep.ReportID = 0;
    printf("Blinking LEDs...\n");
    //srand(time(NULL));
    // Blinking'
    for (i = 0; i < 100; i++)
    {
    bits = rand();
    // Make every IOW blink
    for (j = 0; j < numIows; j++)
    {
    // Write to simple endpoint
    rc = WriteSimple(iows[j], bits);
    // Check for error
    if (!rc)
    printf("Cannot write, err %d\n", GetLastError());
    }
    // Sleep for 25ms
    Sleep(25);
    }
    printf("Blinking complete\n");
    // Set LEDs off
    for (i = 0; i < numIows; i++)
    // Write to simple endpoint
    WriteSimple(iows[i], 0xFFFFFFFF);
    for(i = 0; i < 10; i++)
    {

    [/autoit] [autoit][/autoit] [autoit]

    // Read non blocking
    // Init report
    memset(&rep, 0, IOWKIT56_IO_REPORT_SIZE);
    switch (IowKitGetProductId(devHandle))
    {
    case IOWKIT_PRODUCT_ID_IOW40:
    rc = IowKitReadNonBlocking(iows[0], IOW_PIPE_IO_PINS,
    (PCHAR) &rep, IOWKIT40_IO_REPORT_SIZE);
    printf("%2d) ReadNonBl(): rc=%u bits=", i + 1, rc);
    for (j = IOWKIT40_IO_REPORT_SIZE - 1; j >= 0; j--)
    printf("%02x", rep.Bytes[j]);
    printf("\n");
    break;
    case IOWKIT_PRODUCT_ID_IOW24:
    rc = IowKitReadNonBlocking(iows[0], IOW_PIPE_IO_PINS,
    (PCHAR) &rep, IOWKIT24_IO_REPORT_SIZE);
    printf("%2d) ReadNonBl(): rc=%u bits=", i + 1, rc);
    for (j = IOWKIT24_IO_REPORT_SIZE - 1; j >= 0; j--)
    printf("%02x", rep.Bytes[j]);
    printf("\n");
    break;
    case IOWKIT_PRODUCT_ID_IOW56:
    rc = IowKitReadNonBlocking(iows[0], IOW_PIPE_IO_PINS,
    (PCHAR) &rep, IOWKIT56_IO_REPORT_SIZE);
    printf("%2d) ReadNonBl(): rc=%u bits=", i + 1, rc);
    for (j = IOWKIT56_IO_REPORT_SIZE - 1; j >= 0; j--)
    printf("%02x", rep.Bytes[j]);
    printf("\n");
    break;
    }
    Sleep(100);
    }
    // Close device
    IowKitCloseDevice(devHandle);
    out:

    [/autoit] [autoit][/autoit] [autoit]

    return 0;
    }

    [/autoit]


    Hoffe man kann damit etwas anfangen.

    Lg Tim

  • Hallo zusammen,

    will dieses alte Thema nicht wieder auswärmen, habe aber trotzden eine Frage, keine Angst, nicht speziell zum IO-Warroir!
    Es geht um die verschiedenen Möglichkeiten wie die Bedatung des DLL-Aufrufes von progandy erfolgt.

    In seiner UDF (Antwort vom 13. Juli) bietet er z.B. beim Aufruf der Funktion _IowKitWrite (diese habe ich auch in meine BSP verwendet) drei Varianten an.
    Eine über eine DLL-Struktur, eine über eine Pointer und eine dritte wenn nur eine einfacher Wert übergeben wurde.
    Die dritte Variante funktionier bei mir hervorragend (s. Beispiel anbei).

    Kann mir jemand sagen wie ich meinen Code so umschrieben muss, damit es über die DLL-Struktur oder über den Pointer erfolgt?

    Ansonsten funktioniert der IO-Warroir mit der UDF tadellos!
    Werde mal die Tage einige Spezialfunktionen mal ausprobieren.

    Gruß und Dank
    Ralf

    Spoiler anzeigen
    [autoit]


    #cs ****************************************************************************************************************************
    Autor R. Beermann
    Datum 2012.08.07

    [/autoit] [autoit][/autoit] [autoit]

    Anwendung: Steuerung (einfaches Demo) f. IO-Warrior, in diesem Fall der IO-Warrior24

    [/autoit] [autoit][/autoit] [autoit]

    Hinweis: mir ist nichtr klar wie die Bytezuordnung genau aussieht
    Der IO-W24 hat 16 I/O Kanäle, dieses BSP steuer die ersten 8 (P0.0 - P0.7) an.
    alle AUS = 0xFFFF00
    alle EIN = 0xFF0000
    das 3. Byte ist in diesem Bsp. immer FF und steuert die Ports P1.0 bis P1.7 an (geht auch!)
    das 1. Byte muss immer 00 sein, keine Ahnung wieso, scheint die ReportID zu sein,
    alle Sonderfunktionen mit $numPipe >0 habe hier eine entsprechende ID
    Leider schweigt sich hierzu die Doku aus, habe jedenfalls nix dazugefunden...
    ****************************************************************************************************************************
    #ce

    [/autoit] [autoit][/autoit] [autoit]

    #include <GUIConstantsEx.au3>
    #include "IO_Warrior_UDF.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)
    Opt("MustDeclareVars", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $mainwindow
    Global $IOW_open, $IOW_close, $IOW_B_EIN, $IOW_B_AUS
    Global $A_LEDs[8]
    Global $IOW_handle ; Handle des IO-W
    Global $value =0 ; Wert der auf den IO-Worrior geschrieben werden soll

    [/autoit] [autoit][/autoit] [autoit]

    $mainwindow = GUICreate("IO_Worrior-Test",190, 200) ; ANFANG GUI
    GUISetOnEvent($GUI_EVENT_CLOSE, "schliessen")
    $IOW_open = GUICtrlCreateButton("oeffnen", 10, 10, 80)
    GUICtrlSetOnEvent($IOW_open, "oeffnen")
    $IOW_close = GUICtrlCreateButton("schliessen", 100, 10, 80)
    GUICtrlSetOnEvent($IOW_close, "schliessen")
    $IOW_B_EIN = GUICtrlCreateButton("alle AN", 10, 50, 80)
    GUICtrlSetOnEvent($IOW_B_EIN, "LED_EIN")
    $IOW_B_AUS = GUICtrlCreateButton("alle AUS", 100, 50, 80)
    GUICtrlSetOnEvent($IOW_B_AUS, "LED_AUS")
    for $i=0 to 3
    $A_LEDs[$i]=GUICtrlCreateCheckbox("LED "&$i+1, 20, 90+$i*22, 57, 17)
    GUICtrlSetOnEvent($A_LEDs[$i], "LED_Status")
    Next
    for $i=4 to 7
    $A_LEDs[$i]=GUICtrlCreateCheckbox("LED "&$i+1, 110, 90+($i-4)*22, 57, 17)
    GUICtrlSetOnEvent($A_LEDs[$i], "LED_Status")
    Next
    GUISetState(@SW_SHOW) ; ENDE GUI

    [/autoit] [autoit][/autoit] [autoit]

    _IowKitStartUp(@ScriptDir&"\iowkit.dll") ; DLL offnen, Pfad entsprechend anpassen

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func oeffnen() ; IO-Worroir öffnen
    $IOW_handle = _IowKitOpenDevice()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func LED_AUS () ; alle LEDs AUS (P0.0-P0.7)
    IOW_schreiben(0xFFFF00) ; alternativ hätte auch nach den Checkboxen die Funktion LED_Status aufgerufen werden können
    For $i=0 to 7 ; Status der Checkboxen nachziehen
    GUICtrlSetState($A_LEDs[$i],$GUI_UNCHECKED)
    Next
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func LED_EIN () ; alle LEDs EIN
    IOW_schreiben(0x000000) ; alternativ hätte auch nach den Checkboxen die Funktion LED_Status aufgerufen werden können
    For $i=0 to 7 ; Status der Checkboxen nachziehen
    GUICtrlSetState($A_LEDs[$i],$GUI_CHECKED)
    Next
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func LED_Status () ; Auswertung der Checkboxen
    Local $tmp_Value = 0
    For $i=0 to 7
    If GUICtrlRead($A_LEDs[$i]) = 4 Then
    $tmp_Value= $tmp_Value + 2^$i
    EndIf
    Next
    $tmp_Value=Bitand (0xFFFF00, BitShift($tmp_Value,-8)) ; 0xFFFF00 = alle AUS, erste Byte um -8 bit verschieben
    IOW_schreiben($tmp_Value)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func IOW_schreiben ($IOW_Value) ; Aufruf der eigentlichen IO-Warroir-Funktion
    _IowKitWrite($IOW_handle, "0", $IOW_Value) ; $length braugt nicht angegeben zu sein, weil nicht über Pointer oder DLL-Struktur
    EndFunc ; wie aufruf über Pointer o. DLL-Struktur?

    [/autoit] [autoit][/autoit] [autoit]

    Func schliessen () ; beenden und IO-Warrior schließen, ganz wichtig!
    _IowKitCloseDevice($IOW_handle)
    Exit
    EndFunc

    [/autoit]