Champak

Dll call help

24 posts in this topic

#1 ·  Posted (edited)

Im trying to include this dll in my script and I'm having no luck. The dcdcOpenDevice function is returning 1 so the communication is good I believe, but the other two functions are returning 0. I believe I'm calling them correctly, however the vb example says I should be using "single" instead of "byte" on dcdcGetVin, but I dont see any reference to "single" in the help file.

Also, anytime the call to dcdcOpenDevice is made any of the msgbox or arraydisplay calls will cause the script to throw an error. But consolewrite is working just fine. Any help, thanks.

This is what I've tried.

#include <Array.au3>

$Open = DllCall("C:\Users\M35X\Desktop\release\DCDCUsbLib.dll", "Byte", "dcdcOpenDevice")
If @error Then MsgBox(0,0,@error)


$Connection = DllCall("C:\Users\M35X\Desktop\release\DCDCUsbLib.dll", "Byte", "dcdcGetConnected")
If @error Then MsgBox(0,0,@error)


$Voltage = DllCall("C:\Users\M35X\Desktop\release\DCDCUsbLib.dll", "Byte", "dcdcGetVin")
If @error Then MsgBox(0,0,@error)

ConsoleWrite("!! " & $Open[0] & @CRLF)
ConsoleWrite("!! " & $Connection[0] & @CRLF)
ConsoleWrite("!! " & $Voltage[0] & @CRLF)

;MsgBox(0,0,$Open[0])
;MsgBox(0,0,$Voltage[0])
;MsgBox(0,0,$Connection[0])

;_ArrayDisplay($Open,"Open")
;_ArrayDisplay($Connection,"connection")
;_ArrayDisplay($Voltage,"voltage")

 

This is VB coding

Imports System.Runtime.InteropServices

Imports System.Text

