Jump to content

DLL call funtions (how?)


Recommended Posts

Hi

I have this info about DLL using (functions):

http://www.silabs.com/Support%20Documents/TechnicalDocs/an117.pdf

How to using in AutoIt?

example from this pdf (see above link):

===========================================================================

3. Communications Functions

The 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. Establishing

a valid connection is necessary for all memory operations to succeed.

Supported Debug Adapters: Serial Adapter

C++ 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!

Link to comment
Share on other sites

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 by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Hi

I 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 by microera
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

When the words fail... music speaks.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...