[Scilab-users] Sockets in scilab 6.0
James Holland
j_holland at msn.com
Tue Jun 26 20:20:02 CEST 2018
For testing I've stripped out all the code and put it into one script so I
don't need to keep rebuilding and reloading. What I have now is:
id =1;
commande = "*IDN?";
address = "192.168.1.72"
port = 3000;
// SOCKET_open
TCL_EvalStr(["set tclsocket"+string(id)+" [socket "+address+"
"+string(port)+"]";"fconfigure $tclsocket"+string(id)+" -blocking 0
-translation binary"]);
//send data
TCL_EvalStr([ "puts $tclsocket"+string(id)+" """+commande+"""";
"flush $tclsocket"+string(id)]);
sleep(10); //100ms wait for data to be returned
//get Data
mat=[];
mat=[];
cmd=["set tclsocketlong 0;";
"while {$tclsocketlong >= 0} {";
"set tclsocketlong [gets $tclsocket"+string(id)+" tclsocketligne];";
"if {$tclsocketlong >= 0} {";
// "flush $tclsocket"+string(id)+";";
// bug en cas de ""
"ScilabEval ""mat=\[\""[string map {\"" \""\"" \'' \''\''}
$tclsocketligne]\"";mat\];""";
// "ScilabEval ""mat=\[TCL_GetVar(''tclsocketligne'');mat\];""";
"}";
"}"];
res = TCL_EvalStr(strcat(cmd," "));
The scope does send back a response even though I have one linefeed
appended. However if I set the translation mode to binary I still get the
linefeed. The response from the scope (terminated with a LF) is not being
fed back, cmd is an empty matrix. What I really want to do is set outmode to
binary and inmode to LF but '-translation lf binary' gives me the following
error:
TCL_EvalStr, at line 2
wrong # args: should be "fconfigure channelId ?optionName? ?value?
?optionName value?..."
while executing
"fconfigure $tclsocket1 -blocking 0 -translation lf binary"
I haven't yet found an example showing inmode outmode
--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
More information about the users
mailing list