Why do I get the error "Timeout occurred while waiting for the String Terminator"?
조회 수: 21 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2020년 11월 27일
답변: MathWorks Support Team
2020년 11월 27일
I am trying to create a TCP/IP client connection with a TCP/IP server using tcpclient() (formerly tcpip()). But I get the following error:
>> echotcpip("on",5000);
>> t = tcpclient("10.10.10.100",5000);
>> val = writeread(t,"ctrlcmd");
Error reading String.
Timeout occurred while waiting for the String Terminator.
채택된 답변
MathWorks Support Team
2020년 11월 27일
What you see in the error message is the TCP/IP client saying that it expected a reply, but it did not receive a reply within the timeout period, or it did not receive the reply that it expected.
This can happen if the terminator is not configured correctly. In most cases, the TCP/IP server you are talking to will only recognize that it received a command if you end that command with terminator, such as "CR/LF".
To work around the issue, find out the correct terminator for your TCP/IP server, and specify it using the configureTerminator method:
>> t = tcpclient("10.10.10.100",5000)
>> configureTerminator(t,"CR/LF")
>> val = writeread(t,"ctrlcmd")
For the obsolete tcpip() command, the equivalent would be:
>> t = tcpip("10.10.10.100",5000)
>> t.Terminator = "CR/LF";
>> data = query(t,"ctrlcmd")
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!