Useful commands for direct connection to SCPI from the terminal

Applications, development tools, FPGA, C, WEB
Post Reply
User avatar
redpitaya
Site Admin
Posts: 898
Joined: Wed Mar 26, 2014 7:04 pm

Useful commands for direct connection to SCPI from the terminal

Post by redpitaya » Wed Mar 11, 2020 12:34 pm

Here is a cheatsheet in the case you find it useful to make a direct connection to SCPI from the terminal first:

$ telnet rp-xxxxxx.local 5000 #mac or linux, or
similar in windows using https://the.earth.li/~sgtatham/putty/la ... /putty.exe
or https://chrome.google.com/webstore/deta ... dbbeonoojo
Or netcat
$ nc -C rp-xxxxxx.local 5000 #mac or linux or
of similar in windows using https://nmap.org/ncat/

for Bash: [or any language with a system() call]
$ echo dig:pin led6,1 | nc -C -q 0 10.0.0.5 5000 #turn on led
$ echo dig:pin? led6 | nc -C -q 0 10.0.0.5 5000 #query led
$ function rp() { echo $* | nc -C -q 0 10.0.0.5 5000; } #to save a few keystrokes
$ while true; do rp dig:pin led2,1; sleep 1; rp dig:pin led2,0; sleep 1; done #blink
$ nc -C 10.0.0.5 5000 # or: telnet 10.0.0.5 5000
> type your commands and see the response in real time


Here's the socket communication functions for Mathematica 11:
for Mathematica:
[1] s = SocketConnect[{"10.0.0.5", 5000}];
[2] WriteString[s, "dig:pin led6,1\r\n"];
[3] WriteString[s, "dig:pin? led6\r\n"]; Pause[.1]; ReadString[s, EndOfBuffer]
also: https://community.wolfram.com/groups/-/m/t/880903

for Octave:
> pkg install -forge sockets % I used instead: $ sudo apt-get install octave-sockets
> pkg load sockets
> s=socket(); connect(s, struct("addr", "10.0.0.5", "port", 5000));
> send(s,['dig:pin led6,0' 13 10]) % cr/lf at end
> send(s,['dig:pin? led6' 13 10]); pause(.1); char(recv(s,256,MSG_DONTWAIT)) % max 256 bytes read



Courtesy of Christopher Crawford, University of Kentucky

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 27 guests