05-22-2025 03:09 AM
Hi everyone,
I'm currently building a TCP server in LabVIEW, with a Raspberry Pi acting as the client. I believe the connection between the two is established correctly, but my server can't seem to read the data sent by the client.
The client is programmed to send a message every second. After sending all the messages in its list, it disconnects from the server. On the Raspberry Pi terminal, I can clearly see that it connects and sends all the data (thanks to the print
statements in the code).
However, after about 25 seconds, LabVIEW displays a pop-up with the following error:
Error 85 occurred at Scan From String Function
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019N4XSAU&l=fr-FR
I’ve also encountered this error at times:
Error 56 occurs when using the TCP Listen VI
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P9RWSA0&l=fr-FR
I'm not sure if the issue is related to how I’m sending messages from the client, or if it’s the TCP READ block in LabVIEW that's causing the problem. I've attached both the Raspberry Pi code and the LabVIEW VI.
Thanks in advance to anyone who can help me troubleshoot this!
Solved! Go to Solution.
05-22-2025 04:19 AM
You need to handle errors properly. Scan From String outputs an error because the string received is not well formed.
So some questions arise: what's received? Does TCP Read output an error? If yes, you should not even try to scan the string.
Wire the error output to a Case structure and put a breakpoint into the Error case to see what's happening.
05-22-2025 07:15 AM
I followed your advice and set a breakpoint, but it didn't change the behavior of the VI. My TCP READ still doesn't work, and I don't know why...
05-22-2025 07:26 AM
@Ouinon ha scritto:
I followed your advice and set a breakpoint, but it didn't change the behavior of the VI. My TCP READ still doesn't work, and I don't know why...
Of course it did not change. It was suggested to answer the following questions:
What data is received (if any)?
Does TCP Read output an error? Which error?
05-22-2025 07:55 AM
I found my problem !
I kept getting error 85: the received string is not in the same format as the specified string.
The issue was the "\r". It has to come before the "\n", otherwise it doesn't work.
Thanks again for your help, pincpanter.
05-22-2025 08:13 AM
Hi Quinon,
@Ouinon wrote:
I kept getting error 85: the received string is not in the same format as the specified string.
The issue was the "\r". It has to come before the "\n", otherwise it doesn't work.
Why is there "\r\n" in the format string at all?
05-22-2025 08:29 AM
I added \r\n
at the end of the message sent by the client so that the TCP reader knows when a message is complete (CRLF Mode)
05-22-2025 08:30 AM
Hi Quinon,
@Ouinon wrote:
I added
\r\n
at the end of the message sent by the client so that the TCP reader knows when a message is complete (CRLF Mode)
That is ok.
But why do you need that "\r\n" at the end of the format string connected to the ScanFromString function???
05-22-2025 08:42 AM
It's not necessary, it works fine with or without it. But since my issue was that the two messages had different formats, I added \r\n
to the format used with the ScanFromString
function just to make sure it wasn’t the cause.
Now that I’ve identified the real problem, I’ve removed \r\n
from the format string, but I’m still leaving it in the client’s message.