DANKE dir, ich habe bis jetzt noch folgendes gedunden. Das steht in der Anleitung mit C-Beispiel. Ich habe mich mit dem E77, auf den vorherigen Eintrag verlassen. Der Anleitung zur volge, muss es, wenn es klappt ja dem $buffer eine 1 einschrieben. Und die Serialnummer muss ja dann sowas wie 8 stellig sein.
Spoiler anzeigen
O-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
Ich bekomme folgende Ergebnisse für folgende Funktionen:
Spoiler anzeigen
;Seriennummer auslesen
; Entweder so ...
$buffer = DLLStructCreate("WCHAR[9]")
$res = DllCall($dllIOW, "BOOL", "IowKitGetSerialNumber", "PTR", $hKitIOW, "PTR", DllStructGetPtr ($buffer))
If (not @error) Then
$snIOW = $res[0] ; Hier bitte über _Arraydisplay($res) das richtige auswähle, keine Ahnung welches man hier braucht!!!
Else
$snIOW = "error code: "&@error
EndIf
=>
Spoiler anzeigen
>"D:\Programme\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\User\Desktop\test2.au3"
NUM 1
PID 0x00001500
S/N 1
>Exit code: 0 Time: 0.323
;
Spoiler anzeigen
;Seriennummer auslesen
; Entweder so ...
$buffer = DLLStructCreate("WCHAR[9]")
$res = DllCall($dllIOW, "BOOL", "IowKitGetSerialNumber", "PTR", $hKitIOW, "PTR", DllStructGetPtr ($buffer))
If (not @error) Then
$snIOW = $res[1] ; Hier bitte über _Arraydisplay($res) das richtige auswähle, keine Ahnung welches man hier braucht!!!
Else
$snIOW = "error code: "&@error
EndIf
=>
Spoiler anzeigen
NUM 1
PID 0x00001500
S/N 0x03020014
Das selbe auch wenn ich 2 ins Array Schreibe. Das einzig ärgerliche ist es, das ich irgendwie wenn ich das Script Starte mal 0x03020014 oder beim nächsten mal 0x00EE54F3 oder irgendwelche Random zahlen bekomme, was mich stark verwundert. Oder soll es so sein ? Ich denke wenn cih die Seriennummer abfrage muss die doch gleich bleiben. Oder was meint Ihr ? Naja, weiter gehts
Spoiler anzeigen
;Seriennummer auslesen
; Entweder so ...
$buffer = DLLStructCreate("WCHAR[9]")
$res = DllCall($dllIOW, "BOOL", "IowKitGetSerialNumber", "PTR", $hKitIOW, "PTR", DllStructGetPtr ($buffer))
If (not @error) Then
$snIOW = _ArrayDisplay($res[0]) ; Hier bitte über _Arraydisplay($res) das richtige auswähle, keine Ahnung welches man hier braucht!!!
Else
$snIOW = "error code: "&@error
EndIf
=>
Spoiler anzeigen
NUM 1
PID 0x00001500
S/N 0
;
Spoiler anzeigen
;Seriennummer auslesen
; Entweder so ...
$buffer = DLLStructCreate("WCHAR[9]")
$res = DllCall($dllIOW, "BOOL", "IowKitGetSerialNumber", "PTR", $hKitIOW, "PTR", DllStructGetPtr ($buffer))
If (not @error) Then
$snIOW = _ArrayDisplay($res[1]) ; Hier bitte über _Arraydisplay($res) das richtige auswähle, keine Ahnung welches man hier braucht!!!
Else
$snIOW = "error code: "&@error
EndIf
=>
Spoiler anzeigen
>"D:\Programme\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\User\Desktop\test2.au3"
NUM 1
PID 0x00001500
S/N 0
>Exit code: 0 Time: 0.327
;
Spoiler anzeigen
;Seriennummer auslesen
; Entweder so ...
$buffer = DLLStructCreate("WCHAR[9]")
$res = DllCall($dllIOW, "BOOL", "IowKitGetSerialNumber", "PTR", $hKitIOW, "PTR", DllStructGetPtr ($buffer))
If (not @error) Then
$snIOW = _ArrayDisplay($res[2]) ; Hier bitte über _Arraydisplay($res) das richtige auswähle, keine Ahnung welches man hier braucht!!!
Else
$snIOW = "error code: "&@error
EndIf
=>
Spoiler anzeigen
>"D:\Programme\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\User\Desktop\test2.au3"
NUM 1
PID 0x00001500
S/N 0
>Exit code: 0 Time: 0.329
;
Und ab drei geht nichts mehr, weil es dafür kein Array gibt.
So, nun bin ich gespannt was Ihr schriebt
Wenn es hilft, hier noch einmal das C- Beispiel, das nach dem Starten die Led´s meines I/OWarriors blinken lässt
Spoiler anzeigen
//
// ioblink.cpp - Blinking LEDs sample
//
#include "stdafx.h"
#include "time.h"
#include "iowkit.h"
// Write simple value
BOOLEAN WriteSimple(IOWKIT_HANDLE devHandle, DWORD value)
{
IOWKIT56_IO_REPORT rep;
// 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;
default:
return FALSE;
}
}
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;
// 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++)
{
// 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;
}
Sleep(100);
}
// Close device
IowKitCloseDevice(devHandle);
out:
return 0;
}
lg Tim