Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | File Exchange
ATOMS : Serial Communication details
Please login or create an account

Serial Communication

Communication over a RS-232 Serial Port with Scilab on Windows and Linux
(10769 downloads for this version - 70030 downloads for all versions)
Details
Version
0.5
Authors
Enrico Segre
Aditya Sengupta
Owner Organization
Indian Institute of Technology Bombay
Maintainers
Samuel Gougeon
Aditya Sengupta
Categories
License
Creation Date
May 30, 2019
Source created on
Scilab 6.0.x
Binaries available on
Scilab 5.5.x:
Windows 64-bit Windows 32-bit Linux 64-bit Linux 32-bit MacOSX
Scilab 6.0.x:
Windows 64-bit Windows 32-bit Linux 64-bit Linux 32-bit MacOSX
Scilab 6.1.x:
Windows 64-bit Windows 32-bit Linux 64-bit Linux 32-bit MacOSX
Install command
--> atomsInstall("serial")
Description
            
Serial Communication Toolbox for Scilab
=======================================

This toolbox enables the use of Serial Communication in Scilab and in Scicoslab
(http://www.scicoslab.org).
It can run in Scilab for Windows and Linux, but not for MacOS.

FUNCTIONS
---------
 * openserial  — open serial port
 * readserial  — read characters from serial port
 * writeserial — write to the serial port
 * serialstatus — get status of the serial port
 * closeserial — close the serial port

SYNTAXES
--------
h = openserial(p, smode, translation, handshake, xchar, blocking, timeout)
buf = readserial(h [,n])
err = writeserial(h, buf)
[queue, status] = serialstatus(h)
err = closeserial(h)


Release Notes: 
==============
0.5  : 30/5/2019: ports # > 9 now supported.
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

REMARKS
-------
This toolbox 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. 

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. 
            
Files (5)
[2.86 kB]
Miscellaneous file
CHANGES 0.4.2 => 0.5   (S. Gougeon)
--------------------
 * COM #>9 are now accepted
 * eval => evstr (Scilab 6.1)
 * builder.sce :
   - now embedded as a function
   - now complies with Scilab 6
 * Improvements:
  - loader.sce: warning message added when trying to load on MacOS.
  - string(n) => msprintf("%d\n",n)
  - error messages localized
 * Help:
  - See also: short descriptions were not displayed
  - Encoding ISO-8859-1 => UTF-8
[67.86 kB]
Source code archive

[50.43 kB]
OS-independent binary for Scilab 5.5.x

[52.16 kB]
OS-independent binary for Scilab 6.0.x

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

News (0)
Comments (1)     Leave a comment 
Comment from Le Cabey -- May 30, 2020, 04:58:53 AM    
I had issues when reading/writing data containing null characters.
After I modified the readserial.sci and writeserial.sci the serial toolbox works 
perfectly.

Replace the functions found in the above files in the directory "scilab-
6.1.0\contrib\serial\0.5\macros" with the modified versions below.

The buildmacros.sce script located in the same directory must be executed to update 
the readserial.bin and writeserial.bin.

[readserial.sci]

function buf = readserial(h, n)
    // 12/1/2009: corrected version after report of bug 3829  
    if ~exists("n","local") then
        N = serialstatus(h);
        n = N(1)
    end
  /* //original code start*
    TCL_EvalStr("binary scan [read " + h + " " +
msprintf("%d\n", n) + "] cu* 
ttybuf")
    buf = ascii(evstr(TCL_GetVar("ttybuf")));
    // original code end
  */

   //modified code start
    TCL_EvalStr("binary scan [read " + h + " " +
msprintf("%u\n", n) + "] cu* 
ttybuf")    
    buf = evstr(TCL_GetVar("ttybuf"));
  //modified code start
endfunction


[writeserial.sci]

function result = writeserial(h,buf)
    //  12/1/2009: corrected version after report of bug 3829  
    if ~exists("buf","local") then 
        TCL_EvalStr("set writeresult [catch {flush " + h + "}]")
    else
   /* //original code start*
       TCL_EvalStr("set writeresult [catch {puts -nonewline "+h+..
                    " [binary format c* {" + msprintf("
%d",ascii(buf(:))') + ..
                    "}]; flush " + h + "}]")
     //original code end
   */
   
    // modified code start   
      tempstr = msprintf(" %u", buf(:));
      TCL_EvalStr("set writeresult [catch {puts -nonewline "+h+..
                  " [binary format c* {" + tempstr + ..
                  "}]; flush " + h + "}]")
      //modified code end
    end
    result = -evstr(TCL_GetVar("writeresult"));
endfunction

Cheers

Le
Leave a comment
You must register and log in before leaving a comment.
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.