Jump to content

koushik

Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Interests
    programming(c++,LabVIEW,C), musician.

LabVIEW Information

  • Version
    LabVIEW 2012
  • Since
    2013

koushik's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. @rolfk thanks for the reply. The code that i posted is actually what i wrote as an example that is a stripped down version of original code. the developer has given two functions in which one takes the struct by val and the other returns by val. what is did was write a sample function i.e foo which takes struct by val and returns a copy of it(explicitly malloc'ed). So i will have to deallocate it from labview.(i have written a function for this dll that deallocates it). 1) "So it's likely that the C compiler would pass it as C string pointer anyhow" the data field is not to be treated as a c-string. they are the flash memory data that has been stored in the byte array form. since as you pointed out that they are large and that they are likely to be passed as strings then it means that if i do a memcpy it will not do a deep copy right?. so the data is lost? the original dev wrote the dll in visual studio and it works there. i write a commandline and call this func it works. but labview is giving me a hard time. 2)"But the more interesting thing is that the function seems to return a pointer to that structure" The pointer that is returned is to an explicitly malloc'ed location that is done in the wrapper function. so that location should still be available for me when i return it to labview? 3) "If you don't find this worrying enough, I'm not sure there is anything that would worry you in this world!" its my 6th day tring to beat down on this one function. Btw this is the BSL430_dll from ti. currently there is only python version. i got this last year. i'm trying to adapt certain functions that are problematic to labview 4) Well I now see that it is your DLL!!!!! Forget it and change that signature immediately!!! it is my dll which i am using to debug the actual code. this is the isolated part of the code. 5) "you also provide according exported functions to the caller to deallocate those buffers" Yes i have written a function to deallocate the malloced data and yes i do use free() only. 6) The actaul dll is compiled using visual c++ compiler 2013 ed. this dll(demo.dll) that i have attached is mine for test purose the actual scenario is : the original functions: compiled in visual c++ compiler void some_func(datablock); datablock some_other_func(); my wrappers to the second(some_other_func()) is datablock* some_other_func_alt(); no wrapper to the first. but as you suggested i will change the parameter and will manage it but the return of the second is what is bothering me. to test if this is ok or not i created this demo.dll in which i use the above foo() function. i just wanted to check if labview can read and write this structs. but it is failing. sorry if this is confusing. My apologies
  2. Hello, I am trying to call a function in a DLL whose signature is as below datablock* foo(datablock db); where datablock is : typedef struct { unsigned char data[10240]; unsigned int no_of_bytes; unsigned long start; } datablock; this is actaually a wrapper for a function which return the datablock by value. Labview Import manager chokes and i have to kill labview, when i try to import this function. so i tried to call this function with call library function node and i am unable to get it to work. In the call library function i tried to pass the struct by using 1)adapt to datatype, 2) spliting the struct and passing the elements individually. The call library function returns a pointer which i tried to give it to MoveBlock and tried to move the data but i get Access violation(which leads me to think i'm trespassing labview's memory). i tried using GetVallueByPointer.xnode. This time it did not crash but it does not give proper results. from what i observer only the no_of_bytes seems to be correctly received. basically what i saw is that i can neither pass nor receive these structs by pointer ref and dereference them successfully.. One more thing is that if i try to write the struct argument in the function labview immediately crashes always. i have attached the code (demo.cpp,demo.h), dll(demo.dll), VI that reads this dll. I used gcc 4.8.1 to generate the dll and LabVIEW 2013. i have searched (http://lavag.org/forum/25-calling-external-code/?prune_day=100&sort_by=Z-A&sort_key=last_post&topicfilter=all), (http://lavag.org/topic/17100-problems-with-calling-a-dll/) (https://decibel.ni.com/content/docs/DOC-9079) i also searched labview help but am still failing to get this to work Thanks for the help in advance. Labview_cpp_dll.zip
  3. Hello, I have set up a vi in my project where it deploys startup.rtexe, web service and the related web service vi and a shared variable library to the real-time(sbRIO) target. i have 3 targets in the project 1) My computer 2) RT-Target 3) FPGA. What i want is to change the properties of the RT-Target whereby i can assign the IP address of the device to the target project properties programmatically. i can manually assign the IP address by right click on target->properties->IP address. but sometimes the IP address changes and so target cannot be reached and deployment fails. i want to be able to set the IP address through the VI and then deploy the items to the target. Please suggest a way to do this. Thank you.
  4. Hello, I have lately run into a problem of insufficient memory. Basicallly the controller is ever running and i generate data and store it in .tdms file every x sec. and every shift (3 shifts in a day) i ftp the file to the host and delete the file. During accumalation of the data the ram continuosly decreases(contiguous memory also decreases as i have a lot of array manupilations and such). I want to recover this contiguous memory at the end of the shift so that the next shift runs smoothly. this is observed because i saw lot of inconsistency in the data file. Is there a vi which will free up ram and defragment it?. I cannot use preallocated array because i dont know before hand how many data points i need to store. the data that will be put is in variable time. Thanks in advance.
×
×
  • Create New...

Important Information

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