Création dll sous CVI vers LabView (Callback function)
Bonjour,
J'utilise un capteur de champ magnétique dont la communication se fait sous labwindows/CVI 2012.
Ensuite je dois récupérer la valeur de champ magnétique (mesure en continu) sous labview pour ensuite la traiter.
Je pense qu'il faut utiliser une dll, en regardant dans votre forum j'ai vu comment créer des dll, sauf que les fonctions callback (dans CVI) ne sont pas transformées.
Je ne sais absolument quelles modifications apporter au programme CVI, pouvez-vous m'aider ?
Cordialement,
Fabien65
Bonjour Fabien65,
Que voulez vous dire par: La communication avec le capteur se fait sous Labwindows/CVI??
Quel système d'acquisition utilisez vous ?
Si vous avez vraiment besoin de créer une dll avec Labwindows/CVI, vous devez impérativement spécifier que vous créez une dll et non un .exe.
Voici un document qui pourrait vous être utile:
http://www.ni.com/white-paper/3341/en#toc7
Cordialement.
Aurélien Corbin
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
Cahiers de vacances de NI
Présentations en ligne : 12 fondamentaux à réviser, du 9 juillet au 29 aoû...
Similar Messages
-
Portage d'un appel de DLL en DELPHI vers LabVIEW
Bonjour,
Je suis en train de porter un programme DELPHI en LabVIEW.
Dans ce programme DELPHI, j'ai un appel de DLL (dont je n'ai pas les sources, mais vraisemblablement écrite en C), que je n'arrive pas à transposer en LabVIEW :
prototype de la fonction en DELPHI :
procedure EXAMPLE_FCT (
const PARAM_IN_1: byte;
const PARAM_IN_2: byte;
out PARAM_OUT_1: Byte_Array_T;
out PARAM_OUT_2: cardinal); cdecl;
external 'nom_dll.dll';
(Byte_Array_T est un tableau[1..200] de cardinal)
J'avais pensé parametrer le "Call library function node" de la façon suivante :
- convention d'appel C
- paramètres :
PARAM_IN_x : type numérique; constante; type de données: entier 8 bits non signé; Passer par valeur
PARAM_OUT_1 :type tableau; type de données: Entier 32 bits signé; Dimension: 1; Format du tableau: Pointeur sur les données du tableau; taille minimale : <none>
PARAM_OUT_2 : type numérique; type de données: Entier 32 bits signé; Passer par valeur
Cela ne me renvoie pas d'erreur, mais rien ne m'est retourné dans les paramètres de sortie...
Quelqu'un saurait il parametrer correctement le "Call library function node"?
Merci d'avance,
Christophemuks wrote:
Translation
function prototype in DELPHI:
proceedings EXAMPLE_FCT (
const PARAM_IN_1: byte;
const PARAM_IN_2: byte;
PARAM_OUT_1 out: Byte_Array_T;
PARAM_OUT_2 out: Cardinal); cdecl;
external 'nom_dll.dll';
(Byte_Array_T is an array [1 .. 200] of Cardinal)
I thought might set the "Call library function node" as follows:
- C calling convention
- Parameters:
PARAM_IN_x: numeric; constant data type: 8 bit unsigned integer; Pass by value
PARAM_OUT_1: array, data type: Full 32bit signed; Size: 1; Format table: Pointer to the table data, minimum size: <none>
PARAM_OUT_2: type digital data type: 32 bit signed integer; Pass by value
Christophe
French Board
First PARAM_OUT_2 needs to be passed by Reference (Pointer) as it receives a value from the function.
Second stdcall might or might not be advisable here. Not sure what Delphi uses as default but I would have guessed they would use stdcall, unless if it is for the sake of being different than Microsoft default.
Third you do need to allocate the array on the LabVIEW diagram using an Initilize Array Node. DLL Functions normally need all their parameters being provided by the caller unlike when working in LabVIEW or some more object oriented programming environments where the compiler does take care automatically about that. But when using the Call Library Node this does not apply since the shared library function calling mechanisme has no way of indicating to the caller anything in this direction, so the calling application can not take automatic measures for you.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Problème téléchargement Dll de CVi 2009 vers OS Pharlap
Bonjour,
J'ai deux application qui doivent tourner sur la cible PXI sous l'OS temps réel Pharlap. La
première fait l'acquisition de signaux logiques et analogiques via les cartes présentes
sur le châssis PXI. Le téléchargement de cette Dll vers la cible sous Pharlap fonctionne
correctement et l'application embarquée interagit bien avec l'hote.
La seconde application fait l'acquisition de signaux logiques et analogiques et
l'acquisition de trames CAN via des Dll développées en Labview/FPGA.
C'est lors du téléchargement de cette Dll avec des fonctions CAN qu'il y a un problème.
Le téléchargement s'arrête et demande une Dll qui s'appelle "Version.dll".
Je n'est trouvé nulpart la trace de Version.dll
Merci pour vos réponses
JGOBonjour,
Je ne suis pas sur qu'une DLL créée avec LabVIEW puisse être executée sur LabVIEW RT... à voir.
Pour cela je vous invite à vérfier que votre DLL est exécutable sur un système RT en regardant le lien suivant :
How Can I Verify that My DLL is Executable in LabVIEW Real-Time?
Version.dll fait partie de l'API Windows pour avoir des informations sur les versions de fichiers de DLLs ou d'exécutables, mais il est probable que ces fonctions ne soient pas implémentées dans le système RT de LabVIEW type Pharlap ou VxWorks.
Cordialement,
Da Helmut -
Comment créer une dll sous labview avec plusieurs fonctions venant du même VI et possédant un tabcontrol ?
Bonjour,
L’utilisation d’une « commande d’onglet », ou « tabcontrol », ne pose pas de problème pour la définition d’une DLL à partir d’un VI.
Selon la version de LabVIEW que vous utilisez, le processus de création de DLL sera différent.
Si vous utilisez une version antérieure à la v8, vous pouvez vous reporter à ce lien : Construire une DLL avec LabVIEW 7.0.
Sinon, vous devez enregistrer votre VI dans un projet, puis définir le connecteur de votre VI avec les paramètres d’entrées/sorties (cette opération est indépendante des différentes « commandes d’onglet » que vous avez pu implémenter).
Sélectionnez, dans le projet les « spécifications de construction » dans le projet (via un click droit), pour créer une DLL. Dans la boite de dialogue qui s’ouvre alors, à l’onglet « fichiers source », vous pouvez ajouter votre VI parmi les « VIs exportés » et configurer, en fonction des E/S câblées sur le connecteur de votre VI, les fonctions contenues dans la DLL.
J’espère que ces quelques éléments auront pu vous éclairer.
Cordialement,
Guillaume H.
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
>> NIDays 2011, le mardi 8 février au CNIT de Paris La Défense -
Appelle dll créée avec LabView 8.2 sous VB6 (Booleen)
Bonjour,
Je développe un programme sous LabView8.2 pour créer une dll qui sera appelée par VB6. Lorsque que je mets un booleen VB6 me renvoie le message d'erreur "erreur de chargement de la DLL".
Y a t il une configuration à réaliser sous VB ou LabView ?
Merci de votre aideBonjour,
Voici le programme LabView l'erreur arrive lorsque je veux sélectionner la Dll dans le menu Projet\référence de VB6
Ci joint le vi et le projet qui est simple car c'est un exemple de j'ai créé pour debuguer vu qu'avec un programme compliqué ça ne fonctionnait pas.
Merci de votre aide
Cordialement
Pièces jointes :
essai.vi 8 KB
essais.lvproj 8 KB -
Comment attaquer une DLL sous labview
bonjour,
pour le cadere d'un projet je cherche à savoir s'il est possible d'attaquer directement une DLL sous LABVIEW
cordialementMerci mehdi pour la traduction: "Appeler une fonction d'une DLL"
-
Programme sous CVI 6.0 vers CVI 7.0
Bonjour,
Je travail actuellement sur un système qui lis les capteurs puis affiche les courbes avec les valeurs.
Le programme fut développé par des étudiant à l'époque sous Labwindows CVI6.0 et les ordinateur sont sous windows 98
Seulement, ils ont fait leur époque donc on a acheté des nouveaux ordinateurs sous XP, une nouvelle carte d'acquisition la 6321
cette carte nécessite Labwindows CVI7.0, ce qui fait que le programme ne peut plus fonctionner.
Pouvez vous me dire comment je dois faire pour que mon programme qui fonctionne sous CVI 6.0 puisse fonctionner sous CVI7.0
merciBonjour,
Je pense que le problème vient plus de la version des drivers installés que du programme en lui même étant donné qu'un code fait en LabWindows/CVI 6.0 peut être édité en LabWindows/CVI 7.0.
Avez vous recompilé (édité et sauvegardé) le code en LabWindows/CVI 7.0?
Quelle est la version de DAQmx utilisé par vos étudiants (quel est le matériel qu'ils avaient utilisé?)
Cordialement
David S.| Certified LabVIEW Associate Developer
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
Journées Techniques LabVIEW 2012 : du 27 septembre au 22 novembre
2 sessions en parallèle : Débuter a... -
MIDI in using DLL callback function
I am trying to get MIDI into LV. The dll used is winmm.dll and the function midiinopen (plus others) is described here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_midiinopen.asp
The main problem is I don't know how to program the Call Library Function Node properly in order to perform the call
plus set it to start receiving callback data, being midi messages. I have tried creating and registering a User Event and
passing the Event ref to the dll's "dwCallback" and then trapping the callback in an Event Structure, but nothing happens.
I have studied the "Communicating with a Windows MIDI Device in LabVIEW" example but it gives no hint since midi out
does not require the use of callbacks.
Please advice,
StefanVedeja wrote:
I am trying to get MIDI into LV. The dll used is winmm.dll and the function midiinopen (plus others) is described here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_midiinopen.asp
The main problem is I don't know how to program the Call Library Function Node properly in order to perform the call
plus set it to start receiving callback data, being midi messages. I have tried creating and registering a User Event and
passing the Event ref to the dll's "dwCallback" and then trapping the callback in an Event Structure, but nothing happens.
Damn! Need to make this post shorter as this message
board just silently told me that it needs to be shorter than 5000 words
and ate up my lengthy repsonse with no way to get it back.
You can't configure a Call Library Node to pass a Callback function to
another function. Callback functions have been alien to LabVIEW for a
long time with good reasons and what it has now as callback function in
LabVIEw 7.1 and newer is not directly compatible with C callback
functions.
Basically as you want to get data from the callback function back into
LabVIEW there is really no way around some intermediate software layer
which in this case almost surely means your own specific wrapper DLL
written in C.
If you use LabVIEW 7.1 you could use user events but not in the way you
describe. Attached is an example of how you can use user events from
external code. Note the extra DLL you will have to write. You have to
watch out what data you pass back to the user event as it has to match
exactly the type you configured the user event for, otherwise LabVIEW
will simply crash on you.
For numerics this is quite simply and also shown in the example. For
strings you can't just pass back a C string pointer but you will have
to allocate a LabVIEW string handle with
handle = DSNewHandle(sizeof(int32) + <length of C string>)
and then copy the C string into it. For specifics about how to do this
you should refer to the External Code reference manual in your Online
Bookshelf. Similar rules apply for arrays or clusters for that matter.
If you want or need to do this for LabVIEW < 7.1 there are two
possible approaches but both are even less trivial. You could either
create a wrapper DLL that translates your callback events into LabVIEW
occurrences and for the data transfer back to LabVIEW you would have to
implement your own queing too, or you could use the Windows Message
Queue example somewhere here in the NI examples and adapt it to return
your specific data. That would solve the data queueing more or less for
you without having to worry about that.
Rolf Kalbermatter
Message Edited by rolfk on 05-22-2006 11:22 AM
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions
Attachments:
userevent.zip 27 KB -
Having trouble with this line "void (*m_callback)(_t_pciCommand *cmd);" in PciApi.h file. I have replaced it with NULL and was able to import 2 functions, PciAllocCommand and PciSendCommand. I was then able to get valid information using GetValueByPointer.VI, but crash most of the time.
typedef struct _t_pciCommand
t_pciCommandType m_command;
t_commandError m_error;
long m_gpVal;
void (*m_callback)(_t_pciCommand *cmd);
long m_param[MAX_PCI_PARAMS];
int m_state;
int m_retries;
int m_expected;
long m_origParam[MAX_PCI_PARAMS];
} t_pciCommand;
All files attached. Based on this callback funtion, I can't seem to resolve 2 functions, called PciAllocCommand and PciSendCommand.
Thanks,
John
Solved!
Go to Solution.
Attachments:
PciApiDll7.zip 630 KBThe manual is "pci_api_manual_jb.doc", The funtion I care most about is PciAllocCommand and the #1 issue I have is how to pass "m_param[0]" , "m_param[1]" and "m_param[2]" to the dll. The original h file is "PciApp(original).h" . The second issue would be if removing the callback functionality I need a VI to poll the status of "t_PciCommand "Function without writing to it.
For example, PciAllocCommand(c_baudrate, NULL, 0). How do I set baud = m_param[0]?
Also I am adding a TestApp.exe example of what I want to do in Labview, focusing on the Param1 and Param2
Attachments:
PciApiDll7.zip 630 KB
TestApp.zip 67 KB -
How to implement a callback function using LabView's Call Library Function Node?
I am trying to call a fuction from a SDK.dll library using the Call Library Function Node. The SDK was provided to
me and I do not have the source code, just the .dll and .h files.
The SdkSetPropertyEventHandler function has a callback fuction as one of its parameters. How do I implement the
callback using the CLF node? I am a good LabView programmer but this is my first time using the Call Library
Function Node. I have read all the info I can find on NI's web site and the discussion board but cannot figure
this one out. I am using LabView 8.6.
The SDK.h deacribes the function as:
// Function: SdkSetPropertyEventHandler
SdkError SDKAPI SdkSetPropertyEventHandler(
SdkCameraRef inCameraRef,
SdkPropertyEvent inEvnet,
SdkPropertyEventHandler inPropertyEventHandler,
SdkVoid* inContext );
// Description:
// Registers a callback function for receiving status
// change notification events for property states on a camera.
// Parameters:
// In: inCameraRef - Designate the camera object.
// inEvent - Designate one or all events to be supplemented.
// inPropertyEventHandler - Designate the pointer to the callback
// function for receiving property-related camera events.
// inContext - Designate application information to be passed by
// means of the callback function. Any data needed for
// your application can be passed.
// Out: None
// Returns: Any of the sdk errors.
A separate header file called SDKTypes.h contains the following data:
typedef SdkUInt32 SdkPropertyEvent;
typedef SdkUInt32 SdkPropertyID;
typedef void SdkVoid;
typedef struct __SdkObject* SdkBaseRef;
typedef SdkBaseRef SdkCameraRef;
SdkPropertyEventHandler
typedef SdkError ( SDKCALLBACK *SdkPropertyEventHandler )(
SdkPropertyEvent inEvent,
SdkPropertyID inPropertyID,
SdkUInt32 inParam,
SdkVoid * inContext );
Thanks for your help.
Alejandro
Solved!
Go to Solution.alejandroandreatta wrote:
I am trying to call a fuction from a SDK.dll library using the Call Library Function Node. The SDK was provided to
me and I do not have the source code, just the .dll and .h files.
The SdkSetPropertyEventHandler function has a callback fuction as one of its parameters. How do I implement the
callback using the CLF node? I am a good LabView programmer but this is my first time using the Call Library
Function Node. I have read all the info I can find on NI's web site and the discussion board but cannot figure
this one out. I am using LabView 8.6.
Basically you do not do that. LabVIEW does not know pointers and certainly not function pointers. What you should do instead is writing a C DLL that implements the callback and also exports a function to be called by LabVIEW that translates between the callback and a LabVIEW user event. Look for PostLVUserEvent() here on the NI site to find examples how to do that.
Rolf Kalbermatter
Message Edited by rolfk on 02-11-2009 08:00 PM
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Register a Callback function in LabVIEW
Is there any way to register a callback function in LabVIEW. For example:
I have a DLL on Win2k that run a thread. This thread is doing a certain task (it is not important what it does...) I can't predict when this task will end and I need to know when the task is over. The easy way would be to poll this DLL and ask: "Is it over? Is it over?" over and over again. No! I don't want to poll. Not because it's too easy. I want this DLL to wake me up on time.
Any idea, solutions, function that I'm not aware of, new features...
Thanks
NitrofI think I have a much better solution for you. Here is an example program that show how to set a LabVIEW occurence in a dll. Therefore when your dll is done it can set the LabVIEW occurence, meanwhile your VI is just waiting on the occurence.
More infomration on this is in the external code in LabVIEW manual Using External Code in LabVIEW
NOTE:This will ONLY work in LabVIEW 7.
Attachments:
SetOccurDll.zip 165 KB -
External Function with a Pointer to a Callback Function Inside a DLL
Hi.
I'm loading a DLL and trying to call a function with the following prototype:
Func1(HANDLE, hHandle, LPVOID (*pCallback)(UINT, UINT LPVOID), CHAR* sPath)
Now, I have no problem with the variable types, because CVI 9.0.1 recognizes all of them and I have no problem with LoadLibrary() nor with GetProcAddress().
But, how do I pass a pointer to a callback that is inside the DLL I'm trying to use.
I've tried to declare the callback like this:
LPVOID (CALLBACK Callback)(UINT iDevNo, UINT evEvent, LPVOID pData);
and call the function Func1 like this:
(Func1)(hHandle, &Callback, NULL);
but this gets me:
Undefined symbol '_Callback@12' referenced in "source.c".
Hope I can get some help.
I appreciate your time on this issue.
Regards.
Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
Solved!
Go to Solution.Hi Daniel,
First, you have to make sure that the callback function is exported by the DLL, so that the program that uses the DLL can access the function name identifier. Then, you have to make sure that you call GetProcAddress not just on Func1, but also on the exported callback function. You need to store both function address values in their respective function pointers. You then can pass the callback function pointer as an argument to the Func1 call.
It's probably cleaner if you define typedefs for all your function pointers, in the calling program:
typedef LPVOID (__stdcall *CallbackType) (UINT , UINT, LPVOID);
typedef ??? (__stdcall *Func1Type) (HANDLE, hHandle, CallbackType, CHAR*);
CallbackType CallbackPtr;
Func1Type Func1Ptr;
dllHandle = LoadLibrary ("...");
CallbackPtr = (CallbackType)GetProcAddress (dllHandle, "Callback");
Func1Ptr = (Func1Type)GetProcAddress (dllHandle, "Func1");
Func1Ptr (..., hHandle, CallbackPtr, NULL);
Boa Sorte!
Luis -
Is it possible to make .dll file of .vi project then load it to CVI and use the APIs in the dll to CVI project?
Hi Kumar,
It is possible to make .dll from Labview and i think we can call the same from other programming application also.
Pls refer the
below link
http://zone.ni.com/devzone/cda/tut/p/id/4038
GAnesan KAni -
Teststand cvi probleme de callback
Bonjour,
J'utilise TestStand(2013) en mode Batch parallel et mon interface utilisateur est gérée par CVI(2012).
Quand j'ai besoin d'informations provenant de l'utilisateur, Teststand appel une de mes DLL CVI.
Au debut de ma sequence (dans le model option) Je viens demander plusieurs informations à l'utilisateur et les échange entre teststand et cvi se passent très bien.
Lorsque mes socket sont créés j'arrive bien à mettre à jour mon interface graphique via CVI, mais mes Callback ne fonctionne plus.
Par exemple je souhaite seulement attendre l'appui par l'utilisateur sur un bouton de commande.
J'utilise donc le RunUserInterface dans ma fonction, que ma callback vient acquitter lors de l'appui sur le bouton.
Le problème est que l'appui sur le bouton ne fonctionne pas. Cela ressemble un peu à un problème de gestion des événements.
Une chose étrange est que lorsque je passe en mode debug sur CVI, ma callback fonctionne correctement.
Je voudrai savoir si quelqu'un a déjà rencontré cette situation ou si quelqu'un à une idée?Bonjour,
avez-vous déjà essayé ceci ?
Error Code 145 - ActiveX Control Not Registered in LabWindows/CVI
http://digital.ni.com/public.nsf/allkb/9894BE2B832B7FDE86256ECD00041172?OpenDocument
Aurelie -
I have some C code that was developed using LabWindows/CVI and is controlled with TestStand 3.1. We also have some new development that we want to begin soon. Both efforts are do a great deal of communiction with hardware and test equipment. We'd like to use LabView on the new development. My questions...
1) What types of issues should we expect to encounter if we try to convert the CVI / TestStand effort to LabView.
2) Does it make sense to do this, or should the CVI tests (currently in a DLL) remain and should the new tests be written in LabView (RealTime) and all tests coordinated through TestStand.The only way to convert CVI to LabVIEW is to use Tools>Instrumentation>Import CVI Instrument Driver. However, all this does is put a LabVIEW wrapper around the CVI DLL so the conversion will gain you nothing. The only real conversion is to completely rewrite your CVI functions in LabVIEW. I freely mix and match TestStand steps types with no problems. Some are CVI DLLs, C++ DLLs, LabVIEW DLLs, and some are LabVIEW VIs. I'd focus on the new development.
Maybe you are looking for
-
Error in UWL while opening workitem
Hi All, I have implemented a ESS package, have 2 standard workflows Claims and Leave. I am getting error in UWL while opening workitem (advance claim) in inbox, error is as below: Service cannot be reached What has happened? URL http://stest.hapl.com
-
IMac external hhd does not open on networked windows 8.1 pc
Hi there I hav a 2008 iMac with OS 10.10 and it has three external HHD that are networked to my windows pc. I can see the icons on my pc but when I click on a drive it will not open. In fact it can crash windows explorer and pc has trouble turning
-
After setting Firefox as my home page how do I get Firefox to open my AOL E-mail? in English
Under Firefox's "How to set home page" it states "you can set the Firefox home button to open your e-mail" How do you do this?
-
Firefox is stuck in Offline Mode-How do I get it in Online Mode
I upgraded to Firefox 4 and cannot get any online pages. I am told to uncheck the Work Offline menu item. Where is this menu?
-
Internal table modification in ABAP object event
Hi Gurus I have an internal table displayed using ALV - OOPS concept. THe internal table has 15 rows in my test program but it can go up depending on user inpout. I am able to display it . on the screen . One of the fields is editable . It is require