Module Module1

    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcOpenDevice(ByVal timer As Integer) As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Sub dcdcCloseDevice()
    End Sub
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetConnected() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetTimeCfg() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetVoltageCfg() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetMode() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetState() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetVin() As Single
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetVIgn() As Single
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetVOut() As Single
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetEnabledPowerSwitch() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetEnabledOutput() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetEnabledAuxVOut() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetFlagsStatus1() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetFlagsStatus2() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetFlagsVoltage() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetFlagsTimer() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetFlashPointer() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetTimerWait() As UInt32
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetTimerVout() As UInt32
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetTimerVAux() As UInt32
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetTimerPwSwitch() As UInt32
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetTimerOffDelay() As UInt32
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetTimerHardOff() As UInt32
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetVersionMajor() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetVersionMinor() As Byte
    End Function

    'Set stuff
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Sub dcdcSetEnabledAuxVOut(ByVal set_on As Byte)
    End Sub
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Sub dcdcSetEnabledPowerSwitch(ByVal set_on As Byte)
    End Sub
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Sub dcdcSetEnabledOutput(ByVal set_on As Byte)
    End Sub
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Sub dcdcIncDecVOutVolatile(ByVal set_inc As Byte)
    End Sub
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Sub dcdcSetVOutVolatile(ByVal vout As Single)
    End Sub

    'Flash stuff
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Sub dcdcLoadFlashValues()
    End Sub
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetLoadState() As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Function dcdcGetMaxVariableCnt() As UInt32
    End Function
    <DllImport("DCDCUsbLib.dll", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl)> _
    Function dcdcGetVariableData(ByVal cnt As UInt32, ByVal name As StringBuilder, ByVal value As StringBuilder, ByVal unit As StringBuilder, ByVal comment As StringBuilder) As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Cdecl)> _
    Function dcdcSetVariableData(ByVal cnt As UInt32, ByVal value As String) As Byte
    End Function
    <DllImport("DCDCUsbLib.dll", CallingConvention:=CallingConvention.Cdecl)> Sub dcdcSaveFlashValues()
    End Sub

    Sub Main()
        Dim sCurPath

        sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
        Console.WriteLine(sCurPath)

        Dim bRes As Byte
        bRes = dcdcOpenDevice(1000)

        If (bRes) Then
            Console.WriteLine("DCDC Found!")
            System.Threading.Thread.CurrentThread.Sleep(1000)
            Console.Write("V")
            Console.Write(dcdcGetVersionMajor())
            Console.Write(".")
            Console.Write(dcdcGetVersionMinor())
            Console.WriteLine()
        Else
            Console.WriteLine("DCDC Not found!")
        End If

        Console.WriteLine("Press Esc to exit")

        Dim cki As ConsoleKeyInfo



        Do
            If (Console.KeyAvailable) Then
                cki = Console.ReadKey()
                Select Case cki.Key
                    Case ConsoleKey.D1
                        Console.Write("===> AUX ON")
                        dcdcSetEnabledAuxVOut(1)
                    Case ConsoleKey.D2
                        Console.Write("===> AUX OFF")
                        dcdcSetEnabledAuxVOut(0)
                    Case ConsoleKey.D3
                        Console.Write("===> Power ON")
                        dcdcSetEnabledPowerSwitch(1)
                    Case ConsoleKey.D4
                        Console.Write("===> Power OFF")
                        dcdcSetEnabledPowerSwitch(0)
                    Case ConsoleKey.D5
                        Console.Write("===> VOut ON")
                        dcdcSetEnabledOutput(1)
                    Case ConsoleKey.D6
                        Console.Write("===> VOut OFF")
                        dcdcSetEnabledOutput(0)
                    Case ConsoleKey.D7
                        Console.Write("===> VOut INC")
                        dcdcIncDecVOutVolatile(1)
                    Case ConsoleKey.D8
                        Console.Write("===> VOut DEC")
                        dcdcIncDecVOutVolatile(0)
                    Case ConsoleKey.D9
                        Console.Write("===> VOut Direct 12V")
                        dcdcSetVOutVolatile(12.0)
                    Case ConsoleKey.L
                        Console.Write("===> Loading flash")
                        dcdcLoadFlashValues()

                        Dim timeout As Integer
                        timeout = 0

                        Do
                            timeout = timeout + 1
                            System.Threading.Thread.CurrentThread.Sleep(1000)
                        Loop While timeout < 10 And dcdcGetLoadState() < 100
                        Console.Write("Loading flash =")
                        Console.Write(dcdcGetLoadState())
                        Console.WriteLine()

                        If (dcdcGetLoadState() = 100) Then
                            Dim max As UInt32 = dcdcGetMaxVariableCnt() - 1
                            Console.Write("Variables=")
                            Console.Write(max)
                            Console.WriteLine()
                            For index As UInt32 = 0 To max
                                Dim value As StringBuilder = New StringBuilder(256)
                                Dim unit As StringBuilder = New StringBuilder(256)
                                Dim name As StringBuilder = New StringBuilder(256)
                                Dim comment As StringBuilder = New StringBuilder(1024)
                                If (dcdcGetVariableData(index, name, value, unit, comment)) Then
                                    Console.Write("[")
                                    Console.Write(index)
                                    Console.Write("] ")
                                    Console.Write(name.ToString())
                                    Console.Write("=")
                                    Console.Write(value.ToString())
                                    Console.Write(" ")
                                    Console.Write(unit.ToString())
                                    Console.WriteLine()
                                    'Else
                                    'Console.Write("[")
                                    'Console.Write(index)
                                    'Console.Write("] not used")
                                    'Console.WriteLine()
                                End If
                            Next
                        End If
                    Case ConsoleKey.Q
                        Console.Write("===> Saving flash 1")
                        'see complete list with ConsoleKey.L (format is displayed too)
                        dcdcSetVariableData(0, "20.11") 'Voltage 0 (VOut at startup)
                        dcdcSetVariableData(10, "511") 'Ignition debounce

                        dcdcSetVariableData(20, "10001101") 'config flags
                        dcdcSetVariableData(24, "Never") 'Off-delay TIME 1
                        dcdcSaveFlashValues()
                    Case ConsoleKey.W
                        Console.Write("===> Saving flash 2")
                        dcdcSetVariableData(0, "23.35") 'Voltage 0 (VOut at startup)
                        dcdcSetVariableData(10, "500") 'Ignition debounce

                        dcdcSetVariableData(20, "00001101") 'config flags
                        dcdcSetVariableData(24, "00:00:05") 'Off-delay TIME 1
                        dcdcSaveFlashValues()
                End Select
                Console.WriteLine()
            End If

            If dcdcGetConnected() = 0 Then
                dcdcCloseDevice()
                Console.Write("No device")
                Console.WriteLine()
            Else
                Select Case dcdcGetMode()
                    Case 0 : Console.Write("[Dumb]")
                    Case 1 : Console.Write("[Automotive]")
                    Case 2 : Console.Write("[Script]")
                    Case 3 : Console.Write("[UPS]")
                    Case Else : Console.Write("[Error]")
                End Select

                Console.Write(" State:")
                Console.Write(dcdcGetState())
                Console.Write(" VIn:")
                Console.Write(dcdcGetVin())
                Console.Write(" VIgn:")
                Console.Write(dcdcGetVIgn())
                Console.Write(" VOut:")
                Console.Write(dcdcGetVOut())
                Console.Write(" Switches[PW:")
                Console.Write(dcdcGetEnabledPowerSwitch())
                Console.Write(" VOut:")
                Console.Write(dcdcGetEnabledOutput())
                Console.Write(" Aux:")
                Console.Write(dcdcGetEnabledAuxVOut())
                Console.Write("]")
                Console.WriteLine()

                Console.Write("   CfgT:")
                Console.Write(dcdcGetTimeCfg())
                Console.Write(" CfgV:")
                Console.Write(dcdcGetVoltageCfg())
                Console.Write(" Flags[")
                Console.Write(dcdcGetFlagsStatus1())
                Console.Write(" ")
                Console.Write(dcdcGetFlagsStatus2())
                Console.Write(" ")
                Console.Write(dcdcGetFlagsVoltage())
                Console.Write(" ")
                Console.Write(dcdcGetFlagsTimer())
                Console.Write(" ")
                Console.Write(dcdcGetFlashPointer())
                Console.Write("] Timers[")
                Console.Write(dcdcGetTimerWait())
                Console.Write(" ")
                Console.Write(dcdcGetTimerVout())
                Console.Write(" ")
                Console.Write(dcdcGetTimerVAux())
                Console.Write(" ")
                Console.Write(dcdcGetTimerPwSwitch())
                Console.Write(" ")
                Console.Write(dcdcGetTimerOffDelay())
                Console.Write(" ")
                Console.Write(dcdcGetTimerHardOff())
                Console.Write("]")
                Console.WriteLine()
            End If

            System.Threading.Thread.CurrentThread.Sleep(1000)
        Loop While cki.Key <> ConsoleKey.Escape

        dcdcCloseDevice()
    End Sub

