Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | File Exchange
ATOMS : Serial Communication details
Login with GitLab

Serial Communication

Communication over a RS-232 Serial Port with Scilab on Windows and Linux
(21916 downloads for this version - 95245 downloads for all versions)
Details
Version
0.4.2
A more recent valid version with binaries for Scilab 6.0 exists: 0.5
Authors
Enrico Segre
Aditya Sengupta
Owner Organization
Indian Institute of Technology Bombay
Maintainers
Aditya Sengupta
Administrator ATOMS
Samuel Gougeon
Categories
License
Creation Date
March 13, 2017
Source created on
Scilab 6.0.x
Binaries available on
Scilab 6.0.x:
Windows 64-bit Windows 32-bit Linux 64-bit Linux 32-bit macOS
Scilab 6.1.x:
Windows 64-bit Windows 32-bit Linux 64-bit Linux 32-bit macOS
Install command
--> atomsInstall("serial")
Description
            Serial Communication Toolbox for Scilab
=======================================

This toolbox enables the use of Serial Communication in Scilab (http://www.scilab.org) and in Scicoslab (http://www.scicoslab.org).

This is a port of the __Portable Serial Toolbox__ for Scilab originally written
by Enrico Segre (http://www.weizmann.ac.il/home/fesegre)
and has been ported to Scilab 5.x and released with his kind permission. It is
licensed, at his request, under the GPLv3. 

Enrico does not wish to provide support for this toolbox anymore. Therefore, for
any support related queries or otherwise, please raise an issue on the Github
project page (https://github.com/sengupta/Scilab-Serial).
You can reach me at [this address](mailto:aditya@sengupta.me), but I would
prefer you raise an issue on Github for problems with the toolbox. 

This toolbox is known to have worked so far on Linux based systems and on
Windows (up till Windows 7). 

The implementation via TCL wrappers is certainly suboptimal, but shouldn't be
such a penalty, given the low bandwidth and the intrinsic asynchronous mode of
serial communication. And mainly, it relieves the developer from supporting many
platforms at once. 

Release Notes: 
==============

0.4.2: 13/3/2017: Toolbox ported to Scilab 6.0
0.4.1: 2/10/2012: Toolbox ported to Scilab 5.5
0.4  : 15/4/2012: Toolbox ported to Scilab 5.4
0.3  : 14/5/2011: Initial release on ATOMS by Aditya Sengupta
       serial is now compatible with Scilab 5.x
0.2.x: 12/1/2009: Final Release by Enrico Segre
0.2  : corrected version after http://bugzilla.scilab.org/3829 : 
       readserial/writeserial were confused by strings containing
       nonprintable ascii characters

Toolbox essentially still geared for scilab 4.x (4.1.2, scicoslab) in the sense
that:

- in many points the detour ``TCL_EvalStr("set answ [....]");
  TCL_GetVar("answ")`` is still implemented (was mandatory prior to
[request 319](http://requestzilla.scilab.org/show_bug.cgi?id=319)),
it is not required since scilab 4.1.2
 
            
Files (3)
[83.85 kB]
Source code archive

[51.77 kB]
OS-independent binary for Scilab 6.0.x
Binary version (all platforms)
Automatically generated by the ATOMS compilation chain

[51.77 kB]
OS-independent binary for Scilab 6.1.x

News (0)
Comments (7)     Leave a comment 
Comment from Samuel Gougeon -- March 13, 2017, 11:34:22 PM    
Great to have it in Scilab 6.0 now
Thanks
Comment from Jeff Waters -- May 15, 2017, 03:30:21 PM    
i use readserial from arduino and do not get continuous read... why ??    can it be done
without modification to toolbox... 
maybe its an issue with USB ... comments ??? 
Answer from Samuel Gougeon -- July 13, 2018, 01:38:10 PM    
> i use readserial from arduino and do not get continuous read... why ??    can it be
done
> without modification to toolbox... 
> maybe its an issue with USB ... comments ??? 

This issue could likely be due to the Scilab 6 serious bug 
http://bugzilla.scilab.org/15101 about ascii(0)
Comment from nicolas boizot -- June 8, 2017, 05:49:30 PM    
I'm using this tollbox with Scilab 6 and it works great.
It seems however that, when using openserial, the COM port must be less than 10. Is that
really the case ?
Answer from Samuel Gougeon -- June 8, 2017, 05:52:34 PM    
> I'm using this tollbox with Scilab 6 and it works great.
> It seems however that, when using openserial, the COM port must be less than 10. Is
that
> really the case ?

As far as i remember: Yes, it is a limitation for all versions. We could analyze where it
comes from: TCL or elsewhere. On my side, i never needed more than 9 ports.
Answer from Jerome Briot -- August 2, 2018, 01:16:40 PM    
> As far as i remember: Yes, it is a limitation for all versions. We could analyze
where
> it comes from: TCL or elsewhere. 

See there:
https://support.microsoft.com/en-us/help/115831/howto-specify-serial-ports-larger-than-com9

Modify the first lines of code in openserial.sci:

function h=openserial(p,smode,translation,handshake,xchar,timeout)
//port name
  if ~exists("p","local") then p=1; end
  if type(p)==1 | type(p)==8 then
    if p<=0 then error("port number must be greater than zero"); end
    if getos() == "Windows" then
      port="\\\\.\\COM"+string(p)
    else
      port="/dev/ttyS"+string(p-1)
    end
  elseif type(p)==10
    if strcmp(part(p,1:3), 'COM', 'i')==0 then
      port="\\\\.\\"+p
    else
      port=p 
    end
  else
     error("port to open must be either a number or a string")
  end

You have to rebuild the corresponding bin file.

Then you can use for example openserial(17,...) or openserial('COM17',...) or any number
greater than 9 for the COM port.

> On my side, i never needed more than 9 ports.

It's very handy when you use many USB to UART bridges that emulate virtual COM ports.
Answer from Samuel Gougeon -- May 30, 2019, 08:22:25 PM    
Ports # > 9 are now supported in serial 0.5
Comment from güner güvenç -- July 23, 2017, 09:10:12 AM    
It should definitely be a value under com port 10.
My port com 11 I have not been successful for 2 weeks.
I made comport 6.
Everything is fine
Answer from Foad Sojoodi Farimani -- May 29, 2019, 12:21:39 AM    
> It should definitely be a value under com port 10.
> My port com 11 I have not been successful for 2 weeks.
> I made comport 6.
> Everything is fine


this issue has already been solved in this fork:

https://github.com/Foadsf/Scilab-Serial

as well as this pull request:

https://github.com/sengupta/Scilab-Serial/pull/9
Comment from Samuel Gougeon -- January 16, 2019, 10:00:50 AM    
from fran6j @ http://bugzilla.scilab.org/15926

BUG DESCRIPTION:
----------------
using writeserial() function or closeserial() function generates a message about
obsolescence of function 'eval'
may be limited to these two functions in the Serial Communication Toolbox, to be
confirmed.
Answer from Samuel Gougeon -- May 30, 2019, 08:23:31 PM    
Fixed in serial 0.5
Comment from Mostafa Soliman -- February 7, 2019, 02:34:43 PM    
BUG DESCRIPTION:
----------------
Serial communication toolbox (both 0.42 and 0.41)works well with any COM port, except the
com port related to bluetooth device paired with computer.
The bluetooth device works well with another serial monitor program, but Scilab fails to
make it working. I tested this on Scilab 5.5.2 and Scilab 6.
I am wondering how Scilab can not open a port that can be opened by ordinary serial
terminal program. Can anyone tell me why does this happen?and how to resolve this issue?


ERROR LOG:
----------
at line    17 of function openserial (
C:\Users\XYZ\AppData\Roaming\Scilab\scilab-6.0.1\atoms\x64\serial\0.4.2\macros\openserial.sci
line 17 )

TCL_EvalStr,  at line 1
    couldn't open "COM5:": invalid argument
    while executing
"open COM5: r+"
    invoked from within
"set porthandle [open COM5: r+]"

HOW TO REPRODUCE THE BUG:
-------------------------
The bug appeared when I executed this line
 h=openserial(5,"115200,n,8,1")
while COM5 is the COM port assigned by windows for the paired bluetooth device. 
Comment from Foad Sojoodi Farimani -- May 29, 2019, 12:15:21 AM    
Considering that Aditya Sengupta and Enrico Segre no longer maintain this Toolbox I forked
it and solved some of the issues:

https://github.com/Foadsf/Scilab-Serial

feel free to open new issues over there and send pull requests.

However, I also implemented a completely new version of the Toolbox here:

https://gist.github.com/Foadsf/44fe9b5e2bcb02b22392adf6d8f7a871

in order to achieve MATLABs' functionality, features, and syntax. give it a try and live
comments on the Gist if you had questions/issues. You may also contact me here on Twitter:

https://twitter.com/fsfarimani

if I did not respond immediately. 
Leave a comment
You must register and log in before leaving a comment.
Login with GitLab
Email notifications
Send me email when this toolbox has changes, new files or a new release.
You must register and log in before setting up notifications.