Sending PuTTY-like command through TCPIP or VISA

조회 수: 18 (최근 30일)
Ruger28
Ruger28 2019년 9월 13일
댓글: Vinod 2019년 9월 18일
Hello all,
I am having issues with sending commands to a piece of hardware through MATLAB. I can easily PuTTY into it, and send the required commands, but when I try via MATLAB, not so much.
I initially did a system(command) to log into the device via PuTTY/Plink with echo on, and can send messages through the command window, but I wish to programattically do this. I noticed that the system function locks up matlab while it is executing, making sending any MATLAB commands impossible during the time that the system function is working.
a (somewhat) strange thing is that when I am waiting to send a command in the command window, if I highlight the command text, and hit F9, the command is sent through MATLAB into the PuTTY session.
Getting down to it - I want to send commands to my device that mimic these commands in PuTTY via TCPIP or VISA connection. I am able to successfully open a connection:
boxID = visa('ni','TCPIP0::<myIP>::<myPort>::SOCKET');
fopen(boxID);
when I send a SCPI command (box is not SCPI complient), I get a response that is a square character. I am assuming that this is the result of a response from the device.
fopen(boxID);
fprintf(boxID,'%s\n','*IDN?');
response = fscanf('boxID','%s\n');
fclose(boxID)
fprintf('Response = %s',response); % output = square shaped char
I have tried to change the *IDN? command to my commands, and they do not work. MATLAB, however, does not crash.
I am at a loss here. Anyone know how to mimic PuTTY commands in MATLAB via TCPIP or VISA? An examply command in putty is :
uv % get status
uw 0x00 % turn off
Any help is greatly appreciated.

채택된 답변

Vinod
Vinod 2019년 9월 17일
If you can PuTTY into the box, then it is likely running an SSH server. Try using this:
specifically the ssh2* commands in it to see if it does what you want.
  댓글 수: 2
Ruger28
Ruger28 2019년 9월 18일
Thank you for your relpy.
I attempted to run this, and it is hung on something, which I am assuming is the SSH session.
When I step through, the br.readLine() command never finishes executing. If I supress the command response this isnt an issue, but my commands get sent and they do not control my hardware. Any idea on next steps?
Vinod
Vinod 2019년 9월 18일
I'd reach out to the author of the submission and see if he can give you some troubleshooting tips.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by