I/O-Warrior - Hilfe bei einem C Script

  • Hallo, ich habe es an meinen Alten Beitrag versucht anzuhängen, aber leider ging das nicht so wie geplant. War wohl zu alt ;)

    Also, meine Problem, ich habe folgenden Quelltext in C, der mit Hilfe einer .dll mein USB Kit anspricht, und die Leds an Port 3 Blinken lässt. Ich habe keine Ahnung in C und habde das Problem, das ich das gerne in AutoIt umschreiben möchte. Im Script wird zwischen I/O Warriar 24, 40 und 56 unterschieden. Ich habe den 40.

    Hier erstmal das Script:

    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]


    So, das Beispielprogramm mit C-Sourge und co. gibt es hier. fals ich eigentlich garnicht die richtige Quell-Datei habe, dann ist es klar, wieso ich einfach nicht schlau werde.
    KLICK MICH

    Ich habe auch rausgefunden, das man erstmal das Kit ansprechen muss mit : IowKitOpenDevice()
    und dann die Aktionen mit : IowKitWrite() und IowKitRead() ausführen.
    Am Ende muss man es wider mit : IowKitCloseDevice () schließen, das ein klares Ende definiert ist.

    Ich weis nicht wie es in C ist, ob da ein Script reicht, wie in AutoIt, oder ob sich das aus vielen Dateien zusammensetzt.

    Ich hoffe mir kann jemand mit den bisherigen Informationen Helfen.
    Sollte dochnoch Fragen geben, sind in dieser .pdf-Anleitung soweit eigentlich alles erklärt. Ich habe diese gelesen, komme aber leider mit der Umsetztung von C in AutoIt nicht zurecht. HIER DIE .PDF

  • Warum schon so früh nen push ??
    Zu deinem Problem: Wenn du keine Ahnung von C hast solltest du nicht direkt ein C Skript in AutoIt umschreiben.
    Versuch doch nach den Funktionen in der iowkit.dll zu googlen und dann ein paar DLLCalls in AutoIt zu machen.
    MfG. PrideRage

    Meine Projekte:
    ClipBoard Manager (beendet)
    Gutes ClipBoard Verwaltungs Programm mit nützlichen Funktionen.

    HTML Creator (beendet)
    Nützliches Tool um schnell ein eigenes HTML Dokument zu erstellen.

  • Ok, der Push hätte nciht sein müssen, ich denke das liegt daran, weil ich das Teil zum laufen bekommen will. Ist die Anspannung und Freude.
    Ok, ich werde mich versuchen, und wenn es wider Probleme gibt, posten.
    Danke
    lg Tim


    Edit:

    Also, ich habe nun etwas mit den dll´s. rumgespielt, und bin auf folgendes gestoßen:

    Spoiler anzeigen
    [autoit]

    #include "C:\Users\User\Desktop\ubersetzung.au3"

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

    $antwort = DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "ptr", "IowKitOpenDevice (ioHandle)")
    MsgBox(0,"",$antwort)

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

    $antwort3 = DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "ulong", "IowKitGetNumDevs()")
    MsgBox(0,"",$antwort3)

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

    $antwort2 = DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "ptr", "IowKitCloseDevice(ioHandle)")
    MsgBox(0,"",$antwort2)

    [/autoit]

    Mein Problem dabe ist, das ich immer 0 zurück bekomme. Am anfang ist das auch ok, udn am Ende, aber bei dem Aufruf IowKitGetNumDevs() sollte ich eigentlich eine Zahl zurückbekommen. Es sollte 0x1500 sein. Ich bekomme aber null. Liegt das an meinem falschem dll Aufruf, oder habe ich etwas falsch verstanden. Hier ist die IOWKit. C in AutoIt umgeschriben. Das habe ich schon vor langem mit ProGandy gemacht. Aber was macht diese genau ? Verbindet die sozusagen meinen Befehl in AutoIt mit der dll ?

    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]

    lg Tim

  • Spoiler anzeigen
    [autoit]

    #include "C:\Users\User\Desktop\ubersetzung.au3"

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

    $antwort = DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "ptr", "IowKitOpenDevice (ioHandle)")
    MsgBox(0,"",$antwort)

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

    $antwort3 = DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "ulong", "IowKitGetNumDevs()")
    MsgBox(0,"",$antwort3)

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

    $antwort2 = DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "ptr", "IowKitCloseDevice(ioHandle)")
    MsgBox(0,"",$antwort2)

    [/autoit]

    Das kann schonmal nicht richtig sein. So könnte es klappen

    Spoiler anzeigen
    [autoit]

    #include "C:\Users\User\Desktop\ubersetzung.au3"

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

    $antwort = DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "ptr", "IowKitOpenDevice")
    if @error then
    MsgBox(0, "", "Error: "&@error)
    else
    MsgBox(0,"",$antwort[0])
    endif

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

    $antwort2 = DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "ulong", "IowKitGetNumDevs")
    if @error then
    MsgBox(0, "", "Error: "&@error)
    else
    MsgBox(0,"",$antwort2[0])
    endif

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

    $antwort3= DllCall("C:\Users\User\Desktop\Windows\library_1_5\IOWKIT.dll", "none", "IowKitCloseDevice", "ptr", $antwor[0])
    if @error then
    MsgBox(0, "", "Error: "&@error)
    else
    MsgBox(0,"",$antwort3[0])
    endif

    [/autoit]


    Ungetestet, du musst vielleicht noch returnwerte der DLLCalls anpassen, besonders beim letzten.

  • Aber was macht diese genau ? Verbindet die sozusagen meinen Befehl in AutoIt mit der dll ?


    Dies Include besitzt für jede Funktion in der DLL eine AutoIt-Funktion. Daher musst du die DLLCalls nicht mehr an jeder Stelle neu schreiben, sondern rufst die AutoIt-Funktion auf, die das für dich erledigt. Dadurch wird der Code übersichtlicher.

    Beispiel
    [autoit]

    #include "IOWKit.au3"
    If Not _IowKitStartUp("C:\iowkit.dll") Then
    MsgBox(0, "", "DLL konnte nicht geladen werden")
    Exit
    EndIf

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

    Dim $hGlobalDevice = _IowKitOpenDevice()

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

    $num = _IowKitGetNumDevs()
    ...

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

    _IowKitCloseDevice($hGLobalDevice)

    [/autoit]
  • Hey Progandy !!

    also , folgendes funktioniert schonmal !!!

    Spoiler anzeigen
    [autoit]

    #include "IOWKit.au3"

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

    If Not _IowKitStartUp("C:\Users\User\Desktop\Windows\library_1_5\iowkit.dll") Then
    MsgBox(0, "", "DLL konnte nicht geladen werden")
    Exit
    EndIf

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

    Dim $hGlobalDevice = _IowKitOpenDevice()

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

    $num = _IowKitGetNumDevs()

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

    MsgBox(0,"",$hGlobalDevice & " __ " & $num)

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

    _IowKitCloseDevice($hGLobalDevice)

    [/autoit]

    Das ist echt klasse. Ich übe mich jezt noch ander Write und Read Funktion, und werde mich bei Problemen melden. !!!

    DANKE euch !!!

    lg Tim

  • Also, ich habe die Funkrion noch um folgendes erweitert. Nur habe ich Probleme bei Write, weil ich nicht weis, was ich wo angeben soll, und wo Variablen in den Befehl Write eingesetzt werden.

    Und wie kommst du auf die Variable

    [autoit]

    $hGlobalDevice

    [/autoit]

    ? Konnte sie in der IOWKIT.au3 nicht finden ;?

    Ich denke, wenn ich das nun mit dem Write hinbekomme, kann ich davon auch Read ableiten, und komme hoffentlich ab dann alleine klar. Schön ist es auf jeden fall, das Du/Ihr so geduldig seit.
    Mich würde interessieren wie lange du dich schon mit dem Programmieren / Programmentwicken beschäftigst ;)

    Spoiler anzeigen
    [autoit]

    #include "IOWKit.au3"

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

    If Not _IowKitStartUp("C:\Users\User\Desktop\Windows\library_1_5\iowkit.dll") Then
    MsgBox(0, "", "DLL konnte nicht geladen werden")
    Exit
    EndIf

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

    Dim $hGlobalDevice = _IowKitOpenDevice()

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

    Dim $num = _IowKitGetNumDevs()

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

    Dim $version = _IowKitVersion()

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

    ;~ $devHandle = _IowKitGetProductId() ; Hier komme ich nicht weiter...

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

    ;~ If not _IowKitWrite($devHandle,$num,0, -1) Then ; Und hier habe ich das Problem, das das skript einfach stehenbleibt. Ich bekomme keine Meldeung oder sonstiges.
    ;~ MsgBox(0, "", "Es konnten keine Bits geschrieben werden")
    ;~ Exit
    ;~ EndIf

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

    MsgBox(0,"","IowKitOpenDevice: " & $hGlobalDevice & @CRLF & "IowKitGetNumDevs: " & $num & @CRLF & "IowKitVersion: " & $version )

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

    _IowKitCloseDevice($hGLobalDevice)

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

    ; So wie das Script ist, kann ich die MsgBox ausgebenlassen, und mir die Daten zurückschicken lassen.

    [/autoit]


    Danke nochmal ;)

    lg Tim

  • $hGlobalDevice hab ich mir einfach ausgedacht.
    $h -> es ist ein Handle
    Global -> Zur unterscheidung von der Rückgabe von _IowKitGetDeviceHandle
    Device -> Ist halt ein DeviceHandle

    Diese Variable muss ja auch nicht in der AU3 vorkommen, die Rückgabe braucht man aber eben für _IowKitCloseDevice.

    Zum Schreiben wirst du vermutlich noch ein "normales" devicehandle von _IowKitGetDeviceHandle benötigen, aber ohne DLL, Doku und eigene Tests wird das etwas schwierig.

    Zitat

    Mich würde interessieren wie lange du dich schon mit dem Programmieren / Programmentwicken beschäftigst ;)

    Gute Frage :D Auf jeden Fall schon länger als ich hier angemeldet bin. Jahr 2005 oder 2006 könnte hinkommen, also etwa mit 14 oder so

  • Nett ;)

    Also, ich habe hier wegen der device folgendes rausgefunden:

    Spoiler anzeigen
    [autoit]

    #include "IOWKit.au3"

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

    If Not _IowKitStartUp("C:\Users\User\Desktop\Windows\library_1_5\iowkit.dll") Then
    MsgBox(0, "", "DLL konnte nicht geladen werden")
    Exit
    EndIf

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

    Dim $hGlobalDevice = _IowKitOpenDevice()

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

    Dim $num = _IowKitGetNumDevs()

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

    Dim $version = _IowKitVersion()

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

    Dim $numdevice = _IowKitGetDeviceHandle()

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

    MsgBox(0,"","IowKitOpenDevice: " & $hGlobalDevice & @CRLF & "IowKitGetNumDevs: " & $num & @CRLF & "IowKitVersion: " & $version )

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

    _IowKitCloseDevice($hGLobalDevice)

    [/autoit]


    Das Script bleibt einfach stehen, es passiert nach dem drücken auf F5 nichts. Das Script startet, aber es passiert nichts. wenn ich die Zeile mit dem Dim $numdevice = _IowKitGetDeviceHandle() rausnehme, dann kommt meineMsgBox mit den Informationen. Woran kann das liegen ? Also ich habe auch rausgefunden, in der IOWKIT.au3 sind die funktionen, die Funktionen so :

    Spoiler anzeigen
    [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]

    Und die die nicht gehen(Script bleibt stehen) so:

    Spoiler anzeigen
    [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]

    Das einzige was anders ist, ist die Variable $numDevice hinter der Function. Bei den Funktionierenden, ist da einfach ().

    Was muss ich bei diesen anders machen ?

    lg Tim

    PS: Das das nicht so einfach ist, das nachzufolziehen auf die Ferne ist mir klar ;)

    EDIT: Ich habe bei :

    Spoiler anzeigen
    [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]


    einfach mal das $numdevice entfernt, und nun bekomme ich einen Wert zurück. Kann es sein, das das $numdevice nicht in die IOWkit.au3 gehört ?

    Edit2:

    Was bedeutet eigentlich in Func _IowKitWrite($devHandle, $numPipe, $buffer, $length=-1) der $buffer und $length=-1. Was ist bitte ein buffer ? ?(

  • Also gehört die Variable auch da rein. Gut.

    Muss ich beim aufrufen der Funktion auch hinter der Funktion in der Klammer die Variable einfügen, oder macht er das automatisch. ?

    lg Tim

    Edit: Bei folgendem bekomme ich daten zurück:

    Spoiler anzeigen
    [autoit]

    #include "IOWKit.au3"
    #include "GUIConstants.au3"

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

    If Not _IowKitStartUp("C:\Users\User\Desktop\Windows\library_1_5\iowkit.dll") Then
    MsgBox(0, "", "DLL konnte nicht geladen werden")
    Exit
    EndIf

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

    Dim $hGlobalDevice = _IowKitOpenDevice()

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

    Dim $num = _IowKitGetNumDevs()

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

    Dim $version = _IowKitVersion()

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

    Dim $numdevice = _IowKitGetDeviceHandle($numDevice)

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

    MsgBox(0,"","IowKitOpenDevice: " & $hGlobalDevice & @CRLF & "IowKitGetNumDevs: " & $num & @CRLF & "IowKitVersion: " & $version & @CRLF & "IowKitGetDeviceHandle: " & $numdevice)

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

    _IowKitCloseDevice($hGLobalDevice)

    [/autoit]


    Da funktioniert es mit dem _IowKitGetDeviceHandle($numDevice), aber bei _IowKitGetProductId($devHandle), keine Changse, nichts passiert. kann das an der Variable $devHandle liegen ? Hier nochmal die IOWKIT.au3

    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]

    lg Tim

  • Schu dir nochmal das Beispiel in der Hilfe an. Du sollst nicht die Variable in den Aufruf schrieben, sondern den WERT, den die Variable besitzen soll. Was das fpr ein Wert ist, steht in der Dokumentation deiner DLL.

  • So, ok habe ich gemacht, nun weiß ich was man da reinschreibt ;) DANKE dir für deine Geduld !!!

    Also, nun habe ich eigentlich schon so ziehmlich das teil unter der Kontrolle. Nur leider habe ich das mit dem Write noch nicht ganz raus. Aber erstmal noch eine ander ekleine Frage zu nem Array:

    Spoiler anzeigen
    [autoit]

    #include "IOWKit.au3"
    #include "GUIConstants.au3"

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

    If Not _IowKitStartUp("C:\Users\User\Desktop\Windows\library_1_5\iowkit.dll") Then
    MsgBox(0, "", "DLL konnte nicht geladen werden")
    Exit
    EndIf

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

    Dim $hGlobalDevice = _IowKitOpenDevice()
    Dim $num = _IowKitGetNumDevs()
    Dim $version = _IowKitVersion()
    Dim $numdevice = _IowKitGetDeviceHandle("ulong")
    Dim $ProductID = _IowKitGetProductId("ptr")
    Dim $serialNumber = _IowKitGetSerialNumber("ptr","wstr")

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

    MsgBox(0,"","IowKitOpenDevice: " & $hGlobalDevice & @CRLF & "IowKitGetNumDevs: " & $num & @CRLF & "IowKitVersion: " & $version & @CRLF & "IowKitGetDeviceHandle: " & $numdevice & @CRLF & "IowKitGetProductId: " & $ProductID & @CRLF & "IowKitGetSerialNumber: " & $serialNumber)

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

    _IowKitCloseDevice($hGLobalDevice)

    [/autoit]


    Bei Dim $serialNumber = _IowKitGetSerialNumber("ptr","wstr") habe ich ja für zwei Variablen die WERTE angegeben. Also müsste ich doch auch beide auslesen können. Ok, das steht in der IOWKIT.au3:

    Spoiler anzeigen
    [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]

    Ich bekomme in meinem Obigem Script folgendes zurück:

    [Blockierte Grafik: http://img823.imageshack.us/img823/4387/asdq.png]

    Also für die SerialNummer 0. Aber eigentlich müsste das ja eine mehrstellige Zahl sein. Oder ? In der .,pdf steht etwas interessantes :

    Spoiler anzeigen

    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.

    Aber eigentlich sollte das ja stimmen wegen dem "wstr". Das könnte aber auch die Rückgabe einer Dll sein - Erfolg error = 0 -

    lg Tim

  • Du hast es immer noch nicht Begriffen. Jetzt hast du den VariablenTYP angegeben, Der Wert ist z.B: eine Zahl, ein handle, ein String etc.
    Ein String wird als die Zahl 0 interpertiert, wenn er anstelle einer Zahl verwendet wird.

    Schau dir doch mal den C-Code an. Da wird z.B: der Rückgabewert einer Funktion in einer Variablen gepseichert und der Wert der Variablen dann per Paremter an eine andere Funktion weitergegeben.

    PS: Ich würde dir voschlagen, dich erst mal mit den Grundlagen zu beschäftigen.
    http://web.slzm.de/blog/programmi…uch-episode-ii/
    http://wiki.autoit.de/wiki/index.php/Tutorial
    und die anderen wichtigen Links in der linken Spalte.

  • So, Danke dir, das du mir nicht die Antworten hinschmeist, sondern mir nur tipps gibst. Nun bin ich wider ein Stück weiter. Also folgendes, Mein Script schaut nun so aus:

    Spoiler anzeigen
    [autoit]

    #include "IOWKit.au3"
    #include "GUIConstants.au3"

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

    If Not _IowKitStartUp("C:\Users\User\Desktop\Windows\library_1_5\iowkit.dll") Then
    MsgBox(0, "", "DLL konnte nicht geladen werden")
    Exit
    EndIf

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

    Dim $hGlobalDevice = _IowKitOpenDevice()
    Dim $num = _IowKitGetNumDevs()
    Dim $version = _IowKitVersion()
    Dim $numdevice = _IowKitGetDeviceHandle(1)
    Dim $ProductID = _IowKitGetProductId($numdevice)
    Dim $serialNumber = _IowKitGetSerialNumber($numdevice,"wstr")

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

    MsgBox(0,"","IowKitOpenDevice: " & $hGlobalDevice & @CRLF & "IowKitGetNumDevs: " & $num & @CRLF & "IowKitVersion: " & $version & @CRLF & "IowKitGetDeviceHandle: " & $numdevice & @CRLF & "IowKitGetProductId: " & $ProductID & @CRLF & "IowKitGetSerialNumber: " & $serialNumber)

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

    _IowKitCloseDevice($hGLobalDevice)

    [/autoit]


    Ist auch wunderbar, ich bekomme folgendes zurück:
    [Blockierte Grafik: http://img525.imageshack.us/img525/7185/25107361.png
    doch ärgert mich einwenig noch die Serialnumber mit "1". Ich weiß einfach nicht was ich für "wstr" einsetzten soll, da ich in dem C Script an dieser Stelle ein sn vorfinde. Für was steht das ?

    lg Tim