SIGVIEW can read and write live data over an RS-232/USB serial connection using Julia scripting. This enables scenarios such as:


•Acquiring measurements from a microcontroller, data logger, or sensor board (e.g. Arduino, ESP32) that reports over a serial link

•Feeding analysis results or trigger signals out to a serial-controlled device, actuator, or indicator

•Bridging legacy lab instruments that only expose an RS-232/USB-serial interface

•Prototyping a serial protocol before dedicated hardware is available, using a virtual loopback port


Serial support consists of two custom tools:


•Serial input -- a Signal Source Window script that opens a serial port and turns incoming data into a live signal

•Serial output -- a Custom Display Window script that attaches to any signal or instrument window and sends its data out over a serial port


Prerequisites


Both scripts require the LibSerialPort Julia package. Install it once from a Julia prompt:


    using Pkg; Pkg.add("LibSerialPort")


If the package is missing when a script runs, SIGVIEW detects the import error and offers to install it automatically -- reload the script once after installation completes.



Serial input


This tool opens a serial port, decodes incoming bytes into numeric samples, and displays them as a live scrolling signal. No parent window is required.


Setting up the source


1.Open the tool from the menu: Signal tools > Use custom tool > Serial > Serial input

2.Edit the Configuration block (see below) to match your device and cabling, then save/run.

3.The window opens and immediately attempts to open the configured port.


Configuration


Open the script editor of the window to adjust the configuration variables at the top of the script (Edit script... from the context menu):


    # ---- Configuration ----

    const SERIAL_PORT        = "COM3"

    const BAUD_RATE           = 9600

    const DATA_BITS           = 8

    const PARITY              = "NONE"

    const STOP_BITS           = 1

    const FLOW_CONTROL        = "NONE"


    const DATA_FORMAT         = "ASCII_LINE"

    const LINE_TERMINATOR     = "\n"

    const VALUE_SEPARATOR     = ","

    const CSV_COLUMN_INDEX    = 1

    const BINARY_BYTE_ORDER   = "LITTLE_ENDIAN"


    const SAMPLING_RATE_HZ    = 100.0

    const Y_AXIS_UNIT         = "V"

    const MAX_SAMPLES_PER_UPDATE = 5000

    const MAX_DISPLAY_SAMPLES    = 5000


    const BUFFER_MODE           = "REPLACE"


    const UPDATE_INTERVAL_MS  = 20

    const AUTO_RECONNECT      = true

    const RECONNECT_INTERVAL_MS = 2000


    const SEND_ON_CONNECT     = ""

    const TEST_COMMAND        = "PING\n"

  # ---- End Configuration ----


  SERIAL_PORT (default: "COM3")

    Port name, e.g. "COM3" (Windows) or "/dev/ttyUSB0" (Linux/Mac).


  BAUD_RATE (default: 9600)

    Line speed, e.g. 9600, 19200, 38400, 57600, 115200.


  DATA_BITS (default: 8)

    Number of data bits: 5, 6, 7 or 8.


  PARITY (default: "NONE")

    "NONE", "ODD", "EVEN", "MARK" or "SPACE".


  STOP_BITS (default: 1)

    1 or 2.


  FLOW_CONTROL (default: "NONE")

    "NONE", "RTSCTS" (hardware) or "XONXOFF" (software).


  DATA_FORMAT (default: "ASCII_LINE")

    How to decode incoming bytes: "ASCII_LINE" (one number per line),

    "ASCII_CSV" (comma-separated columns), or "BINARY_UINT8" /

    "BINARY_INT16" / "BINARY_UINT16" / "BINARY_INT32" / "BINARY_UINT32" /

    "BINARY_FLOAT32".


  LINE_TERMINATOR (default: "\n")

    Line terminator for the ASCII formats (e.g. "\n" or "\r\n").


  VALUE_SEPARATOR (default: ",")

    Column separator for ASCII_CSV.


  CSV_COLUMN_INDEX (default: 1)

    Which column to plot for ASCII_CSV (1-based). Use 0 to append all

    columns as consecutive samples.


  BINARY_BYTE_ORDER (default: "LITTLE_ENDIAN")

    Byte order used by the BINARY_* formats.


  SAMPLING_RATE_HZ (default: 100.0)

    Sampling rate assigned to the decoded signal. Set to match your

    device's actual output rate.


  Y_AXIS_UNIT (default: "V")

    Unit shown on the Y axis.


  MAX_SAMPLES_PER_UPDATE (default: 5000)

    Safety cap on samples decoded in a single update, to keep the UI

    responsive during a data burst.


  MAX_DISPLAY_SAMPLES (default: 5000)

    Length of the scrolling window kept in memory and displayed; older

    samples are dropped.


 BUFFER_MODE (default: "REPLACE")

    "ACCUMULATE" — appends newly decoded samples to a rolling history buffer, correct for a real device that only ever streams new readings.

    "REPLACE" — each update shows only the samples decoded since the last update, discarding what was shown before.


  UPDATE_INTERVAL_MS (default: 20)

    How often the port is polled, in milliseconds (minimum 10).


  AUTO_RECONNECT (default: true)

    Automatically retry opening the port if it is closed or lost.


  RECONNECT_INTERVAL_MS (default: 2000)

    Minimum time between reconnect attempts.


  SEND_ON_CONNECT (default: "")

    Optional string sent to the device right after the port opens (e.g. a

    "start streaming" command). Leave empty to send nothing.


  TEST_COMMAND (default: "PING\n")

    String sent by the "Send Test Command" right-click action. Leave empty

    to hide that action.



