09-17-2024 03:10 AM
Hi,
I have attached three VI's here. TCP Client and TCP Local server are in the client PC. SPC server is in the server PC. So TCP client will send a command to SPC server when you press a button, which will read it and then understand what data it needs to send back and will send back accordingly by flattening it into string and in the client PC, the VI TCP local server will receive that data, then unflatten it and display it to the user. But the unflatten from string is giving an error
Error 116 occurred at Unflatten From String
Unflatten or byte stream read operation failed due to corrupt, unexpected, or truncated data.
And the error doesnt occur all the time. So as I said TCP client sends the message when you press a button. So i press the button Get Cell voltages multiple times, most times i will get the error, sometimes it doesnt and displays the correct value. So why is this. And how can I fix this.
Important point : TCP Local Server has Unflatten from string and is not generic, so every time I need a different type of data, I need to reprogram the datatype in Unflatten from string. This is because I am using this only for test process, I will program the actual client later when this is successful. For now, the program I have uploaded it works to read cell voltages and cell temperatures because the datatype I have wired to Unflatten from string is 1d array.
Important point 2 : The VI SPC_Server has many references in it because this VI is part of a bigger project and the bigger project is where all the big values comes from. And this smaller subVI SPC_Server is only used to send those data to the client and I cannot share the bigger project because it is confidential.
09-17-2024 06:09 AM - edited 09-17-2024 06:35 AM
Is your data probably too large to be transmitted within the timeout period? All your subsequent reads would be corrupt, because they do not start with the data size.
I find your error handling a little confusing. It would be more clear if you skipped the second TCP read if the first one (reading the data size) times out.
Also, can I introduce you to the concept of the Natt Sequence? It does not work like that in LV2016, but the concept is still possible. For me, stacked sequence structures are completely unreadable. Even a for loop with a case structure is better, just to avoid wires going left and right.
Also, what data do you get when error 116 occurs? When unflattening a double array without prepended size I only get error 74 when less than 8 bytes are unflattened.
Could you show the server code for sending the data?
09-17-2024 09:07 AM
(Nobody in his right mind will try to debug code with a 6 frame stacked sequence containing dozens of sequence locals. 😮 )
I assume the communications works fine, right?
Can we isolate the problem to the unflatten operation? What is the value of the "data out" string when the problem occurs? (And why use a local instead of a feedback node?)
09-17-2024 10:53 AM
Very quick look (i might be completely wrong), it looks like you're sending a command like "Write:something" and then try to convert it to a float array on the other side?
Also, Clear error with 56 as input looks cleaner than the case structures.
09-17-2024 11:53 AM
@Yamaeda wrote:
Also, Clear error with 56 as input looks cleaner than the case structures.
I'll take it a step further: If you get a timeout on the read process, you cannot trust the rest of the reads. The error should not be cleared until after the entire read process.