So, nun läuft es ! Es fehlte ':cdecl' ...
Also, die Struktur des Puffers als ubyte(unsigned char = 0 bis 255), den Funktionsparameter als ubyte*, so ist es korrekt.
Bei mir läuft das Skript aber nur bis zum ersten Aufruf und gibt DHE_ERROR_COMMAND zurück, bei dir müsste es aber schon anders sein ...
Spoiler anzeigen
; Konstanten
Global Const $DHC_SIUDI0 = 0 ; COMMAND
Global Const $DHC_SIUDI1 = 100 ; COMMAND
Global Const $DHC_SIUDI2 = 200 ; COMMAND
Global Const $DHC_SIUDI3 = 300 ; COMMAND
Global Const $DHC_SIUDI4 = 400 ; COMMAND
Global Const $DHC_SIUDI5 = 500 ; COMMAND
Global Const $DHC_SIUDI6 = 600 ; COMMAND
Global Const $DHC_SIUDI7 = 700 ; COMMAND
Global Const $DHC_SIUDI8 = 800 ; COMMAND
Global Const $DHC_SIUDI9 = 900 ; COMMAND
Global Const $DHC_OPEN = 1 ; COMMAND
Global Const $DHC_CLOSE = 2 ; COMMAND
Global Const $DHC_DMXOUTOFF = 3 ; COMMAND
Global Const $DHC_DMXOUT = 4 ; COMMAND
Global Const $DHC_PORTREAD = 5 ; COMMAND
Global Const $DHC_PORTCONFIG = 6 ; COMMAND
Global Const $DHC_VERSION = 7 ; COMMAND
Global Const $DHC_DMXIN = 8 ; COMMAND
Global Const $DHC_RESET = 11 ; COMMAND
Global Const $DHC_DEBUG_OPEN = 12 ; COMMAND
Global Const $DHC_DEBUG_CLOSE = 13 ; COMMAND
Global Const $DHC_WRITEMEMORY = 21 ; COMMAND
Global Const $DHC_READMEMORY = 22 ; COMMAND
Global Const $DHC_SIZEMEMORY = 23 ; COMMAND
Global Const $DHC_3DWRITE = 25 ; COMMAND
Global Const $DHC_3DREAD = 26 ; COMMAND
Global Const $DHC_MMWRITE = 27 ; COMMAND
Global Const $DHC_MMREAD = 28 ; COMMAND
Global Const $DHC_TRANSPORT = 30 ; COMMAND
Global Const $DHP_TRANSPORT_MODEALW = 1 ; PARAM
Global Const $DHP_TRANSPORT_MODEALW32 = 2 ; PARAM
Global Const $DHP_TRANSPORT_MODEOPT = 3 ; PARAM DEFAULT
Global Const $DHP_TRANSPORT_MODEOPT32 = 4 ; PARAM
Global Const $DHC_SERIALNREAD = 47 ; COMMAND
Global Const $DHC_SERIALNWRITE = 48 ; COMMAND
Global Const $DHE_OK = 1 ; RETURN NO ERROR
Global Const $DHE_NOTHINGTODO = 2 ; RETURN NO ERROR
Global Const $DHE_ERROR_COMMAND = -1 ; RETURN ERROR
Global Const $DHE_ERROR_NOTOPEN = -2 ; RETURN ERROR
Global Const $DHE_DMXOUT_PACKWRITE = -1000 ; RETURN ERROR -1005 = ERROR_ACCESS_DENIED -1023 = ERROR_CRC
Global Const $DHE_DMXOUT_PACKREAD = -1100 ; RETURN ERROR
; Dll öffnen
Global Const $dhcDll = DllOpen ('DasHard.dll')
Opt ('OnExitFunc', 'Terminate')
[/autoit] [autoit][/autoit] [autoit]; Dll schließen
Func Terminate ( )
DllClose ($dhcDll)
EndFunc
; *** Dll Funktion ***
Func HardDllCommand ($iCommand, $iParam, $pBloc)
$aRes = DllCall ($dhcDll, 'int:cdecl', 'DasHardCommand', _
'int', $iCommand, _
'int', $iParam, _
'ubyte*', $pBloc)
Return $aRes[0]
EndFunc
; *** Open the interface when your application start :
[/autoit] [autoit][/autoit] [autoit]Dim $v, $interface_open; // global
; Struktur für den Daten-Block erzeugen
$dmxblock = DllStructCreate ('ubyte dmxblock[512]'); // global
$interface_open = HardDllCommand ($DHC_OPEN,0,0);
switch $interface_open
case $DHE_ERROR_NOTOPEN
MsgBox (266256, 'DasHardCommand - Error', 'DHE_ERROR_NOTOPEN')
case $DHE_ERROR_COMMAND
MsgBox (266256, 'DasHardCommand - Error', 'DHE_ERROR_COMMAND')
case $DHE_NOTHINGTODO
MsgBox (266304, 'DasHardCommand - Info', 'DHE_NOTHINGTODO')
case $DHE_OK
MsgBox (266304, 'DasHardCommand - Info', 'DHE_OK')
endswitch
if ($interface_open > 0) then
for $i = 1 to 512
; eigentlich unnötig, wie ProgAndy schon andeutete,
; aber ist ja nur ein Schreibtest ...
ConsoleWrite (DllStructSetData ($dmxblock, 'dmxblock', 0, $i) & @crlf);
next
$v = HardDllCommand ($DHC_DMXOUTOFF,0,0);
endif
; Note :
; - When you open the interface, you don't know the state of the DMX output levels into the interface.
; It's why it's better to clean all DMX levels to be sure.
; *** Send the DMX and read the PORT everytime :
[/autoit] [autoit][/autoit] [autoit]Dim $v, $ports;
if ($interface_open > 0) then
$ports = HardDllCommand ($DHC_PORTREAD,0,0);
$v = HardDllCommand ($DHC_DMXOUT, 512, DllStructGetPtr ($dmxblock, 'dmxblock')); evtl. 'dmxblock[0]' ...
if ($v < 0) then
$v = HardDllCommand ($DHC_CLOSE,0,0);
$v = HardDllCommand ($DHC_OPEN,0,0);
endif
endif
; Note :
; - When you use the DHC_DMXOUT command, the DLL analyses your DMX block.
; If there is no changes on the DMX levels, the function returns DHE_NOTHINGTODO and
; the DLL don't make a USB communication to save the CPU time of your computer.
; - After 6 seconds without USB communication, the USBDMX1 and interfaces go in stand alone mode
; (it's a nice feature, if the computer fails). It's why we propose to read the state of the
; port everytime to force a USB communication, with this, the interface do not go in stand alone mode.
; - If the DHC_DMXOUT command fails (for example, if the user unplug the USB interface !), you need
; to close and try to open again the interface.
; *** Close the interface when your application finish :
[/autoit] [autoit][/autoit] [autoit]Dim $v;
if ($interface_open>0) then _
$v = HardDllCommand ($DHC_CLOSE,0,0);
EDIT: Das Exit musste natürlich noch raus ...
LG
Greenhorn