LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP with "unflatten from string" function : error 116

Hi there !

 

I have a big problem with my application (executable created from LV 2011). I use an RT target (sbRIO-9612) and an eeePC.

 

RT code : data are acquired, they are flattened to string, and then they are sent to eeePC by TCP (I use STM library for TCP communication)

eeePC code : data are received and then they are unflattened from string

 

The problem is that after 6 hours of data acquisition, I got an error 116 generated by unflatten from string function : "Unflatten or byte stream read operation failed due to corrupt, unexpected, or truncated data."

 

Please see screenshot attached...

 

I plan to launch another test with a false constant wired to the input "data includes array or string size?" of "flatten to string" and "unflatten from string" function. But I really worry because I don't have a lot of ideas to fix this bug...

 

Thank you very much for any help.

 

J.

 

Download All
0 Kudos
Message 1 of 20
(5,287 Views)

Six hours is a very long time. It is impossible to troubleshoot by looking at a few pictures with unknown subVIs. Could you add some debugging code that writes the actual string received to disk whenever this error occurs? This might give a clue on what's happening.

0 Kudos
Message 2 of 20
(5,270 Views)

Thank you for your help altenbach.

 

OK, I have launched the test with this little VI in order to log TCP data binary string (see screenshot attached)...I'll send the log file in next post...

0 Kudos
Message 3 of 20
(5,265 Views)

Here are 2 log files :

- TCP ERROR_ok.log : exemple of data binary string received when the "unflatten from string" function works properly

- TCP ERROR_ko.log : exemple of data binary string received when the "unflatten from string" function generates an error (error 116 if the data output is linked to graph indicator ; error 74 if the data output is not linked to graph indicator...that's strange but anyway, that's the same kind of error : corrupted data)

 

You will also find a VI to show you how error is generated (LV 2011). As described in the VI, the data type is as follow :

- Wfm array (64 channels)

- For each channels, 2000 points (data type : SGL)

 

If you have any idea...

Download All
0 Kudos
Message 4 of 20
(5,250 Views)

I have compared both files and I noticed something (maybe it will help you to help me ! Smiley Happy ) :

There is an 8 byte substring in each file that I find 64 times in the "good" file whereas I find it 65 times in the "bad" file (64 is logic because it corresponds to the number of channels in my waveform)...Please take a look at this VI which be more efficient than any complicated explanation.

 

I also have the feeling that the end of the "bad" file looks like its beginning...as if those data were corresponding to the beginning of what should have been next TCP message. Hope that's clear, sorry for my english !

0 Kudos
Message 5 of 20
(5,224 Views)

I have done some changes and my application has now been running for 24 hours. It seems that those changes make it works (unless I post another message in next days ! 🙂 ). Maybe it will help somebody one day so I explain what I did.

 

1) I have developped my own "flatten to string" and "unflatten from string" functions to transfer SGL Waveform Array :

See files attached.

 

Then I got error 1 generated by TCP read timeout after 2 hours of data acquisition (error 1 : invalid parameter >> I didn't really understand that, I would have understood better getting a timeout error in case of deconnection for instance...)

 

2) I have increased TCP write timeout :

By default it was a 1 second timeout with STM library, and both "acquisition" & "TCP sender" loops periods were equal to 1 second on the RT target. "I strongly suspect it is because you code on the sending side is dropping data when it hits a timeout" said somebody in another post : I think that I had such a problem as well.

 

J.

Download All
0 Kudos
Message 6 of 20
(5,179 Views)

Hello guys,please i have attached below the server and client sceen shots of a simple TCP/IP communication i am trying to do.When i run both vis i get an error message saying "LabVIEW:  Unflatten or byte stream read operation failed due to corrupt, unexpected, or truncated data." Please can you look at both screen shots and let me know what i am doing wrong?Thanks

 

Osowoaji

Download All
0 Kudos
Message 7 of 20
(5,089 Views)

@osowoaji wrote:

Hello guys,please i have attached below the server and client sceen shots of a simple TCP/IP communication i am trying to do.When i run both vis i get an error message saying "LabVIEW:  Unflatten or byte stream read operation failed due to corrupt, unexpected, or truncated data." Please can you look at both screen shots and let me know what i am doing wrong?Thanks

 

Osowoaji


You are mixing data types which is probably causing at least some of your problems. In addition, you flatten some large chunk of data yet on the receive side you read only 1024. You should include the size of the data on both the sending and receiving sides. That way the receiver will know exactly how much data to read



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 20
(5,080 Views)

Thanks Mark,so what do i do about the data types and where do i change the data size?on the flatten to string or on the TCP wite and read?I have attached the VIs maybe you can show me what you talking about.Thanks again

 

Osowoaji

Download All
0 Kudos
Message 9 of 20
(5,075 Views)

You should typecast one side or the other to match data types. As for the length modify your code to send the data length first and then send the data. Flatten to string, get the size of the string (strlen) and then send teh length as an interger then the data. On the other side read 4 bytes (the size of an integer) and typecast these 4 bytes to an integer then use that value for your next read. This way you read the exact amount of data that was sent.

 

Also, you should try and keep your questions related to this in a single thread. I see you have posted this question in several different threads already. I commend you for using search to get answers to your questions but you probably should have started a new thread rather than add to threads that are quite old.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 10 of 20
(5,063 Views)