Index of /xtras/serial_xtra

Icon  Name                    Last modified      Size  Description
[PARENTDIR] Parent Directory - [   ] demo.ls 2016-09-01 16:43 1.6K [TXT] readme.txt 2016-09-01 16:43 1.8K [   ] SerialXtra_v0.4.zip 2016-09-01 16:44 28K
-- xtra Serial (win only)
-- v0.4 (c) 2016 Valentin Schmidt

new object me
open object me, integer port, *baud, byteSize, parity, stopBits, dtrControl, rtsControl
close object me
sendData object me, any stringOrByteArray
dataWaiting object me -- returns number of bytes waiting to be read
readData object me, *limit -- returns string (D10-) or bytearray (D11.5+)
setDataCallback object me, *cbHandler, cbTarget


Notes:
======

- only required argument for open() is the port number (e.g. 3 for COM3), all
  other arguments are optional, if not specified, the following defaults are used:

    baud = 9600
    byteSize = 8
    parity = 2
    stopBits = 0
    dtrControl = 1
    rtsControl = 1
    
  What those values mean is explained on this MS page about the DCB structure:
  https://msdn.microsoft.com/en-us/library/windows/desktop/aa363214(v=vs.85).aspx
  
- readData() returns a (binary) string in D10- and a bytearray in D11.5+.
  You can optionally pass an integer 'intLimit' for max length of returned data.

- instead of calling dataWaiting() and readData(), you can use setDataCallback() 
  to specify a callback handler (symbol) and optionaly a target object which will
  will receive any newly arrived data, again as (binary) string in D10- and
  as bytearray in D11.5+.

- sendData() accepts both (binary) strings (for D10-) and bytearrays (for D11.5+).
  To send arbitrary data types (in D11.5+), just pack them into a bytearray.

  If you e.g. just want to send the single byte 23, use:

    sx.sendData( bytearray(1, 23) )

  If you want to send the single char 'A', use:

    sx.sendData( bytearray("A") )

  If you want to send 1234 as 4 byte integer (long), use:

    ba = bytearray()
    ba.writeInt32(1234)
    sx.sendData( ba )

  And so on...