Status display


The source window displays live statistics as text overlay:


- Connection state -- connected/disconnected, paused

- Byte and sample counters -- total bytes received and samples successfully decoded

- Last error -- the most recent connection or decode error, if any



Right-click actions


Available on the window's context menu:


- Connect Port / Reconnect Port -- closes and reopens the serial connection

- Pause Acquisition / Resume Acquisition -- temporarily stops decoding without closing the port

- Clear Input Buffer -- discards any buffered but unparsed bytes and flushes the OS input buffer

- DTR: Turn ON / OFF and RTS: Turn ON / OFF -- toggle the corresponding modem control line

- Send Test Command -- writes TEST_COMMAND to the port (hidden if left empty)

- Reset Statistics -- zeroes the byte/sample counters



How it works


On each poll, the script performs a non-blocking read of whatever bytes have arrived, decodes them according to DATA_FORMAT, and appends the new samples to a rolling in-memory buffer of length MAX_DISPLAY_SAMPLES. For the ASCII formats, partial lines are carried over between polls so a line split across two reads is still decoded correctly. If the port closes or a read fails, the window keeps showing the last received data while AUTO_RECONNECT retries in the background.



Serial output


This tool opens a serial port, reads data from its parent signal or instrument window and writes it out over a serial port.


Setting up the output


1.Open the tool from the menu: Signal tools > Use custom tool > Serial > Serial output

2.Edit the Configuration block (see below) to match your device and cabling, then save/run.

3.The window opens and immediately attempts to open the configured port.



Configuration


Open the script editor of the window to adjust the configuration variables at the top of the script (Edit script... from the context menu):


    # ---- Configuration ----

    const SERIAL_PORT   = "COM4"

    const BAUD_RATE     = 9600

    const DATA_BITS     = 8

    const PARITY        = "NONE"

    const STOP_BITS     = 1

    const FLOW_CONTROL  = "NONE"


    const DATA_FORMAT   = "ASCII_LINE"

    const LINE_TERMINATOR   = "\n"

    const VALUE_SEPARATOR   = ","

    const BINARY_BYTE_ORDER = "LITTLE_ENDIAN"


    const MAX_SAMPLES_PER_FRAME = 2000

    const WRITE_TIMEOUT_SEC     = 0.2


    const AUTO_RECONNECT        = true

    const RECONNECT_INTERVAL_MS = 2000


    const SEND_ON_CONNECT = ""

    const TEST_COMMAND    = "PING\n"

  # ---- End Configuration ----


  SERIAL_PORT (default: "COM4")

    Port name of the outgoing connection.


  BAUD_RATE, DATA_BITS, PARITY, STOP_BITS, FLOW_CONTROL

    Same meaning and values as in SerialPortSignalSource.jl above. Must

    match the receiving device's settings.


  DATA_FORMAT (default: "ASCII_LINE")

    How to encode outgoing samples: "ASCII_LINE" (one number per line),

    "ASCII_CSV" (all samples of a frame on one comma-separated line), or a

    BINARY_* fixed-width format (same options as the source script).


  LINE_TERMINATOR, VALUE_SEPARATOR, BINARY_BYTE_ORDER

    Same meaning as in SerialPortSignalSource.jl.


  MAX_SAMPLES_PER_FRAME (default: 2000)

    Safety cap on samples sent per update, bounding the worst-case time a

    write can take.


  WRITE_TIMEOUT_SEC (default: 0.2)

    Maximum seconds a single write may block SIGVIEW before the frame is

    abandoned as a timeout.


  AUTO_RECONNECT (default: true)

    Automatically retry opening the port if it is closed or lost.


  RECONNECT_INTERVAL_MS (default: 2000)

    Minimum time between reconnect attempts.


  SEND_ON_CONNECT (default: "")

    Optional string sent right after the port opens. Leave empty to send

    nothing.


  TEST_COMMAND (default: "PING\n")

    String sent by the "Send Test Command" right-click action. Leave empty

    to hide that action.