End Module

 

attached is the dll

 

DCDCUsbLib.dll

Edited by Champak

Share this post


Link to post
Share on other sites



By default, AutoIt uses the 'stdcall' calling method. To use the 'cdecl' method place ':cdecl' after the return type.
DllCall("SQLite.dll", "int:cdecl", "sqlite3_open", "str", $sDatabase_Filename , "long*",

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks, I tried that, same issue.

Edited by Champak

Share this post


Link to post
Share on other sites

The openDevice call fails because it expects you to parse an int parameter Timer (see Help doc for how to do this); and Single = Float, not Byte.

Share this post


Link to post
Share on other sites


Based on your general understanding about these dllcalls, is that timer in the call meant to keep the device open for the other functions to communicate with the device and retrieve/set information?


I don't see anything in the help file about dllcall about timers or parsing, so is one of these attempts correct?
Like this?

$Open = DllCall("C:\Users\M35X\Desktop\release\DCDCUsbLib.dll", "Byte", "dcdcOpenDevice(1000)")


Or like this?

$Open = DllCall("C:\Users\M35X\Desktop\release\DCDCUsbLib.dll", "Byte", "dcdcOpenDevice", "int", 1000)


 

Share this post


Link to post
Share on other sites

JohnOne is right. If the documentation says cdecl the you have(!) to use :cdecl.
(However if the function has no parameters then calling convention is irrelevant)

$Open = DllCall($hDLL, "byte:cdecl", "dcdcOpenDevice", "dword", 1000)

 


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Sorry, JohnOne I forgot to add it in this post, but I did put it in the script this morning and it didnt do anything....however, I didnt make the initial call to dcdcOpenDevice with the timer. 

@trancexx thanks, The functions, as far as i see do not have parameters, except the dcdcOpenDevice.

Edited by Champak

Share this post


Link to post
Share on other sites

@champak, I think you may have misunderstood my comment. That "Timer" variable is from your own VB script you posted. The first dllcall to open a device appears to expect an integer defining some timer, maybe a timeout before a "device not found" error is triggered or something (just guessing, I don't use that dll). So I think you'll need to include a predefined variable of type integer when you make that particular call. And trancexx is of course right; the calling convention defines in what order such parsed parameters are placed on the stack (for the dll to pop them off again), so if you use the wrong convention, misalignments and misattributions will happen if two or more parameters are parsed, and your call will then very likely fail. And if your first call to open a device has failed, then everything you try to do through the dll with that device thereafter will also fail, obviously.

From your responses I gather that you are not yet thoroughly familiar with dllcalls in general. There's a tutorial at https://www.autoitscript.com/forum/topic/93496-tutorial-on-dllcall-dllstructs/

Furthermore, if you're calling the same dll over and over, it's more efficient to open it once (receiving a handle) and then call it using its handle (of course, that means that you have to close it too when you're done).

Share this post


Link to post
Share on other sites

Thats a good read. I was still getting nowhere with the adjustments, so I tried the open and close method and now I'm getting a return from dcdcGetConnected, but dcdcGetVin and every other "get" data function is not returning anything except 0. I know there is communication because when I disconnect the device dcdcOpenDevice returns 0 instead of 1.

This is my adjustment. Also, msgbox and array causing shuutdowns

#include <Array.au3>
$dll = DllOpen("C:\Users\M35X\Desktop\release\DCDCUsbLib.dll")

$Open = DllCall($dll, "Byte:cdecl", "dcdcOpenDevice", "dword", 1000)
If @error Then MsgBox(0,0,@error)

$Connection = DllCall($dll, "Byte:cdecl", "dcdcGetConnected")
If @error Then MsgBox(0,0,@error)

$Voltage = DllCall($dll, "float:cdecl", "dcdcGetVin")
If @error Then MsgBox(0,0,@error)

;$Close = DllCall($dll, "Byte:cdecl", "dcdcCloseDevice")
;If @error Then MsgBox(0,0,@error)

DllClose($dll)

ConsoleWrite("!! " & $Open[0] & @CRLF)
ConsoleWrite("!! " & $Connection[0] & @CRLF)
ConsoleWrite("!! " & $Voltage[0] & @CRLF)
;ConsoleWrite("!! " & $Close[0] & @CRLF)


;MsgBox(0,0,$Open[0])
;MsgBox(0,0,$Voltage[0])
;MsgBox(0,0,$Connection[0])

;_ArrayDisplay($Open,"Open")
;_ArrayDisplay($Connection,"connection")
;_ArrayDisplay($Voltage,"voltage")

Any other ideas?

Share this post


Link to post
Share on other sites

Yes, all of them, and all return 0. When I start playing with and changing the return type, I get sequence of numbers, but none of which are what they should be...if that matters.

 

Share this post


Link to post
Share on other sites

In the C++ code it appears to imply that dcdcGetConnected is of type bool...

// DCDCUsbLibTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <windows.h>
#include <conio.h>
#include "..\DCDCUsbLib\DCDCUsbLib.h"

int _tmain(int argc, _TCHAR* argv[])
{
    printf("HIT <Esc> TO EXIT!\n");
    dcdcOpenDevice(1000);
    //if (dcdcOpenDeviceByCnt(2, 1000))
    if (dcdcGetConnected())
    {
        printf("DCDC opened!\n");
        Sleep(500); //it's recommended to give a few miliseconds before the first read otherwise the first read might be 0 

        //the library reads the UPS values in every 1000 msec (once per second)
        //therefore is useless to read them faster from here

        char path[1024];
        dcdcGetDevicePath(path);
        
        printf(" firmware: %02d.%02d \n",dcdcGetVersionMajor(),dcdcGetVersionMinor());
        printf(" mode: %d\n",dcdcGetMode());
        printf(" path: %s\n",path);
        printf("------------------------------\n");
    }
    else printf("DCDC not found!\n");

    char ch = 0;

    while (ch != 27)
    {
        if (_kbhit())
        {
            ch = _getch();
            if (ch != 27)
            {
                printf("Press again:\n1.Switch aux ON\n2.switch aux OFF\n3.Switch power ON\n4.Switch power OFF\n5.Switch VOut ON\n6.Switch VOut OFF\n");
                printf("7.Increase VOut\n8.Decrease VOut\n9.Set VOut\nL.Load flash");
                ch = _getch();
                switch (ch)
                {
                case '1': printf("AUX ON\n");dcdcSetEnabledAuxVOut(true); break;
                case '2': printf("AUX OFF\n");dcdcSetEnabledAuxVOut(false); break;
                case '3': printf("Power ON\n");dcdcSetEnabledPowerSwitch(true); break;
                case '4': printf("Power OFF\n");dcdcSetEnabledPowerSwitch(false); break;
                case '5': printf("VOut ON\n");dcdcSetEnabledOutput(true); break;
                case '6': printf("VOut OFF\n");dcdcSetEnabledOutput(false); break;
                case '7': printf("INC VOut\n");dcdcIncDecVOutVolatile(true); break;
                case '8': printf("DEC VOut\n");dcdcIncDecVOutVolatile(false); break;
                case '9': printf("Set VOut to 12V\n");dcdcSetVOutVolatile(12.0); break;
                case 'l':
                case 'L': 
                    {
                        printf("Loading flash values. Wait ...\n");
                        dcdcLoadFlashValues();
                        int timeout = 0;
                        while ((dcdcGetLoadState() < 100) && (timeout < 10))//wait for 10 seconds
                        {
                            printf("Loading %d%c\n",dcdcGetLoadState(),'%');
                            timeout++;
                            Sleep(1000);
                        }
                        printf("Loading final: %d%c\n",dcdcGetLoadState(),'%');
                        if (dcdcGetLoadState() == 100)//succesfull
                        {
                            unsigned int var_max = dcdcGetMaxVariableCnt();
                            char name[256];
                            char value[256];
                            char unit[256];
                            char comment[1024];

                            for (int i=0;i<var_max;i++)
                                if (dcdcGetVariableData(i, name, value, unit, comment))
                                    printf("[%d] %s=%s %s\n",i,name, value, unit);//, comment);
                        }
                    }break;
                case 'q':
                case 'Q':
                case 'w':
                case 'W':
                    if ((ch == 'q') || (ch == 'Q'))
                    {
                        dcdcSetVariableData(0, "20.11");//Voltage 0 (VOut at startup)
                        dcdcSetVariableData(10, "511");//Ignition debounce
                        dcdcSetVariableData(20, "10001101");//config flags
                        dcdcSetVariableData(24, "00:11:05");//Off-delay TIME 1
                    }
                    else
                    {
                        dcdcSetVariableData(0, "23.00");//Voltage 0 (VOut at startup)
                        dcdcSetVariableData(10, "500");//Ignition debounce
                        dcdcSetVariableData(20, "00001101");//config flags
                        dcdcSetVariableData(24, "00:00:05");//Off-delay TIME 1
                    }

                    dcdcSaveFlashValues();
                    break;
                }
            }
        }
        else
        {
            if (dcdcGetConnected() == false)
            {
                //dcdcCloseDevice();
                printf("No device\n");
            }
            else
            {
                switch (dcdcGetMode())
                {
                case 0: printf("[Dumb] ");break;
                case 1: printf("[Automotive]  ");break;
                case 2: printf("[Script]  ");break;
                case 3: printf("[UPS]  ");break;
                default:printf("[Error]  ");
                }

                printf("State:%02x Vin:%.2f VIgn:%.2f VOut:%.2f SW[Power:%d Output:%d Aux:%d]\n",
                    dcdcGetState(), dcdcGetVin(),dcdcGetVIgn(),dcdcGetVOut(),
                    dcdcGetEnabledPowerSwitch(), dcdcGetEnabledOutput(),dcdcGetEnabledAuxVOut());
                printf("    CfgT:%02x CfgV:%02x Flags[%02X %02X %02X %02X %02X] Timers[%d %d %d %d %d %d]\n", 
                    dcdcGetTimeCfg(),dcdcGetVoltageCfg(),
                    dcdcGetFlagsStatus1(),dcdcGetFlagsStatus2(),dcdcGetFlagsVoltage(),dcdcGetFlagsTimer(),dcdcGetFlashPointer(),
                    dcdcGetTimerWait(),dcdcGetTimerVout(),dcdcGetTimerVAux(),dcdcGetTimerPwSwitch(),dcdcGetTimerOffDelay(),dcdcGetTimerHardOff());
            }
            Sleep(1000);
        }
    }//while
    dcdcCloseDevice();

    return 0;
}

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Thanks JohnOne for pointing out that version, it helped me to fix my issue. It needs to sleep a bit after each call...not just the openDevice as it states here... even if the call has nothing to do with the next function. Thanks all for your help.

So I understand the thinking for future (even though it may seem obvious at this point), what made you look in this version as opposed to just relying on the vb version which is more closely related to autoit.

Share this post


Link to post
Share on other sites

@J1 : I'm not clever with Dllcall and variables types, maybe you can confirm that : if I understand the helpfile, BYTE and BOOLEAN are both "an unsigned 8 bit integer", so it should work with both in the DllCall, no ?

 

1 person likes this

Share this post


Link to post
Share on other sites

There's a difference in size between BOOLEAN (8 bits, unaligned = 1 BYTE) and BOOL (32-bits, memory-aligned = 4 BYTES).

1 person likes this

Share this post


Link to post
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