Please refer to the following correction example:
Our software engineers corrected what they thought.
After checking the source code, he thinks that there are two correction points below.
(1) terminator setting
It seems necessary to set the Terminator setting (CRLF) of transmission and reception.
In OSA, ETHERNET (SOCKET) communication uses "CR / LF" for Terminator.
Even in your program, I think you need to set "TCP / IP object" "Terminator" to "CR / LF".
Example: set (t, "Terminator", 'CR / LF');
(2) receive "ready" character string
It is necessary to receive "ready" character string from OSA after sending password.
After sending the password to OSA, OSA sends "ready" when the connection is completed.
Please execute command communication after receiving it.
Please refer to the section written below.
%%% change Serial number according to the OSA
t = tcpip('6370C91NA17145', 10001);
pause(3);
% Set size of receiving buffer, if needed.
set(t, 'InputBufferSize', 30000);
set(t, “Terminator”, 'CR/LF');
% Open connection to the server.
fopen(t);
pause(3);
% Transmit data to the server (or a request for data from the server).
fprintf(t, 'OPEN "labman"');
pause(1)
% read strings “AUTHENTICATE CRAM-MD5.\n” from OSA
while (get(t, 'BytesAvailable') > 0)
t.BytesAvailable
DataReceived = fscanf(t)
end
% send password strings
fprintf(t, 'labman');
pause(3);
% read connection completion strings “ready\n” from OSA
while (get(t, 'BytesAvailable') > 0)
t.BytesAvailable
DataReceived = fscanf(t)
end
fprintf(t, '*RST');
pause(10);