[Scilab-users] ?==?utf-8?q? help for RS232 programming

Philipp Mühlmann p.muehlmann at gmail.com
Wed Aug 17 13:23:47 CEST 2016


small update:

1st: thanks for all commands.

2nd: There must be two leading  "*" symbols for Synchronisation.

3rd: the command (e.g. "A_r_106_0") can not be written in one single
string. Instead each symbol of the command must be send separatly.


example:

writeserial(h,"**A");    // **A  is the only part of the command that can
be send in one string
xpause(echotime);

writeserial(h,"_");
xpause(echotime);
writeserial(h,"r");
xpause(echotime);

...etc

// to end the command
writeserial(h,ascii(21));
xpause(echotime);


buf = readserial(h);

// buf contains the echo of the command a . -Symbol and the answer

// e.g.  A_r_106_0 .value


Greetings,
Philipp


2016-08-16 17:08 GMT+02:00 Samuel Gougeon <sgougeon at free.fr>:

> Hello Philipp,
> Thanks for the device pointer: very helpful to help you.
>
> Le 16/08/2016 16:27, Philipp Mühlmann a écrit :
>
> OK,
>
> it seems I need stopbit = 2;  // at leas a working C-code has this setting
>
>
> so:
>
>  h = openserial(1," 9600,n,8,2");
>
> .
> Beware about the leading space: ," 9600,n,8,2" or  "9600,n,8,2"?
>
>
> but with this, I get as a result the command back as a string when I use
> "readserial()"
>
>
> Example:
>
> h = openserial(1," 9600,n,8,2");
>
> ret = writeserial(h, " *A_r_106_0 " );
>
> .
> Same remark: there should not be any leading and trailing space:
> "*A_r_106_0"
> Moreover:
>
>    - leading "*": in the doc, it is not clear whether this char must be
>    explicitly prepended to the actual command, or if it is always
>    automatically prepended. Or if it must be sent apart, alone, before the
>    actual command.
>    You may try each method.
>
>    - trailing "§": AFAIU the doc, it looks necessary to append "§" to
>    each command. For many devices, ascii(10)==\n is used, but for this device,
>    it looks to be "§". You may try with it.
>
>
> result = readserial(h);
>
> .
> Before reading, you may try inserting a sleep(..) to wait the answer
> before reading it. When not waiting, usually we get nothing in the output
> buffer. Noticeably because here the connection here is slow (9600 bauds)
> Try first with a quite long sleep -- say 1 second -- and when you will
> have the connexion and a proper answer, you will be able to decrease and
> tune this wait time.
>
> HTH
> Samuel
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>


-- 
In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.

There we have the salad.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160817/4c189952/attachment.htm>


More information about the users mailing list