Jump to content

Neon_Light

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by Neon_Light

  1. Hello Rolf, thank you, you were completely correct. The label was missing. I did spent a lot of evenings coding and most of it seems to work. To setup the IDE I did use this site it describes how to setup the C environment in VSC and tips how to debug the DLL software. https://gitlab.com/serenial/talks/11-20-labview-and-vscode-shared-libraries I did also try to get rid of the array changing this code: typedef struct { int32_t status; double value; } DataRecord; into typedef struct { int32_t status; double value; } DataRecord, *dataHdl; ...... ...... dataHdl handle = NULL; the rest of the code I did keep the same. This does not work. How can I send one cluster back at a time? Does the handle always need a size even when the size is one cluster / struct? The reason I ask is because the size of the array is different every call, I did find out when using a debug window as described in the link above. Another question I have is how to transport the Labview LVUserEventRef data to the callback function? Is the part below legal? LVUserEventRef giveReftoCallback; FuncCalledFromLabviw(LVUserEventRef *rwer,int bla) { .... giveReftoCallback = rwer; ..... } void __stcall MyCallback(....) { .... err = PostLVUserEvent(giveReftoCallback, &handle); } You also did write: Yes the callback function will be called ever time there is new measurement data. So I there is a change the callback function is still sending data to Labview when it is called for new data. Is there a easy way to fix this? thank you for the help!!
  2. Thank you Rolf !! but the thing I can still not find is how do I get acces to the array in the event structure. If I wire a number for example index to the create user event it ends up in the event structure. Wile the callback array does not appear. I added a screenshot, hope that helps.
  3. Hello I did give it a try I am able to compile some C code send some data to the created DLL and receive data from the DLL. So that is great 🙂 thanks ! The original DLL however will return a array with structs to my C DLL I will try to implement thePostLVUserEvent part there . When I try to make an even structure as an experiment I am not able to get the array out again. This makes me think I am not using the event method in the correct way. what will be the best way to get an array from the DLL back to the Labview event? Do I need to send every array element back with a PostLVUserEvent?
  4. Hello ShaunR, thank you for the answer. I have to admit it was not the answer I hoped for as this will take more time, on the other side learning new things is always a great thing 🙂 . I did read this forum: And I think for me the most important points are: Although the document is old I can use most parts of: "Using External Code in LabVIEW". The link to the Ni site contains more recent info: https://www.ni.com/docs/en-US/bundle/labview/page/lvhelp/labview_help.html One part which is outdated of the external code document is how to set up the environment in the IDE. At this time I am using VSC, as a IDE. Do you have a link to a VSC setup to develop a DLL for Labview?
  5. Hello Rolf and ShaunR, Thank you for the help! I do not have the source code of the wrapper but they included 2 files a Typedefs.h and a interface.h The: Int LOGEXPORT __sdcall LOG_StartLogging{const char ** logFilename, ptLogCallbackfunction ptFunction, ptObject ptObject} is implemented in the dll and I can call it with a CLFN, first I tried to wire the output of a Register For Events function to the "ptLogCallbackfunction" as I understood this would provide a function-pointer to a Labview function/vi which would then behave as a callback function. It makes Labview crash though. When the driver is not running it returns a error message. I think the function does not try to use the callback pointer when the driver is not running. My communication might not be completely correct as I am new to callback functions. Maybe this helps, above example text: Void __stdcall callbackLog(ptObject object, const int ArraySize, const StructLogdata *const logDataArray) there is also the text: typedef Void( __stdcall *callbackLogFunction)(ptObject object, const int ArraySize, const StructLogdata *const logDataArray) I can give it a try, but how do I approach this? I can also try to code it in C, think it is interesting and fun but it has been a while since I did code C. Although I planned to refresh my C knowledge, this would take time and focus on one thing to learn at a time might be more successful. It is late now, I will read trough the examples and Using External code pdf tomorrow. Thank you for the help you provided!
  6. Well the header file I mention is from the wrapper someone else wrote. I have got some functions working from this wrapper. The only part I havent managed to get working is the part with the callback. So what you are saying I need a wrapper to use this wrapper because it uses a callback function? I will read the example you did provide thank you!
  7. Hello I hope someone can help me, I have been trying to get this to work for days but no success yet. What I want to do I got a dll with a wrapper, this dll and wrapper can be used for a special datalogger. The wrapper contains multiple functions, I have got some of them working using a CLFN, for instance I can read a jumper setting from the datalogger in LabView. So far everything is fine. Of course I am not that interested in the jumper setting, I would rather use the datalogger to log data. I need to run one function to start logging. When there is enough data in the databuffer of the driver dll it will call a callback function I need to write in Labview, here is the function which starts the logging as described in the header file: Int LOGEXPORT __sdcall LOG_StartLogging{const char ** logFilename, ptLogCallbackfunction ptFunction, ptObject ptObject} logFilename needs to be a NULL pointer, from my understanding I do not need to do anything with it. Only provide it. If I do not do anything with it some data is saved at a default location. ptLogCallbackfunction, as far as I know I need to provide a pointer to the callback function ptObject ptObject, this must be a void pointer The header also provided how the callback function could look like in 😄 Void __stdcall callbackLog(ptObject object, const int ArraySize, const StructLogdata *const logDataArray) { // copy data from logDataArray for use in my code } StructLogdata is a struct with different datatypes. What I did try I did a search on internet there are some examples about callback functions, most of them point to NET and active X. They use a reg Event Callback. I did read the helpfile at the end of the helpfile there is the text: “Use the Event structure or the Register For Events function to register and handle non-.NET or non-ActiveX events dynamically” I am having a hard time to find a proper example. I did find this site with some information: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P8XJSA0&l=nl-NL and this one about the refnum: https://forums.ni.com/t5/LabVIEW/Passing-Event-Refnum-to-Call-Library-Function/td-p/4107748 So I did make a user event, I wired a static Vi ref containing a callback vi to the input of this user event. I did wire the user event to a Reg event and wired the event registration refnum to the start logging dll call library function node function pointer input and also to an event structure. I did place a counter in the event structure. But nothing happens besides for an exception which makes Labview crash. The parameters I did use in the call library function are: logFilename: type numeric, datatype: Signed Pointer-sized int Pass: pointer to value ptLogCallbackfunction: type: adapt to type, Data format handles by value (tried all options) ptObject: same as logFilename I did try a lot of different things. Writing them in this post will result in chaos and I don’t want that. I hope someone can help me with a simple example how to make this work, or point me into the correct direction. Thank you all for the help!
×
×
  • Create New...

Important Information

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