LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW TCP Server Can't Read Data from Raspberry Pi Client (Error 85 & 56)

Solved!
Go to solution

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:

I’ve also encountered this error at times:

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!

Download All
0 Kudos
Message 1 of 9
(124 Views)

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.

pincpanter_0-1747905517767.png

 

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 9
(99 Views)

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...

0 Kudos
Message 3 of 9
(79 Views)

@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?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 9
(72 Views)
Solution
Accepted by topic author Ouinon

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.

0 Kudos
Message 5 of 9
(61 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(52 Views)

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)

0 Kudos
Message 7 of 9
(50 Views)

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???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(44 Views)

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.

0 Kudos
Message 9 of 9
(33 Views)