From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-02-2010 04:45 AM
Here's my take on how to do this. The attached example just deals with LabVIEW vi sending a single double, C# program receives it, adds 1 to it and sends it back to LabVIEW vi. It seems the key issue is how to get C# to do the conversion. Being an old C hacker - it seems to me that this isn't that easy in C#. That may be the reason why there is a standard library function called BitConverter which can do this for you. BitConverter.ToDouble can take an array of bytes and return the equivalent double and BitConverter.GetBytes does the reverse. I've attached a simple example (vi and C#) to show this. Extending this to arrays of doubles is relatively simple. The BitConverter.ToDouble function has a convenient argument to specify the starting index in the byte array. So in the C#, get the size of the array of bytes, divide this by 8, then with a for loop step through the array of bytes incrementing the start index by 8 each time.
12-02-2010 07:41 AM
Thank you to both of you for your help, we now have the comms working. Very much appreciated.
02-16-2012 06:18 AM
Hello.. I am also trying to send large data from cRIO to C#. I have attached the code.
I have 20 chanels (can be more) and 100 sample each chanel (getting those datas from FPGA FIFO). So I need to send 2000 x 8 = 16000 byte. Since it is not possible to send this in 1 packet, I have splitted it to 100*8=800bytes and send each in a while loop.
I have 2 main loops:
First one for write to RT FIFO from FPGA FIFO
Second for read from RT FIFO and write to TCP
And 1 loop in second loop. It is for sending splitted 20 data (each 800 byte) to TCP untill complete 16000byte.
So the second loop rate (5ms) must be less than first loop (10ms) to not loss any data.
I tried to do but I cannot be sure if it work good. I see "RT FIFO Write Timed Out" led always true even I set the loop rate of second loop to 5ms.
I am not sure if I can send 20 packet in 5ms from TCP. (I add "Wait" 50ms to check something, I also tried without it and I saw the 5ms loop rate from tick count of second loop).
How can I do it without losing any data?
Thanks in advance.
02-16-2012 07:00 AM
Ok I figured it out.. it is probably because I didn't read data from C sharp part fast enough... 😄