Jump to content

Alex723

Members
  • Posts

    7
  • Joined

  • Last visited

LabVIEW Information

  • Version
    LabVIEW 8.5
  • Since
    2011

Alex723's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Yes. The DLL I posted was a debugging example. Real Labview DLLs will be developed by LabView programmer to be called from my VB.net application. DLLs can changed to accomodate any calling needs. Since I am not Labview developer I need to find a way to call that DLLs and explain LV programmer my requirements as long as they are duable in Labview.
  2. Since "ComPort parameter is a reference to a VISA session ... and passing a constant that corresponds to the COM port you want to open WILL NOT WORK" could it be done different way? For example, currently I have a parameter COLOR passing as simple integer which LV DLL uses inside its own way to change LCD color. Now could be similar approach used for VISA parameter or that cluster ERROR variables? For example, instead passing real VISA type parameter, VB sends an integer 1, and and a code inside DLL just makes a selection such as if this number =1 then use COM1, if this number =2 then use COM2. In this case VB would deal with its own standard variables and Labiew would deal with its own data types.
  3. Thanks a lot for the detailed explanation. I thought that calling Labiew DLL with VISA parameters was quite popular and expected to find clear examples. Unfortunately few examples NI provides show passing regular but not LabVIEW specific variables.
  4. Unfortunately, nothing I have tried works. This is how the header file looks like: #include "extcode.h" #pragma pack(push) #pragma pack(1) #ifdef __cplusplus extern "C" { #endif typedef struct { LVBoolean status; int32_t code; LStrHandle source; } TD1; void __cdecl LCDColor(LVRefNum *VISAIN, uint16_t LCDColor2, TD1 *errorInNoError, LVRefNum *VISAOUT, char OutputString[], TD1 *errorOut, int32_t len); long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module); #ifdef __cplusplus } // extern "C" #endif #pragma pack(pop) Also ffrom this DLL developer I learned that inside Labview code it uses name "COM1" as a string for the Com Port under VISAIN and VISAOUT parameter, also that parameters errorIn,OutputStr, errorOut, len are optional. I have tried several ways to declare and call it in VB.NET: 1. DeclareAutoFunction LCDColor Lib"..LabVIEWdllsLCD Color.dll" (ByVal ComPortIn AsString, ByVal color As Int16, ByRef errIn As Int32, ByVal ComPortOut AsString, ByRef outPutStr AsString, ByRef errOut As Int32, ByRef len As Int32) AsInt32 Call as LCDColor("COM1", color, errorIn,"COM1", OutputStr, errorOut, len) 2. DeclareAutoFunction LCDColor Lib"..LabVIEWdllsLCD Color.dll" (ByVal ComPortIn As Int32, ByVal color As Int16, ByRef errIn As Int32, ByVal ComPortOut As Int32, ByRef outPutStr AsString, ByRef errOut As Int32, ByRef len As Int32) As Int32 call as LCDColor(1, color, errorIn, 1, OutputStr, errorOut, len) 3.DeclareAutoFunction LCDColor Lib"..LabVIEWdllsLCD Color.dll" (ByVal ComPortIn As IntPtr, ByVal color As Int16, ByRef errIn As Int32, ByVal ComPortOut As IntPtr, ByRef outPutStr AsString, ByRef errOut As Int32, ByRef len As Int32) As Int32 call as Dim ComPort AsString = "COM3" Dim ptrCom As IntPtr = Marshal.StringToHGlobalAnsi(ComPort) LCDColor(ptrCom, color, errorIn, ptrCom, OutputStr, errorOut, len) In all cases I get the same error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. I need to have it done. Thanks for any suggestions.
  5. Thanks to all of you. It looks like you talking a case if I need to get resource name from this DLL. Actually, my VB program already knows resource name ("COM1") and should pass it to DLL. I will try to send it just as a string "COM1" and see if DLL takes it correctly. This is all I need. And ,as ShaunR mentioned, "the C pointer (asterisk) makes me tentative, however, since it could be a ByRef". So I need to verify this as well.
  6. Thanks for reply. Actually I need to find out what a real value I should pass via the parameter LVRefNum *VISAIN. Let's say If I need to tell the DLL using Com Port 1, what should be in my calling variable that DLL understands: 1 or COM1 or "COM1" or "1" or anything else ? I don't create this DLL, I don't program Labview. I only get a header file from Labiew project with calling parameters knowing that this is a variable for a Com Port. Thanks.
  7. I have tasks to call various LabView DLLs from my VB.NET application. I found the LVCalculator.dll example on NI website to call Labview DLL from VB.net. It shows how to declare the DLL and call in VB.net and Declare Auto Function Calculator Lib "..LabVIEWLVCalculator.dll" (ByVal val1 As Double, ByVal val2 As Double, ByVal Op As Integer) As Double Result.Text = Calculator(System.Double.Parse(Operand1.Text), System.Double.Parse(Operand2.Text), add) This example works fine. Unfortunately, all examples I found have parameteres with standard data type such as Integer, Double or String. However in my DLL I have a parameter LVRefNum *VISAIN and *VISAOUT . void __cdecl LCDColor(LVRefNum *VISAIN, uint16_t LCDColor2, TD1 *errorInNoError, LVRefNum *VISAOUT, char OutputString[], TD1 *errorOut, int32_t len); These parameters in my DLL are a Com Port numbers, which Labview VI uses to communicate with the controlled hardware. When this VI runs as standalone program in with Labview GUI the COM port is selected from the menu. But when I call this VI as a DLL, I need to pass my COM port number via the parameter LVRefNum *VISAIN (VISAOUT). And I could not figure out what data type and format to use to make DLL understand it.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.