babashari Posted July 3, 2014 Report Share Posted July 3, 2014 Hi all I new with labview & i need to take care of LV project at work, the past programmer work was to communicate with our HW during .DLL file {with defined C# function & objects}. my goal is to make this code active (the code is realy good except .dll functions that need to get pointer to struct and not intfloat etc.) I already read the topics: https://decibel.ni.com/content/docs/DOC-9091 http://lavag.org/topic/14528-call-dll/?hl=pointer#entry87090 It deals with related issue, but in this case i need to deliver pointer to struct that already contains data this data already usee by the program and the .dll need to adjust it. the dll functions doesn't return the struct value. { UINT32 BufferReadMeasurements(Measurement* measurementsArray, UINT32 offsetInBuffer, UINT32 numberOfMeasurementsToRead, DWORD timeOutMilliseconds); } in the code he sends instance of the struct with initialization to const values. but the function need to get pointer to real struct . (while i try to run it the program the stuck) 1. someone have an idea how can i do this ? 2. while i try to change VI patterns and insert more patches (want to wire it in different way) i found out that the vi i adjust is seen transparent in its appearance at block diagram, this cause errors in the code, so how can i change the vi pattern without create new errors ? thenks Quote Link to comment
ned Posted July 3, 2014 Report Share Posted July 3, 2014 How is the Measurement data type defined? If the Measurement struct is fairly simple, you can create a matching cluster in LabVIEW, fill in the values, and pass it to the DLL function. The corresponding output from the Call Library Node will have the modified values after the call to the DLL. Can you share your LabVIEW code, showing what you tried? Quote Link to comment
babashari Posted July 6, 2014 Author Report Share Posted July 6, 2014 Hi ned sorry for the latency it was weekend Attached Measurement data type definition (.pdf). The DLL input need to be pointer to array of measurements at C implementation it mean that the program reads the array and adjust it by jumping i*sizeof(One Measurement), therefore it needed to pass the exact database to the DLL and not shadow copy of the values. for example my VI 'Show probe dialog.VI' (this function is working well) the function signature has two pointers one to a data destination, second to database to manipulate. Attached pobe dialoge definition & implementation(img)- static bool ShowProbeDialog(ISmart** smartArray, int arrayLength, ProbeDialogParams* pdp, ProbeDialogResult* pdr); At Probe_Dialog.VI data pass to function and labView take care for the pointers issue but in the other case - the measurements is complex struct and i can't make the same thing- create the struct and send it to the function this attached the measurements vi. do you have idea for this??? Measurement.pdf Quote Link to comment
ned Posted July 7, 2014 Report Share Posted July 7, 2014 You can pass clusters to a DLL, with the parameter configured as Adapt to Type. The cluster will be passed by pointer, like a struct. I recommend that you try this for your Show Probe Dialog VI, since it will eliminate splitting and joining numbers. LabVIEW will handle all that for you automatically. You can likewise pass an array of clusters to the DLL using Adapt to Type. Set "Data Format" to "Array Data Pointer." You'll need to create a cluster that matches the format of the Measurement struct. This is easy if you're only using one of the members of the union. If you are using more than one member of the union, then you can either pass the data in a more generic format (for example an array of the correct number of bytes) and parse the data out later, or you can create a struct that matches one member of the union, and then reinterpret that portion of the data when dealing with other Measurement types. See snippet below. 1 Quote Link to comment
babashari Posted July 8, 2014 Author Report Share Posted July 8, 2014 (edited) Thanks!!!! i start to deal with other issue at this project & i will try this sol ASAP ... Edited July 8, 2014 by babashari Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.