microera Posted May 1, 2012 Posted May 1, 2012 HiI have this info about DLL using (functions):http://www.silabs.com/Support%20Documents/TechnicalDocs/an117.pdfHow to using in AutoIt?example from this pdf (see above link):===========================================================================3. Communications FunctionsThe following communication functions are available for use in the Interface Utilities DLL.Connect() - Connects to a target C8051Fxxx device using a Serial Adapter.Disconnect() - Disconnects from a target C8051Fxxx device using a Serial Adapter.ConnectUSB() - Connects to a target C8051Fxxx device using a USB Debug Adapter.DisconnectUSB() - Disconnects from a target C8051Fxxx device using a USB Debug Adapter.Connected() - Returns the connection state of the target C8051Fxxx device.3.1. Connect()Description: This function is used to connect to a target C8051Fxxx device using a Serial Adapter. Establishinga valid connection is necessary for all memory operations to succeed.Supported Debug Adapters: Serial AdapterC++ Prototype: extern āCā __declspec(dllimport) HRESULT__stdcall Connect(int nComPort=1, int nDisableDialogBoxes=0, int nECprotocol=0,int nBaudRateIndex=0);===========================================================================How to use for example Connect() function?THANKS!
Andreik Posted May 1, 2012 Posted May 1, 2012 (edited) Example for Connect function:Func Connect($nComPort=1,$nDisableDialogBoxes=0,$nECprotocol=0,$nBaudRateIndex=0) Local $aRet = DllCall("siuitl.dll","long","Connect","int",$nComPort,"int",$nDisableDialogBoxes,"int",$nECprotocol,"int",$nBaudRateIndex) Return $aRet[0] EndFunc Edited May 1, 2012 by Andreik
microera Posted May 1, 2012 Author Posted May 1, 2012 (edited) HiI try[/sub] [sub]Global $int_ComPort Global $int_nDisableDialogBoxes Global $int_nECprotocol Global $int_nBaudRateIndex $int_ComPort=1 $int_nDisableDialogBoxes=0 $int_nECprotocol=0 $int_nBaudRateIndex =0 $aReturn=Connect($int_ComPort, $int_nDisableDialogBoxes, $int_nECprotocol, $int_nBaudRateIndex) MsgBox(0, "Info", "retun=" & $aReturn)[/sub] [sub]Func Connect($nComPort=1,$nDisableDialogBoxes=0,$nECprotocol=0,$nBaudRateIndex=0) Local $aRet = DllCall("siuitl.dll","long","Connect","int",$nComPort,"int",$nDisableDialogBoxes,"int",$nECprotocol,"int",$nBaudRateIndex) Return $aRet[0] EndFunc but I get:Subscript used with non-Array variable. at return $aRet[0]why? Edited May 1, 2012 by microera
microera Posted May 1, 2012 Author Posted May 1, 2012 Yes it works!!!! Global $int_ComPort Global $int_nDisableDialogBoxes Global $int_nECprotocol Global $int_nBaudRateIndex $int_ComPort=1 ;1=default COM port $int_nDisableDialogBoxes=0 ;Disable (1) or enable (0) dialogs boxes within the DLL. The default is 0. $int_nECprotocol=1 ;0=JTAG 1=C2 $int_nBaudRateIndex =0 ;Autobaud detection (0), 115200(1), 57600 (2), 38400 (3), 9600 (4) or 2400 (5). The default is 0. $aReturn=Connect($int_ComPort, $int_nDisableDialogBoxes, $int_nECprotocol, $int_nBaudRateIndex) MsgBox(0, "Info", "return=" & $aReturn) Func Connect($nComPort=1,$nDisableDialogBoxes=0,$nECprotocol=1,$nBaudRateIndex=0) Local $aRet Local $dll $dll= DllOpen("SiUtil.dll") if $dll=-1 Then MsgBox(0, "Info", "Error! failure open DLL") exit EndIf $aRet= DllCall($dll,"long","Connect","int",$nComPort,"int",$nDisableDialogBoxes,"int",$nECprotocol,"int",$nBaudRateIndex) DllClose($dll) Return $aRet ;[0] EndFunc
Andreik Posted May 1, 2012 Posted May 1, 2012 I wrote a small UDF for SiUtil.dll. Example: #include <SiUtil.au3> SiUtil_Init() ConsoleWrite("DLL Version: " & SiUtil_GetDLLVersion() & @CRLF) ConsoleWrite("SA Firmware Version: " & SiUtil_GetSAFirmwareVersion() & @CRLF) $Connect = SiUtil_Connect() ConsoleWrite(SiUtil_GetErrorMsg($Connect) & @CRLF) $Connected = SiUtil_Connected() ConsoleWrite("Connected: " & $Connected & @CRLF) $Disconnect = SiUtil_Disconnect() ConsoleWrite(SiUtil_GetErrorMsg($Disconnect) & @CRLF) SiUtil_UnInit()SiUtil.au3
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now