I know this question was asked many, many years ago. But after recent frustration in dealing with this box, here is the script I wrote to communicate with the Ontrak ADU200. Just copy AduHid.dll to the same folder and run.
;Tested with ONTRAK ADU200
Global $DisplayMsgBox=''
;global $DisplayMsgBox='1'
Global $dll = DllOpen( "AduHid.DLL" )
Global $iHandle=0
_TestAduDevice()
Func _TestAduDevice()
$iHandle=_OpenAduDevice(1)
ConsoleWrite(Number($iHandle)&@CRLF)
if @error then ConsoleWrite('','','failed open'&@CRLF)
_WriteAduDevice($iHandle,'SK0',0,500)
sleep(500)
_WriteAduDevice($iHandle,'RK0',0,500)
_WriteAduDevice($iHandle,'SPK1011',0,500) ;Binary Output Relay Set 1011
_WriteAduDevice($iHandle,'RPK',0,500) ; Read Relay Bits
$ret=(_ReadAduDevice($iHandle,'RPK',0,500))
ConsoleWrite('Relay Binary Bits Set to: '&($ret)&@CRLF)
sleep(500)
;_WriteAduDevice($iHandle,'RC0',0,500) ; Clear Switch 0 Counter
; sleep(1000)
_WriteAduDevice($iHandle,'RPA',0,500) ; Read input Switch Bits
$ret=(_ReadAduDevice($iHandle,'RPA',0,500))
ConsoleWrite('Input Switch Bits Set to: '&($ret)&@CRLF)
sleep(500)
_WriteAduDevice($iHandle,'RE0',0,500) ; Read Switch 0 Count
$ret=(_ReadAduDevice($iHandle,'RE0',0,500))
ConsoleWrite(Number($ret)&@CRLF)
_WriteAduDevice($iHandle,'DB2',0,500) ; Set Debounce to 100ms
_WriteAduDevice($iHandle,'DB',0,500) ; Read Debounce setting
$ret=(_ReadAduDevice($iHandle,'DB',0,500))
ConsoleWrite('Debounce Set to: '&($ret)&@CRLF)
_WriteAduDevice($iHandle,'WD3',0,500) ; Set Watchdog Timeout to 1min
_WriteAduDevice($iHandle,'WD',0,500) ; Read Watchdog Timeout setting
$ret=(_ReadAduDevice($iHandle,'WD',0,500))
ConsoleWrite('Watchdog Timeout Set to: '&($ret)&@CRLF)
_WriteAduDevice($iHandle,'WD0',0,500) ; Set Watchdog Timeout OFF
_CloseAduDevice($iHandle)
DllClose( $dll )
EndFunc
Func _OpenAduDevice($aduHandle)
Local $ret
$ret = DllCall( $dll, 'long','OpenAduDevice','long', 500 )
if @error then ConsoleWrite('failed open'&@CRLF)
If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $ret[0])
return $ret[0]
EndFunc
Func _CloseAduDevice($aduHandle)
Local $ret
$ret = DllCall( $dll, 'long','CloseAduDevice','long', $aduHandle )
if @error then ConsoleWrite('failed close'&@CRLF)
If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $ret[0])
return $ret[0]
EndFunc
Func _WriteAduDevice($aduHandle,$lpBuffer,$lBytesWritten,$iTimeout)
Local $ret
$lNumberOfBytesToWrite=StringLen($lpBuffer)
$ret = DllCall( $dll, 'long','WriteAduDevice','long', $aduHandle, 'str',$lpBuffer, 'long',$lNumberOfBytesToWrite, 'long', $lBytesWritten, 'long', $iTimeout )
if @error then ConsoleWrite('failed write'&@CRLF)
If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $ret[0])
return $ret[0]
EndFunc
Func _ReadAduDevice($aduHandle,$sResponse,$iBytesRead,$iTimeout)
Local $ret
$ret = DllCall( $dll, 'long','ReadAduDevice','long', $aduHandle, 'str',$sResponse,'str',7, 'long',$iBytesRead, 'long', $iTimeout )
if @error then ConsoleWrite('failed read'&@CRLF)
If $DisplayMsgBox <> "" Then MsgBox(0,"_GetLastErrorMessage",$DisplayMsgBox & @CRLF & $ret[0])
return $ret[2]
EndFunc