Jump to content

Help a newbie with a dll call


Andywpg
 Share

Recommended Posts

I'm new to this, so be gentle.

To start, I have read the dllcall tutorial on the forums, but its not helping.

I am trying to call a dll and having trouble. The dll is "super4.dll" and here is the description of the function I want to use from the manufacturers website:

*****start dll description*****

int32_t SetRelays(char* relayBoard, uint8_t mask, uint8_t set)

Set or un-set the relays.

The first 4 bits of the 'mask' determines which relays will be affected:

1 = relay will be affected

0 = leave alone (don't change)

'set' determines whether the relay will be switched on or switched off.

1 = relay on

0 = relay off.

example: To control relay 1 and 3 and leave relay 2 and 4 unchanged, mask = 5 (0101)

Returns:

The state of the relays after the action.

0 to 15:

first 4 bits represent the relay states.

1 = relay is on.

0 = relay is off.

A negative number indicates an error:

-1 invalid relay board string (board not found)

-2 DLL function not loaded (FTD2XX.DLL not found)

-3 Invalid bit mask (must be 0 to 15)

-4 Undefined error

*****end dll description*****

For the life of me, I can't get this to work! Could someone please help and show me how I should format the dll call in AutoIt? As an example, I have been trying to set relay 1, and the name of the board is "virprint"

I would be forever grateful!

Thanks

Andy

Edited by Andywpg
Link to comment
Share on other sites

The deal is - first perhaps you could show what you've tried, then we'll show you ours.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

The deal is - first perhaps you could show what you've tried, then we'll show you ours.

Here are a few of them:

DllCall("super4.dll,"int","int32_t SetRelays","char*","virprint","uint8_t",1,"uint8_t",1)

DllCall("super4.dll","int","SetRelays","virprint","mask",1,"set",1)

DllCall("super4.dll",$retval,"int32_t SetRelays","virprint","uint8_t",1,"uint8_t",1) where $retval was in a statement earlier DIM $retval = 0

DllCall("c:\autoit\super4.dll","none","int32_t SetRelays","char*","virprint","uint8_t",1,"uint8_t",1)

And various other combinations - can't quite remember them all right now.

I really have tried lots of them, just getting frustrated, that's all.

Thanks,

Andy

Edited by Andywpg
Link to comment
Share on other sites

Here are a few of them:

DllCall("super4.dll,"int","int32_t SetRelays","char*","virprint","uint8_t",1,"uint8_t",1)

DllCall("super4.dll","int","SetRelays","virprint","mask",1,"set",1)

DllCall("super4.dll",$retval,"int32_t SetRelays","virprint","uint8_t",1,"uint8_t",1) where $retval was in a statement earlier DIM $retval = 0

DllCall("c:\autoit\super4.dll","none","int32_t SetRelays","char*","virprint","uint8_t",1,"uint8_t",1)

And various other combinations - can't quite remember them all right now.

I really have tried lots of them, just getting frustrated, that's all.

Thanks,

Andy

Try

DllCall("super4.dll","int", "SetRelays","str","virprint","byte",1,"byte",1)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

GENIUS!!! It worked! Thanks SO much!!

Andy

No genius but a little understanding is needed.

The parameters are (in this order)

"super4.dll" = the dll of course

"int" = what you expect the dll function to return. Int32 is presumably a 32 bit integer which is "int" in AutoIt

"SetRelays" = the name of the function to call

"str" = the type of first parameter required by the function. In C char* is simply "str" in AutoIt.

"virprint" = the name of the board

"byte" = the type of the second parameter. Int8 I assume is an 8 bit int which is simply a byte.

1 = second parameter value

"byte" = third parameter type

1 = third parameter value.

I'm glad it worked.

I'm interested to know what the board is you are controlling. If it is sold as a standard part can you tell me?

EDIT: I didn't notice before, so welcome to the AutoIt forums Andy :mellow:

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I'm interested to know what the board is you are controlling. If it is sold as a standard part can you tell me?

It is a USB relay board called the Super4 made by a company called TcTec. Very cool little unit.

We are using it as output relays to control functions in a fire alarm panel while we are testing. The software was all created with AutoIt.

The boards are about $60 canadian and available at:

TcTec

Thanks again for the help!

Andy

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