chadiz Posted November 10, 2007 Share Posted November 10, 2007 Hi all, I have this code working in C win32 , (and also VB.NET ) but I cant get my DLLCALLs to work i have .lib file for the c code and dll file for calling win32 functions this code configures Digital IO ports on a usb DAQ from mcc (usb 1208-FS ) C code: ULStat = cbDConfigPort (BoardNum, PortNum, Direction); ULStat = cbDBitOut (BoardNum, PortType, BitNum, BitValue); so I used the same exact parameter values as in the C code .. yet the config port return successful.. but the BitOut code returns error: port not configured correctly autoIt code: $return = DllCall ( "cbw32.dll", "int", "cbDConfigPort", "int", $Board_number, "int", $Port_Number, "int", $IO_Direction) $return = DllCall ( "cbw32.dll", "int", "cbDBitOut", "int", $Board_number, "int", $Port_Number, "int", $Bit_Number, "ushort", $Bit_Value) ANY ideas why the calls dont work the same? is there any timing or reset involved with this? Thanks Link to comment Share on other sites More sharing options...
BrettF Posted November 10, 2007 Share Posted November 10, 2007 Hi all, I have this code working in C win32 , (and also VB.NET )but I cant get my DLLCALLs to worki have .lib file for the c code and dll file for calling win32 functionsthis code configures Digital IO ports on a usb DAQ from mcc (usb 1208-FS )C code: ULStat = cbDConfigPort (BoardNum, PortNum, Direction); ULStat = cbDBitOut (BoardNum, PortType, BitNum, BitValue);so I used the same exact parameter values as in the C code .. yet the config port return successful.. but the BitOut code returns error: port not configured correctlyautoIt code:$return = DllCall ( "cbw32.dll", "int", "cbDConfigPort", "int", $Board_number, "int", $Port_Number, "int", $IO_Direction)$return = DllCall ( "cbw32.dll", "int", "cbDBitOut", "int", $Board_number, "int", $Port_Number, "int", $Bit_Number, "ushort", $Bit_Value)ANY ideas why the calls dont work the same? is there any timing or reset involved with this?ThanksHi,Welcome to the forums Can we please see your VB.net code (Might be easier)? What are the variables declared as? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
chadiz Posted November 10, 2007 Author Share Posted November 10, 2007 Hi,Welcome to the forums Can we please see your VB.net code (Might be easier)? What are the variables declared as?thanks Bert,here is the VB code that creates an object and calls similar methods:DaqBoard = New MccDaq.MccBoard(BoardNum) '<======this is the default board numberPortNum = MccDaq.DigitalPortType.FirstPortADirection = MccDaq.DigitalPortDirection.DigitalOutULStat = DaqBoard.DConfigPort(PortNum, Direction)...... partial code Dim ULStat As MccDaq.ErrorInfoDim BitValue As MccDaq.DigitalLogicStateDim BitNum As IntegerDim PortType As MccDaq.DigitalPortType' Write to the bits of FirstPortA and FirstPortB digital outputs'NOTE that the port name for all the bits wrote during the DBitOut is'ALWAYS FirstPortAPortType = MccDaq.DigitalPortType.FirstPortA' From checkbox BitNum = Index If (chkSetBit(Index).Checked) Then BitValue = MccDaq.DigitalLogicState.HighElse BitValue = MccDaq.DigitalLogicState.LowEnd IfULStat = DaqBoard.DBitOut(PortType, BitNum, BitValue)function prototypes :Public Function DConfigPort(ByVal portNum As MccDaq.DigitalPortType, ByVal direction As MccDaq.DigitalPortDirection) As MccDaq.ErrorInfo' Digital outputPublic Function DBitOut(ByVal portType As MccDaq.DigitalPortType ,ByVal bitNum As Integer, ByVal bitValue As MccDaq.DigitalLogicState) As MccDaq.ErrorInfoalso I like to call this Analog input that uses reference Public Function AIn(ByVal channel As Integer, ByVal range AsMccDaq.Range , ByRef dataValue As Short) As MccDaq.ErrorInfoI could call .NET methods from .NET DLLso my question: how can I create VB.NET object and use reference parameters? Link to comment Share on other sites More sharing options...
BrettF Posted November 10, 2007 Share Posted November 10, 2007 Goto run, and then try this: regsvr32 <path & filename of dll> And then see what happens if you try this: $oOBJ = ObjCreate("MccDaq.MccBoard") If Not IsObj($oOBJ) Then MsgBox(0, "", "Error") Else MsgBox(0, "", "Success!") EndIf Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
chadiz Posted November 12, 2007 Author Share Posted November 12, 2007 Goto run, and then try this: regsvr32 <path & filename of dll> And then see what happens if you try this: $oOBJ = ObjCreate("MccDaq.MccBoard") If Not IsObj($oOBJ) Then MsgBox(0, "", "Error") Else MsgBox(0, "", "Success!") EndIf I got Error.. and couldnt register the dll.. anything i could do? Link to comment Share on other sites More sharing options...
chadiz Posted November 12, 2007 Author Share Posted November 12, 2007 I got Error.. and couldnt register the dll.. anything i could do?so I managed to register the dll.. using regasm from VStudio command prompt.and i got SUCCESS for creating the object.. I will need to figure out how to call the methods... Link to comment Share on other sites More sharing options...
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