Jump to content

Neon_Light

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by Neon_Light

  1. Thank you Shaun for the reply πŸ™‚ Today the best of the day is gone, I hope I will have time soon to give it a try.
  2. Hello Rolf, thanks again for the great help! It's kind off busy here so I was not able to reply earlier.. Well I am in a bit of luck this time I did find some documentation and the compiler used is "MSVC2019". It is written in C++ and it: "exports a pure C interface", I like the word pure as it reminds me of clean air, oceans without plastic and being young, in this context however I can not really understand what is meant. maybe you can give a global idea? If I read this text I think it might be wise to turn error handling off? At this time I did set it at maximum, hoping to get some information about things that might went wrong. Thank you for the remark, In the real code I do check if the handle is not 0 if it is zero I return a error code to Labview. If the pointer is 0 I also return a error code to Labview Thank you for the remark. I need to read this remark again when it is not too late, my energy level is kind of low now at the end of the day. I will try to find the example I started with to go with your remark. I think I understand what you write. The dll I wrap in my own dll uses a callback to send error and status massages. I can see them in Labview now πŸ™‚ . I think however it is better to use this info in the C code eventually e.g automatic stop logging when there is an error related to the logging. I need to find out the best way to do this though. And even if I can use the error and status messages it would be really helpful if there is something going horrible wrong with the dll, something I did not think about, the dll will not be able to make Labview crash, I rather would have a message telling something like: "Unknown error at dll, program halted.." , better to have a ugly way of telling something went wrong than a crash-ing way which closes down Labview. If this would be possible please let me know. Maybe I can at least use some kind of exception handling when loading / running the functions of the dll I try to wrap? Thanx for the help!
  3. Hello all, background A while ago I wrote a dll wrapper to get data from dedicated test-hardware. For this hardware there is a dll available. To use this dll you need to use an callback function. If you need to use a dll in Labview which needs a callback you need to write the callback in C code and use a Labview C lib to get the data into Labview, basically my dll takes care of this problem . Enhance the code and way of working more efficient The code I wrote code works fine. However I did not use / test it for hours on a row. And sometimes If I make a mistake when changing the code I run into problems. I was able to fix all the errors and problems however it was not the most efficient way of working. For instance If there is a serious error in the code the dll I need for the hardware can crash, it can make my wrapper crash, which will in return make Labview crash. This makes the way of coding inefficiΓ«nt and it will not enable me to read my C++ book etc etc. Example pseudo code I did try to extract some main points of intrest from the code, I did add some comment in the code. I hope someone can give me some general guideline or advice what to read. At this time I am reading: Unhandled C++ exceptions I think I might be able to use it, I did not use this before so advice would be welcome. Thank you all for the help ! // .. // This is a part of the code only intended to have a talk about how to catch errors // It is not complete and intended as Pseudo code // .. int __stdcall MyDriverLoads(const int NumberToInitialise,const bool enableAnotherOption , const char *const path , LVUserEventRef *rwer) { // loads the dll // Q -- I can check if (F_functionname !=0), if it is not 0 then I can proceed if the function returns 0 I can return an error to Labview Extern_dll = Load_Extern_dll(); // Get the functions I need from the dll p2_ExternDriver F_ExternDriver = (p2_ExternDriver)GetProcAddress(Extern_dll, "_ExternDriver"); p2_Initialise F_Initialise = (p2_Initialise)GetProcAddress(Extern_dll, "_Initialise"); p2_AdapterCount F_AdapterCount = (p2_AdapterCount)GetProcAddress(Extern_dll, "_AdapterCount"); p2_StartLogging F_StartLogging = (p2_StartLogging)GetProcAddress(Extern_dll, "_StartLogging"); p2_StopLogging F_StopLogging = (p2_StopLogging)GetProcAddress(Extern_dll, "_StopLogging"); // When there are adapters found I tell it in Labview adapterCount = F_AdapterCount(); // Get the callback function adress, if adress == 0 I can see something is wrong void(__stdcall *p2_CallbackFunction_t) (pt2Obj , const LogData & ) = &CallbackFunction; // Q -- I could use try {} and catch {} however I do not have acces to the source code of the dll so, // I do not know if they used // trow "The Blue error" , or // trow "The Red error" ret = F_ExternDriver(adapterCount, enableLogFile, path, *p2_CallbackFunction_t, pt2Obj); // This tels the dll to start logging before this command you will not receive data in Labview ret F_StartLogging(1,2,3); // Labview is receiving data thats great !!! return ret; // Q -- Labview has been receiving data for a hour what happens if the used extern dll crashes ?? // If the dll crashes when return is passed I can not use try() and catch anymore. // } extern void __stdcall CallbackFunction(pt2Obj , const LogData & ) { // There is a lot to do here // do stuff!! // I did not write everything here err = PostLVUserEvent(*event_ref, &tmpEvent); }
  4. Hello RolfK, Thank you again for the great help. The terminology is not completely clear to me. Although the 9074 does not run Linux but VxWorks, I try to make a quick compare between Linux to make it easier to understand for me. In this screen from MAX I did click next and did install the recommended software. Is this what you mean with "the base system"? This is the same in linux as apt-get upgrade? I did not update the BIOS with the button on the left. Updating the bios would be going from Ubuntu 20 to Ubuntu 22? Do I need to do a BIOS update to install and test the new version of RT Main ?
  5. Hello I try to compile a FPGA clicking the right mouse button on Build specifications -> click the Test FPGA --> build. It starts. But it ends with this window: then in the compile status I can click details, which shows me: I did use windows search to find the first file in the list. I can find it. I did try build and rebuild they both result in the same error I did clear compiled object cache did not help also added the directory at options --> Paths which did also not work I am using Labview 2018, the project was previous build in Labview 2017 which is not available anymore. The cRIO type is a 9074 Hope someone can help me! thank you all Eddit: I did previously use version 2019 of Labview this version worked fine. I did find this link: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P9KGSA0&l=nl-NL I did try to run the "FPGA Compile Worker" it did not start so I did go to the directory where the exe file is located. In This directory I can also find a file with the name: ".NI.LV.FPGA.2019.CompileWorker.lock" This makes me think there is some software left behind from the 2019 version causing a conflict. Can I remove the LOCK file without serious consequences ?
  6. Hello all, At work there is an Old 9074 which is running test software. There is also a 9148 connected to the 9074. I did change the old software tested it in simulation in simulation it works fine. What I already did do: I got RAD working, so I can restore the old software I did install the packages needed for Labview 2018 I did find I can use MAX to install new software clicking the cRIO --> software --> add remove software gives me the option to install Labview 2018 recommended packages I did this it removed some files and added a lot of new files Now I do need to deploy the new RT main to the cRIO there are a lot of actions I do need to perform. Can someone please tell me the basic steps I need to take to deploy the new software and test it on the real hardware? Is it as simple as hitting the run button or do I need to stop the old RT main first? Is action 3 above enough or did I had to remove old software? hope someone can give me an overview, thanx !
  7. This might be a little bit of-topic but I think you also use Matlab code in Labview? I see a lot of files with the name Mathscript is this the software needed to use Matlab ? or is it something completely different ?
  8. Hey ShaunR, most of it did work, the only thing the install complained about was: "Install National Instruments Device Drivers Now?" Are these also on one of the files you linked to? Or do I need to download them seperately? Thanx for the help ! Now I am happy again I hope I can build some nice things and convince my managers etc. to buy a new license ...
  9. Hello hope you can help, (did edit this text to make it better to understand) Normal testcode (If I have more time I can try to include this code) I try to simulate the real time main in a cRIO test project. All goes well I can run the real time main on "my computer" target and use the FPGA in simulation mode without the use of real hardware. when I add an extra loop to the real time main with new shared variables which are not used in the simulated FPGA, I can not deploy anymore. In that case I can only deploy when I use the option disable auto deploy variables (right mouse on RT compact RIO target) and make the variables absolute (right mouse on the variable in the blockdiagram code). but when I run with this option I get an error -1950679035 when I want to use the shared variables which are *not* used in the FPGA. I Use a desktop execution node to change data on the simulated FPGA this works fine. Smaller code without the FPGA I made the code smaller and easier to understand to have focus on the shared network variables, this code is included below . There is a screenshot and the real code. When I use the small program and try to load the *non* FPGA shared variables, I get the same error -1950679035. when I only use the shared variables which are previous used in the FPGA vi and remove the non FPGA shared variables all is okay, I can also see the FPGA variables in the in the Ni Distributed system manager. Although the other program simulating the total cRIO code with FPGA has long been stopped. What I want is to open a library with a link to the file e.g.: C : \folder with *.vlib . But I am unable to open a direct link to the harddrive e.g.: C:\Users\noob\Documents\labview projects\cRIO\My Control Application\Shared Variables\Noob Shared Lib.lvlib I get the error -1950679035 again. I only do not get errors when I try to acces network shared variables I did previous use in the test with the FPGA simulation and where where used in the FPGA code. I think the desktop execution node only adds shared network variables from the FPGA code to the Ni variable server and does not do this for the shared network variables in the Real time main code. I am able to see the old FPGA shared network variables when I use the NI Distributed System Manager which can be found at the tools menu. I think I must load a variable library into the server before I can acces it with the code below is this correct? Can anyone point me in the correct direction to do this? hope you guys can help and I hope this text is easier to understand compared to the text I wrote last night πŸ™‚ at nights it tends to be late and my texts show that. If the question is not clear please let me know then I will try to solve it. Hope you guys can help thanx! Enable Debug modus.vi
  10. I think they are willing but hard to convince, its like chicken egg, chicken egg, chicken egg. etc and then they go like lets have carrots we understand that! What I mean is you need a team to build up knowledge and experience. That costs money like a few licenses. When they, the managers can see what can be done with it then they are willing to pay. That is the same as with software as Altium, Matlab, other CAD software, etc If I cant get the software working I am certain the chicken or egg will die.
  11. OW well I have got until 23:59 to use this license ... hope I can install the other 2018 after that. I know some big companies have got volume licenses would be happy if my work had one of those. that would be a relaxing thought. They are relative cheap compared to the licenses which only enable a few to people to work with. but then you need 5 or more employee's who use Labview I think.
  12. Can you even get a maintenance support contract on old versions? Or can you only get it on the new versions where you need to pay every year?
  13. Thanx, I did already download the files. Hope they work. So these files are the same as on the DVD? Or the ones you can get with a package manager? Any tips for keeping the old Labview install (which is a newer version) undamaged? thanx again
  14. Hello Rolf, I am afraid this time I have to disagree. Agree Dont get me wrong I think it is okay to pay for Labview, I really "value" the software. I did work with other testsoftware and although it is the price was lower or even free, the time needed to get to a working test-setup without bugs etc. made it more expensive. Thats only the price and with Labview you can do so much more than other testsoftware etc etc. So Yes I see there is a price tag and I think it is justified. Dont agree Now for the parts I do not agree with. Some testmachines can be complex expensive, much much much more expensive than the Labview license. These machines need to be reliable. They are used a lot and you can not simply change your software when you want to. For machines like this I would rather use the Old Labview version thats already running on the machine and use a new version when the total machine is being replaced. The decision what version to use should be up to the company who did build the machine and did buy the license. Not up to NI. If I take a look at the Ni website they are simply making it hard for you to download an old version. They should not do this. Introducing risk in expensive equipment is not wanted. Dont get me wrong I rather build new setups but a lot of times it is not wanted. And Yes I know you could ask cash for install files etc of old versions, but would this make my manager happy when I need to spend extra time on that? Will my manager be extra willing to pay for a new license when I need to spend a lot of time on ridicule subjects like this? Think not. If you add that a lot of managers simply are not able to understand advantages of a good product as Labview. Then you can get to the sum where the manager tells to quit using Labview. Sorry to say but what I write it is realistic. btw the last time I did install MS windows on a laptop I did not even need a license key. It was already in the EEprom of the laptop. To be clear, I understand you need to pay for capable software and support, but downloading a old version you already paid for? This time I think the sales and marketing department of Ni dont get the point of selling software. And yes I understand installing old software can be annoying but if I dont pay for it is not up to Ni.
  15. Hello Sam, Did you manage to solve your problem? I aks because I am running into the same problem. Have got a valid serial number but .... one DVD is missing Same software etc. If you managed to solve the problem can you please tell me how you did solve it? hope you can help, thanx !
  16. So I can give the adres of handle to testDataBlock.dataRecords, like this: size_t len = offsetof(DataArrayRec, elms) + size * sizeof(DataRecord) if (!handle) { handle = DSNewHandle(len); // testDataBlock.dataRecords = Null testDataBlock.dataRecords = & handle // testDataBlock.dataRecords != Null if (!handle) err = mFullErr; } else { err = DSSetHandleSize(handle, len); // do I need to repeat this: // testDataBlock.dataRecords = & handle // or does the adres not change ? } and thats it ? when I try the code above I get: a value of type "DataArrayHdl*" cannot be assigned to an antity of type "DataArrayHdl" in the line: testDataBlock.DataRecords = &handle; Can anyone tell me what I might be doing wrong ? thanx !!
  17. Hello Rolf thank you for your patience, I did copy a piece of your code and added some comment, can you please check if I am correct? static MgErr PostDataMessage(LVUserEventRef rwer, int32_t adapterNr, DataRecord *dataPtr, int32_t numElements) { // when you create the variable "testDataBlock" everything in the block is made 0 with the use of {0} // dataRecords points to a memory location which has got an unknow size. At this time the pointer is a Null pointer maybe ? DataBlock testDataBlock = {0}; // Here you use the function "NumericArrayResize" to resize the memorylocation dataRecords points to, MgErr err = NumericArrayResize(uL, 1, (UHandle*)&testDataBlock.dataRecords, 2 * numElements); if (!err) { testDataBlock.adapterNr = adapterNr; // Here you use MoveBlock to Move the data from the source location where dataPtr points, to the // correct location of testDataBlock. You use the (*(..)) because if you would have used // *testDataBlock.dataRecords->elms you did point at the beginning of testDataBlock and not to the begining of elms MoveBlock(dataPtr, (*(testDataBlock.dataRecords))->elms, numElements * sizof(DataRecord)); (*(testDataBlock.dataRecords))->dimSize = numElements; err = PostLVUserEvent(rwer, &testDataBlock); // (this was your comment): PostLVUserEvent does a deep copy so we need to deallocate this handle to avoid a memory leak DSDisposeHandle(testDataBlock.dataRecords); } return err; I hope I start to understand what's going on, then it is easier to remember. How do I change the code when I want to change the array from int int, to int double? Can I use this piece of code you gave earlier: if (!handle) { handle = DSNewHandle(sizeof(DataArrayRec) * (size - 1)); if (!handle) err = mFullErr; } else { err = DSSetHandleSize(handle, sizeof(DataArrayRec) * (size - 1)); } and change the adres where to testDataBlock.dataRecords points ? the handle is it easy to explain whats done here is it that the Labview functions add some extra bytes to make every variable the same size e.g. when I have char and a int they ad 3 chars for the char to make the size the same as a int or is there more going on? thank you for the help you are great !!
  18. Yes! its not 36C anymore!! There is even a cold wind blowing in my room !! From what I read I am not allowed to use C memory functions, but there is a Labview function called MoveBlock: void MoveBlock(ps, pd, size); ps UPtr Pointer to source. pd UPtr Pointer to destination. size int32 Number of bytes you want to move. When I take a look here to see how it is used: https://lavag.org/topic/23177-send-cluster-struct-from-dll-with-a-couple-of-ints-and-a-string-of-text-to-labview/#comment-150817 I see it is used here: { MoveBlock(stringData, LStrBuf(**lvStringHandle), len); LStrLen(**lvStringHandle) = (int32_t)len; } The pdf "Using External Code in Labview " shows: uChar *LStrBuf(s); Returns the address of the string data of a long Pascal string, that is, the address of s->str. So do I need to do something like: Datablock testDataBlock; testDataBlock.adapterNr = 1; MoveBlock(*handle, testDataBlock->elms, len); I'll give it a try, am I going in the correct direction?
  19. Thanks but how do I get the data in? I get confused because there is another level added by "testStructArray" (And it is 36 C in my room now and I am melting ) TD1 testStructArray; testStructArray.AdapterNr = 1; // give te adapter a number (*handle)->elm[i].status = status[i]; // in the example above this was used to fill the array elements // what must I do now to get the data in? The "testStructArray" made it a level deeper thanx
  20. Hello Rolf, thanx !! Yesterday it was late and I was behaving stupidly, I should stop sooner. I did connect the cluster to a create user event and that one to a Reg event and that one to a function node. I should have connected the cluster directly to the function node that creates the correct C file I think. /* Call Library source file */ #include "extcode.h" /* lv_prolog.h and lv_epilog.h set up the correct alignment for LabVIEW data. */ #include "lv_prolog.h" /* Typedefs */ typedef struct { int32_t Status; int32_t Value; } TD3; typedef struct { int32_t dimSize; TD3 elt[1]; } TD2; typedef TD2 **TD2Hdl; typedef struct { TD2Hdl DataRecord; int32_t AdapterNr; } TD1; #include "lv_epilog.h" void funcName(TD1 *TestInput); void funcName(TD1 *TestInput) { /* Insert code here */ This makes sense If I look at it. Thanx again πŸ™‚
  21. Hello Rolf, thanx for all the help you give, This start working fine now!! It has been a great learning experience for me ! (1) The next question might be kind of silly but how do I change the 1D array to a 2D array ? (2)With one adapter everything seems to work out okay! Now I got the question to make it work for multiple adapters. I can receive the data in my wrapper from multiple adapters. So the question is: How can I put the 1D array in a cluster with another int to indicate which adapter the array comes from? Ho do I change the C code so Labview can receive something like this: Thanx !!
  22. I am afraid you are correct, the C I did was low level ANSI... I bought a book to learn C++, but I am afraid to have landed in a chicken egg situation: I really want to finish this project so I can start with the book but I am losing a lot of time finishing this project because the lack of knowledge. I can copy and understand parts from the internet, but without the overview which a book can give ... ow well I think you get the point. Anyway your answer helps me a lot I hope I can start reading the book soon. Is my assumption correct that: I only need a handle if the size of the data is unknown e.g. the struct with a unknown string size? But when I do something like this: typedef struct { int firstInt; int secondInt; int thirdInt // The string is gone !! Now I know it is 3 x int = 12 bytes }structSample; .. Then I do not need a handle? Thanx again Rolf!! Your help is great!
  23. Hello to you all, Sending a cluster with int's I did manage to send an array with clusters from a dll to Labview. Thank you all for the help. You can find the link here: https://lavag.org/topic/22877-can-someone-help-me-with-an-example-for-an-existing-wrapper-dll-which-uses-function-pointer-with-callback-function/#comment-147496 It works fine I am very pleased with it. πŸ˜ƒ Sending a text string I did got a example here: https://forums.ni.com/t5/Example-Code/Posting-Events-to-a-LabVIEW-Event-Structure-From-a-Dll/ta-p/3996283 Tested it and it works fine. Again I am happy πŸ˜ƒ Sending a cluster with int's AND a string Now I want to send a cluster / struct with a couple of int's AND a string of text. I Got a example of how to send text from a C / C++ wrapper to Labview, can someone please help me out? The thing I do not get is, how to combine the both examples. Is "sizeof(structSample)" valid with a LStrHandle in it? How do I copy the data from the string to the struct, etc. Can someone change the code example or help me with the example so it works? I did add some text to the example code to make it more clear I added +++ signs in my comment in the code. Hope someone can help me. Thanx ! // LVUserEvent.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" #include <stdio.h> #include "LVUserEvent.h" #define STRING_LENGHT 256 //Can be any size // ++++ I want to send this Cluster/Struct to Labview typedef struct { int firstInt; int secondInt; int thirdInt // +++++ I try to add this, Gues this will not work .. see extcode.h LStrHandle textString[TEXT_STRING_SIZE]; }structSample; typedef struct{ int32_t size; structSample elm[1]; }totalstructSample, **structHdl LVUSEREVENT_API void SendEvent(LVUserEventRef *rwer) { LStrHandle newStringHandle; //Allocate memory for a LabVIEW string handle using LabVIEW's //memory manager functions. newStringHandle=(LStrHandle)DSNewHandle(sizeof(int32)+STRING_LENGHT*sizeof(uChar)); // +++++ OW no another one ... structHdl = (eventHdl)DSNewHandle(sizeof(totalstructSample)); Sleep(2000); PopulateStringHandle(newStringHandle,"+++ Dear int I don't want you in my PostLVUserEvent"); //Post event to Event structure. Refer to "Using External Code //with LabVIEW manual for information about this function. PostLVUserEvent(*rwer,(void *)&newStringHandle); return; } void PopulateStringHandle(LStrHandle lvStringHandle,char* stringData) { //Empties the buffer memset(LStrBuf(*lvStringHandle),'\0',STRING_LENGHT); //Fills the string buffer with stringData sprintf((char*)LStrBuf(*lvStringHandle),"%s",stringData); //Informs the LabVIEW string handle about the size of the size LStrLen(*lvStringHandle)=strlen(stringData); return; }
×
×
  • Create New...

Important Information

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