Jump to content

Calorified

Members
  • Posts

    38
  • Joined

  • Last visited

Everything posted by Calorified

  1. Hey y'all. Code is fixed. I am brilliant now I'm posting the .png file in case someone in the future runs into same issue.
  2. So I have the array constant but but in LabVIEW 2014, I can't find my way into Choose Representation. or SGL. Now, I tried this and I am having floating point numbers as my output. But I notice my data is of the order 1.06607E+9 when in actual fact, it should somewhat be 1.06607. Am I missing something?
  3. Thanks. How do you change the type on the Unflatten String into Array of Single Precision?, I wired a numeric constant to it and typed 0.00f into it to indicate float and then ran the labview code but I got an "error 74 occurred at Unflatten From String in "Code UDP"
  4. I tried this before but I will try again. What do you suggest I wire to the type terminal on the Unflatten string?
  5. Here's what I am sending from the C# end. It's binary. this.facePoints3D = frame.Get3DShape(); // UDP Connection :: Talker :: Boolean done = false; Boolean exception_thrown = false; Socket sending_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPAddress send_to_address = IPAddress.Parse("172.22.11.2"); IPEndPoint sending_end_point = new IPEndPoint(send_to_address, 80); while (!done) { foreach (Vector3DF vector in facePoints3D) { //arrange float zvect = vector.Z; byte[] bytearray = BitConverter.GetBytes(zvect); Console.WriteLine("sending to address: {0} port: {1}", sending_end_point.Address, sending_end_point.Port); try { sending_socket.SendTo(bytearray, sending_end_point); } catch (Exception send_exception) { exception_thrown = true; Console.WriteLine(" Exception {0}", send_exception.Message); } if (exception_thrown == false) { Console.WriteLine("Message has been sent to the broadcast address"); } else { exception_thrown = false; Console.WriteLine("The exception indicates the message was not sent."); } } //ends foreach statement } //ends while(!done) statement I am getting something of this sort from the UDP Read function in labview when I wired an indicator to it: ƒª’? After unflatteneing, I am getting values which are inherently not corresponding (e.g. numbers like 141, 168, 200) to what I have on my console window (floats such as 1.8543, 1.115 etc). Let me know what you think.
  6. Really? Do you mind sharing the Delphi Code as well as the Labview VI?
  7. Can you show an example of this? I am receiving the data in labview but it seems I need to deconstruct the unflatten from string function is not being properly deconstructed. This is what I have:
  8. I am using udp to transfer data from a Windows PC Host to NI MyRIO. The data transfer is satisfactory by me. The challenge I have is handling the endianness between both. Is there a way to receive the data in labview in little endian or better still, translate the endianness to big endian which is what labview is based on before passing on my data? Thank you!
  9. Okay. I actually tried the UDP thing this morning. Got the C# code to send the data to the UDP Port I wanted (I used an IP address of 172.22.11.2 and Port 80 which are the default for myRIO) but since my ultimate aim is to pass on the data to myRIO, I could see data on my screen but I could not ascertain the veracity as I was getting a constant string of data. I simply used the udp receiver example that came with the base development of labview but changed the ip address and udp port numbers.
  10. I have a C# code which I have compiled as a DLL class. It basically employs a Kinect camera to track an object and then spills distance of the camera from the object to a console window. How do I retrieve the distance (given in the console window when I run the C# executable file) by calling the .NET assembly in labview. Thank you!
  11. I did the above and I still have the same error. I am officially depressed!
  12. Alrighty. Here's the C# snippet I have: int n = 121; foreach (Vector3DF[] vector in facePoints3D.GetSlices(n)) { var copier = new VectorSerializer(); //act byte[] bytearray = copier.SerializeVectors(vector); Vector3DF[] copiedVectors = copier.DeserializeVectors(bytearray); //Initialize unmanaged memory to hold array. int size = Marshal.SizeOf(bytearray[0]) * bytearray.Length; IntPtr pnt = Marshal.AllocHGlobal(size); //bool mutexCreated; // Mutex mutex = new Mutex(true, "vectmapmutex", out mutexCreated); //copy the array to unmanaged memory. Marshal.Copy(bytearray, 0, pnt, bytearray.Length); // Copy the unmanaged array back to another managed array. byte[] bytearray2 = new byte[bytearray.Length]; Marshal.Copy(pnt, bytearray2, 0, bytearray.Length); //Console.WriteLine("The array was coppied to unmanaged memory and back."); try { using (MemoryMappedFile mmf = MemoryMappedFile.CreateNew("vectmap", 1024 * 1024)) { //bool mutexCreated; //Mutex mutex = new Mutex(true, "vectmapmutex", out mutexCreated); //Copy to Memory Mapped File using (MemoryMappedViewStream mapstream = mmf.CreateViewStream()) { BinaryWriter binwriter = new BinaryWriter(mapstream); binwriter.Write(bytearray2); } // mutex.ReleaseMutex(); //mutex.WaitOne(1000); using (MemoryMappedViewStream mapstream = mmf.CreateViewStream()) { BinaryReader binreader = new BinaryReader(mapstream); //return binreader.ReadBytes((int)mapstream.Length); Console.WriteLine("vectors: {0}", binreader.ReadBoolean()); } // mutex.ReleaseMutex(); } } finally { // Free the unmanaged memory. Marshal.FreeHGlobal(pnt); } Console.WriteLine(string.Join(",", bytearray2)); // sw.WriteLine(string.Join(",", bytearray)); //sw.Flush(); stream.Position = 0; // so we can read from file beginning, set stream position to null } // close memorystream thread } // close foreach thread I tested the C# code earlier and it works fine except for the mutex part of the code which was throwing a synchronization thread exception (which I guess I have to figure out somehow later. To save the day, I have commented this out of the code for now). And in labview, I have the following: I am not at work now as I am working from home. I will deploy this when I get to the lab tomorrow morning and I better hope it works. Thanks for your help ShaunR, Rolf and every other one person that has contributed to my learning. If you think there is any modification I need to add into my code, kindly let me know. Thanks once again.
  13. Thanks. I do not need .NET on myRIO anyways. The DMA FIFO Code I showed earlier answers this part of the question. Once I can do interprocess communication from C# to labview, the Windows Host VI in the DMA FIFO Code you see at the top of the page where it's attached as a Zipped file, would move whatever data is being passed to the Windows Host VI (this exists under MY Computer Tab in the project file) to the myRIO (correct me if I am wrong). I have actually copied random data to myRIO using the Windows Host VI using the DMA FIFO Code so I feel quite positive this is possible (at least theoretically for now ). Now back to the Memory Mapped File API, I see from the example that you had to "create" then "write" to a file before the "Read" polymorphic node was invoked. Do you think your MMAp Open can open a file that is in memory? The file in memory in this case would be from my C# code. I tried to do this earlier in the afternoon but I was getting some kind of weird error that labview doesn't seem to have a clue about: " Error -80002 occurred at Unable To Open Map in MMap.lvclass:MMAP Open Map.vi" I would be glad to read from you. Once again, thank you!
  14. You are entirely right except that I have the skeleton mode disabled because I am tracking an inanimate object here; this enables the kinect sensor to be able to track objects of similar facsimile as a human being. Now, this was a ton of work in C#. In any case, I tried your suggestion on the AllFramesReadyEvent event in LabVIEW but it has no constructor. Even if it has, I would have to start putting all the code together to generate the coordinates I want from scratch. It took me a while to get here. I just need to get this done before it's too late or I am bananas.
  15. I have not done this before in C#. You have a link or example that can guide? I was trying Mapped Memory cause I felt it was the best I could do without having to write some signalling code which I am not so good at.
  16. Thanks. One thing that confuses me about the PostUserEvent is that it seems I have to generate a signalling event from within my C# code for LabVIEW. Am I right? Or do I just go ahead in labview and generate the PostLVUserEvent without signalling the communication from C#? I looked to the MSDN documentation but this is not so elegantly explained. Looking forward to reading from you.
  17. First of all, I want to thank you for this wonderful resource. You are a life-saver! Do you have some documentation on how I can use the MMap API you have shared? I am assuming I would need to raise an event handler whenever coordinates are written to the mapped file and then use the MMap API you have sent to intercept such messages. I have the whole c# code working. I've never done this in labview before. If you do not mind, I could send you my C# ode so you can best understand what I am trying to do in labview. Thanks!
  18. You have an example that can guide? I am using MappedMemoryFile method in C#, You are right,it's been a big pain working with memory allocation over the past few days. Is there some way to work around this? I executed my c# code using mapped memory functionality and I got it to map a section of memory for writing the data I want. The question is how to dereference the pointer in Labview. I could send you my code if you do not mind. I am not sure if this is entirely true. Go look through the documentation for DMA/FIFO on the labview zone pages and clear this. You don't have to go over ethernet to communicate with the myRIO either. With correct memory mapping (_http://www.abhisheksur.com/2012/02/inter-process-communication-using.html) or "Named Pipe (_http://msdn.microsoft.com/en-us/library/bb546085(v=vs.110).aspx)", or WCF Interprocess Communication (_http://tech.pro/tutorial/855/wcf-tutorial-basic-interprocess-communication), I believe communication can be bridged.
  19. Alrighty. It's been a lot of effort trying to get around this but no luck. I have setup the following attachment on my system and myRIO (_https://decibel.ni.com/content/docs/DOC-9893). I am presently using the kinect Face Tracking Basics WPF c# program to track a manikin head and extract z-coordinates which represent the distance of the camera from the manikin head. At present, I am writing this coordinates to memory using the memorystream method in c#. The problem is I want to send the z-coordinates to the fpga on myRIO using the Host to Target scope in the link above. So far, I can't figure out how to do that. Is it even possible for labview to access physical memory on my windows computer? I look forward to your replies. Thank you! DMA FIFO Code.zip
  20. Beam me up Scotty. No intelligent life down here.

  21. #AmericaInFiveWords

    Be. Number. One. Always. Forever!

  22. NB: Always compile your build spec before you run an FPGA code. 30 mins shattered. Pushing through the dark, still another mile.

×
×
  • Create New...

Important Information

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