06-10-2010 04:42 AM
Hi Rolfk,
Thank you for explaining reg. wrapper fn.
Please find an attachment of the VI (LabVIEW 8.5.1), in which I make the return type of the OLECreateObject() to Signed 32-bit integer.
And then I pass this returned value of OLECreateObject() to one of the parameters of OLEGetFASTVersionNumber().
The second parameter is a C String Pointer with minimum size of 300.
Have a look at it and kindly advice.
Thanking you,
Regards,
Vani
06-13-2010 11:34 PM
Dear Rolfk,
Request you to kindly find the attachment of LabVIEW code and advice accordingly. I want to confirm that the equivalent of the Pointer sized integer (Only available for LabVIEW 8.6 and above) in LabVIEW 8.5 is a Signed 32-bit integer. And I have set the Char* to String and C String Pointer of minimum size 300.
Waiting for your reply.
Regards,
S.P.Vani
06-14-2010 01:42 AM
06-14-2010 05:56 AM
Hi Rolfk,
I am sorry for I do not have the hardware set-up for testing this VI and see the output of the function. So, I wanted to re-confirm it from you. As for now when I run it, I dont seem to see any errors or crashes either. But to verify the correct output, I should have the Hardware set-up for testing it.
I hope this works and I shall post the results once I am finished done with the testing. Thank you very much. Regards,S.P.Vani
08-02-2010 06:02 AM
Dear All,
I get an error 1097 exception while trying to access the DLL.
1. typedef long __stdcall( *OLECREATEOBJECT)(char*);
typedef long __stdcall( *LOADFASTAPP)(long,char*);
static HINSTANCE Hinstlib,hinstlib;
static long gvntISystem;
long CviCreateFastObjects (void) {
OLECREATEOBJECT procAdd;
pStrTempmem = (char*)CA_AllocMemory(1);
Hinstlib = LoadLibrary("FastTrio");
if( Hinstlib != NULL){
procAdd = (OLECREATEOBJECT) GetProcAddress(Hinstlib, "OLECreateObject");
if(fRunTimeLinkSucess = (procAdd != NULL)){
gvntISystem = (procAdd)("FAST.IMFASTSystemInterface");
return 0;
}
else
return 1;
}
else
{
return 1;
}
}
LabVIEW successfully compiles the above function and returns a long value when the DLL is loaded into the memory (i.e when the vi is loaded into the memory). This function loads or invokes FAST application (Loads the FAST software application). To call this dll, one input is Cstring and the return value is signed 32-bit integer which is gvntISystem.
2. long CviFASTLoadApplication (char *cString){
LOADFASTAPP procAdd;
long status = -99;
if( Hinstlib != NULL){
procAdd = (LOADFASTAPP) GetProcAddress(Hinstlib, "OLELoadApplication");
if(fRunTimeLinkSucess = (procAdd != NULL)){
status = (procAdd)(gvntISystem,cString);//call the function
}
}
return status;
}
When I try to access this function by passing the gvntISystem as an input, I get the above exception. To access this function, I am passing the gvntISystem as signed 32-bit integer and passing as value (not pointer to value) and a CString to which an application name is given.
Pls help me.
I have got LabVIEW 2009.
Regards,
Vani
08-18-2010 03:28 AM
Hi,
Solved the error exception 1097 by changing the option "Run in any thread" to "Run in User interface thread" in the Call Library Node.
The problem is solved and I am able to access the Dll successfully. The credit goes to all of you.
I would also like to thank Rolfk, D F Gray and H Sh for guiding and assisting me all along.
With Kind Regards,
S.P.Vani
08-18-2010 03:39 AM
Hi,
Solution is in the message posted by DFGray and Rolfk: -
1. All the information you need is in the C code.
2. One recommendation (if you would use LabVIEW 8.5 or better):
Make the return value of the CreateObject function to be a pointer sized integer. As it is now you do assume 32 Bit Windows and DLL and that might bite you later on when you upgrade to a 64 Bit Windows, LabVIEw and DLL.
As to the implementation itself you make the typical LabVIEW Call Library Node starter error. The string to the second function is an output buffer. From LabVIEW you are used that it will take care to resize any string or array automatically to whatever size is needed. That does not work for DLL calls.
Did you notice the CA_AllocMemory(300) call in the CVI source code? For what might this be necessary??
Indeed it allocates a memory buffer for the function to write in the version string. LabVIEW has no way to know that this function wants a buffer to write in this information so you have to explicitedly tell LabVIEW that.
You do this with Initialize Array by creating a byte array large enough for the function parameter and then using the Byte Array To String function to turn it into the string. If you had LabVIEW 8.5 or better you could also simply configure this parameter in the Call Library Node configuration dialog to be of the desired minimum size and LabVIEW will take care about allocating that buffer automatically.
Ohh and by the way you should put a Delay function in the False case. Otherwise the loop does try to do very hard nothing and that has a rather nasty effect under LabVIEW for Windows of monopolizing the CPU almost completely.
04-19-2012 02:45 AM
Hello to everyone ,
i have problem creating a code and calling this code to Labview via DLL.
I would like to create this code in LabView:
typedef struct
{
UINT32 dwTime;
UINT32 dwMsgId;
CANMSGINFO uMsgInfo;
UINT8 abData[8];
} CANMSG, *PCANMSG;
dwTime
: [in/out] With receive messages, this field contains the relative reception time of the message in ticks. The resolution of a tick can be calculated from the fields dwClockFreq and dwTscDivisor of the structure CANCAPABILITIES in accor-dance with the following formula:
Resolution [s] = dwTscDivisor / dwClockFreq
dwMsgId
: [in/out] CAN ID of the message in Intel format (right-aligned) without RTR bit.
•
uMsgInfo: [in/out] Bit field with information on the message type. A description of the bit field is given in section 5.2.5.
•
abData: [in/out] Array for up to 8 data bytes. The number of valid data bytes is defined by the field uMsgInfo.Bits.dlc.
Can someone please advice me how can i do that?I can use the call function librabynode to do this and how?I have never done something like this and i need guidenance
04-19-2012 03:16 AM
This is not a C code but simply a structure datatype definition. As such it is most easily resembled by a LabVIEW Cluster. If you create a Cluster that has two uInt32, another SOMETHING for the CANMSGINFO, followed by 8 uInt8 then you have basically created a cluster that resembles this C struct. But this is no code, just a datatype.
04-19-2012 03:32 AM
Can you provide an example to understand what you are saying please.I must use this Vi to change the delay time between message i am receiving through the CANBus