Status display


The output window displays live statistics as text overlay:


- Connection state -- connected/disconnected, paused, current DTR/RTS state

- Input window -- type (Signal/Instrument) and samples per frame

- Send rate -- measured frames per second, and totals sent/dropped

- Bytes sent -- cumulative data volume in MB

- Last error -- the most recent write or connection error, if any



Right-click actions


- Connect Port / Reconnect Port

- Pause Sending / Resume Sending

- DTR: Turn ON / OFF and RTS: Turn ON / OFF

- Send Test Command (hidden if TEST_COMMAND is left empty)

- Reset Statistics



How it works


Every time the parent window updates, the script encodes its current sample block according to DATA_FORMAT and writes it to the serial port. Unlike a TCP socket, a serial write is a blocking operating-system call that SIGVIEW's Julia engine cannot run fully in the background -- so instead of queuing frames asynchronously the way the network Stream Sender does, this script bounds the risk directly: WRITE_TIMEOUT_SEC aborts a write that takes too long (the device is busy or not reading), and MAX_SAMPLES_PER_FRAME caps how much is sent per update. Together these keep a slow or unresponsive device from stalling SIGVIEW by more than a small, predictable amount.



Serial port and hardware considerations


- Unlike the network streaming tools, a serial port can only be opened by one process at a time -- if SIGVIEW reports it cannot open the port, check that no other program (another SIGVIEW window, a terminal program, an IDE's serial monitor) already has it open.

- Port names differ by operating system: "COM3"-style names on Windows, "/dev/ttyUSB0" or "/dev/ttyACM0"-style paths on Linux/Mac.

- Baud rate, parity, data bits, and stop bits must match on both ends of the link; a mismatch typically shows up as garbled ASCII or samples that fail to parse.

- Only enable FLOW_CONTROL if the device actually implements it -- enabling hardware flow control on a device that doesn't drive CTS can cause writes to stall.

- Check the voltage levels of your device before wiring it directly to a USB-serial adapter: TTL logic (3.3 V or 5 V, e.g. most microcontrollers) and RS-232 levels (up to +/-12 V, e.g. older lab instruments) are not interchangeable.



Performance notes


- Achievable data rate is bounded by the baud rate, not by SIGVIEW. As a rough guide, a baud rate carries roughly (baud / 10) bytes per second of usable payload with 8N1 framing; for example, 9600 baud supports only around 960 bytes/second, so large binary frames or high sample counts require a correspondingly higher baud rate.

- On the source script, lowering UPDATE_INTERVAL_MS reduces read latency but increases CPU usage from polling; the default of 20 ms is a reasonable balance for most acquisition rates.

- On the output script, a large MAX_SAMPLES_PER_FRAME at a low baud rate increases the worst-case time a single write can take; reduce it (or raise the baud rate) if the output window's updates start to lag.

- MAX_DISPLAY_SAMPLES on the source script directly controls memory use and on-screen history length -- raise it for a longer visible window, lower it to reduce memory use on very high sample-rate links.