LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transform data from queue to string to send through TCP

Solved!
Go to solution

Hello:

 

Actually I am receiving data from the FPGA and queueing.

 

I must transform all the data to string to send to the socket TCP.

 

In the first picture, we see a qeueing reading and a decimate of the data because it is 4 channel data.

The i pass this decimated arrays to a string converted subvi

block_diagram.png

This string converter subvi, takes the 4 inputs arrays and transform each individual value and attached the characters AvalueABvalueBCvalueCDvalueD

transform to string.png 

 

But it seems that the queue reading is faster than the transform to string.

 

Is it  anyway to make the transformation faster .

 

I think that i have a funnel between the transformation and the socket writing

0 Kudos
Message 1 of 5
(2,010 Views)
Solution
Accepted by topic author GuilleCad

Hi GuilleCad,

 


@GuilleCad wrote:

Is it  anyway to make the transformation faster .


Try this:

No need to decimate the whole array and to create 4 sub-arrays.

No need to multiply each individual element with its own multplication node when you can apply the scaling to your whole array.

No need to init a string array to replace all elements when you can use autoindexing.

 

Btw. do you really need this way of encoding the data? Wouldn't it be much simpler to use a standard "%.;%f,%f,%f,%f\r\n" format string to allow operations like ArrayToSpreadsheetString/SpreadsheetStringToArray?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(2,001 Views)

@GuilleCad wrote:

Is it  anyway to make the transformation faster .

Depending on the receiver, I would probably just use Flatten To String.  On the receive side, read 4 bytes (I32 for the number of elements in the array), multiply by 8 to get the number of bytes in the array (8 bytes per element), read that many bytes, and then Unflatten From String to convert back to the double array.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 5
(1,950 Views)

Thanks for the suggestion.

 

I am going to try it.

 

Probably the second suggestion that you made would be much simplier, but in the other side of the TCP connection is a python script where I have created 4 list for each encapsulated data, because each data belongs to a specific channel

0 Kudos
Message 4 of 5
(1,913 Views)

Hi GerdW

 

I have try your suggestion and it works much faster!

 

Thank you.

 

But on the other side now I have receiving some data empty or only the sign

 

GuilleCad_0-1614168295146.png

 

In the previous version I have never have this kind of error, could i assume that is because now is faster and ignore some value?

 

Should I reduce the time loop period? Now is in 10us should I execute in 100 us or 1 ms?

0 Kudos
Message 5 of 5
(1,901 Views)