Hi i want to read some datas over the serial port with plink.exe. in the dos shell it works
with scilab terminal i get
and i tried several cmd commands and echo.
Any idea?
Hi i want to read some datas over the serial port with plink.exe. in the dos shell it works
Any idea?
Hello,
It really depends on your goal: do you just want to asynchronously display data coming from the serial port or read and process the data within Scilab ? In the first case (although the code can be adapted to the second) I posted some time ago on the ML the following function which displays the asynchronous output of a dos command (timeout of 2 seconds can be customized):
function cmd(cmdstr)
tmpfile=fullfile(TMPDIR,"out.txt");
host("start /B "+cmdstr +" > "+tmpfile)
s=0;
ns=0;
dt=1;
TIMEOUT=2;
fd=mopen(tmpfile,"rb");
while %t
info=fileinfo(tmpfile)
if info(1) > s
ns = 0;
str = mgetstr(info(1)-s,fd)
mprintf("%s",str);
s=info(1)
elseif ns < TIMEOUT
sleep(dt,"s")
ns = ns+1;
else
break
end
end
mclose(fd);
mdelete(tmpfile);
endfunction
thanks, i will tested it and see if it works
M.f.G. Pascal
I tested it with the command and still saw nothing.
Actually i wanna read and process the data within Scilab. But what is the difference if i do it in Windows shell or scilab terminal?
Is there maybe a way or should the datas piped to scilab terminal?
M.f.g. Pascal
Can you check that you get some output with
cmd("ping www.google.com")
?
Yes it works with ping
but i think with plink it exits serial before mqtt gives the publishing answer to serial
I think that the redirection of the standard output fails when using plink. Can you try the following on the DOS command line:
start /B cmd > out.txt
where cmd
has to be replaced by the full plink command. BTW, can you include your outputs as text (instead of screenshots) ?
S.
ok, i can make it so, than read the txt into scilab, this should work.
But my goal its todo directly, having the strings as an array abd then make the evaluation with plotting all in scilab.
Tricky i know
if i do it with txt. i can use putty and read its logfile and that’s it. but with plink iwanted to avoid this part with txt.
No, I meant that you should try the above only to test if redirection of plink works or not. Maybe just adding quotes before and after the command would make it work from Scilab. Anyway, if the redirection works, then the file would be updated and read in Scilab by cmd().
S.
Can you add 2>&1
at the end and try again (see https://stackoverflow.com/questions/45414288/plink-command-results-not-being-saved-to-local-text-file) ?
Ok. Just make sure out.txt
above is actually empty and that you updated the code of cmd
like this (third line):
function cmd(cmdstr)
tmpfile=fullfile(TMPDIR,"out.txt");
host("start /B "+cmdstr +" > "+tmpfile+" 2>&1")
s=0;
ns=0;
dt=1;
TIMEOUT=2;
fd=mopen(tmpfile,"rb");
while %t
info=fileinfo(tmpfile)
if info(1) > s
ns = 0;
str = mgetstr(info(1)-s,fd)
mprintf("%s",str);
s=info(1)
elseif ns < TIMEOUT
sleep(dt,"s")
ns = ns+1;
else
break
end
end
mclose(fd);
mdelete(tmpfile);
endfunction
Hi again, i made it like the you
and run in terminal
it almost worked lost one O like opening but the handle was not acceptet could it be the arrow at the dataline begining? Alt+27 : ← ?
No idea. Maybe try to open the file in text mode 'rt'
instead of 'rb'
? Anyway, glad that it works !
‘rt’ the same like ‘rb’, but now with the O of Opening.
So, lets leave it here, maybe next time with a more accurate string from serial.
So, thanks for now and hope to see the next release
M.f.G. Pascal