[Scilab-users] ?==?utf-8?q? help for RS232 programming
Samuel Gougeon
sgougeon at free.fr
Tue Aug 16 17:08:45 CEST 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160816/e551eb86/attachment.htm>
More information about the users
mailing list