navigate Logo

Getting Started

  • Quick Start Guide
  • Software Installation
  • I Want To…

User Guide

  • Supported Hardware
  • Supported File Formats
  • User Interface Walkthrough
  • Setting Up A Microscope
  • Acquiring Data
  • Case Studies

Development

  • Contributing Guidelines
  • Developer Install
  • Software Architecture
  • Feature Container
  • REST-API
  • Plugin Architecture

Troubleshooting & Known Issues

  • Troubleshooting
  • Known Issues

Plugins

  • navigate Plugin Template
  • navigate Confocal Projection
  • navigate at Scale
  • navigate Constant Velocity Acquisition
  • navigate MMCore
  • navigate ilastik Server
  • navigate Photoactivation

Reference

  • Implemented Microscopes
  • Software API
    • navigate.config
    • navigate.controller
    • navigate.controller.configurator
    • navigate.log_files
    • navigate.model
      • navigate.model.analysis
      • navigate.model.concurrency
      • navigate.model.data_sources
      • navigate.model.device_startup_functions
      • navigate.model.devices
        • navigate.model.devices.MonitoredSerial
        • navigate.model.devices.camera
        • navigate.model.devices.daq
        • navigate.model.devices.device_types
        • navigate.model.devices.filter_wheel
        • navigate.model.devices.galvo
        • navigate.model.devices.laser
        • navigate.model.devices.mirror
        • navigate.model.devices.objectives
        • navigate.model.devices.pump
        • navigate.model.devices.remote_focus
        • navigate.model.devices.shutter
        • navigate.model.devices.stage
        • navigate.model.devices.zoom
      • navigate.model.features
      • navigate.model.metadata_sources
      • navigate.model.microscope
      • navigate.model.model
      • navigate.model.plugins_model
      • navigate.model.waveforms
    • navigate.tools
    • navigate.view
navigate
  • Software API
  • navigate.model
  • navigate.model.devices
  • navigate.model.devices.MonitoredSerial
  • View page source

navigate.model.devices.MonitoredSerial

class navigate.model.devices.MonitoredSerial(*args, **kwargs)

Bases: Serial

MonitoredSerial - Serial class that logs read/write events.

__init__(*args, **kwargs)

Initialize comm port object. If a “port” is given, then the port will be opened immediately. Otherwise a Serial port object in closed state is returned.

Methods

__init__(*args, **kwargs)

Initialize comm port object.

applySettingsDict(d)

apply_settings(d)

Apply stored settings from a dictionary returned from get_settings().

cancel_read()

cancel_write()

close()

Close port

fileno()

For easier use of the serial port instance with select.

flush()

Flush of file like objects.

flushInput()

flushOutput()

getCD()

getCTS()

getDSR()

getRI()

getSettingsDict()

get_settings()

Get current port settings as a dictionary.

inWaiting()

iread_until(*args, **kwargs)

Read lines, implemented as generator.

isOpen()

isatty()

Return whether this is an 'interactive' stream.

log_event(payload, duration_ns)

Log the read/write event with performance data.

nonblocking()

DEPRECATED - has no use

open()

Open port with current settings.

read([size])

Read bytes from the serial port and log the event.

read_all()

Read all bytes currently available in the buffer of the OS.

read_until([expected, size])

Read until an expected sequence is found (' ' by default), the size is exceeded or until timeout occurs.

readable()

Return whether object was opened for reading.

readall()

Read until EOF, using multiple read() call.

readinto(b)

readline([size])

Read a line from the serial port and log the event.

readlines([hint])

Return a list of lines from the stream.

reset_input_buffer()

Clear input buffer, discarding all that is in the buffer.

reset_output_buffer()

Clear output buffer, aborting the current output and discarding all that is in the buffer.

seek

Change stream position.

seekable()

Return whether object supports random access.

sendBreak([duration])

send_break([duration])

Send break condition.

setDTR([value])

setPort(port)

setRTS([value])

set_input_flow_control([enable])

Manually control flow - when software flow control is enabled.

set_low_latency_mode(low_latency_settings)

set_output_flow_control([enable])

Manually control flow of outgoing data - when hardware or software flow control is enabled.

tell()

Return current stream position.

truncate

Truncate file to size bytes.

writable()

Return whether object was opened for writing.

write(data)

Write data to the serial port and log the event.

writelines(lines, /)

Write a list of lines to stream.

Attributes

BAUDRATES

BAUDRATE_CONSTANTS

BYTESIZES

PARITIES

STOPBITS

baudrate

Get the current baud rate setting.

break_condition

bytesize

Get the current byte size setting.

cd

Carrier Detect

closed

cts

Clear To Send

dsr

Data Set Ready

dsrdtr

Get the current DSR/DTR flow control setting.

dtr

exclusive

Get the current exclusive access setting.

in_waiting

Return the number of bytes currently in the input buffer.

interCharTimeout

inter_byte_timeout

Get the current inter-character timeout setting.

out_waiting

Return the number of bytes currently in the output buffer.

parity

Get the current parity setting.

port

Get the current port setting.

ri

Ring Indicator

rs485_mode

Enable RS485 mode and apply new settings, set to None to disable.

rts

rtscts

Get the current RTS/CTS flow control setting.

stopbits

Get the current stop bits setting.

timeout

Get the current timeout setting.

writeTimeout

write_timeout

Get the current timeout setting.

xonxoff

Get the current XON/XOFF setting.

apply_settings(d)

Apply stored settings from a dictionary returned from get_settings(). It’s allowed to delete keys from the dictionary. These values will simply left unchanged.

close()

Close port

fileno()

For easier use of the serial port instance with select. WARNING: this function is not portable to different platforms!

flush()

Flush of file like objects. In this case, wait until all data is written.

get_settings()

Get current port settings as a dictionary. For use with apply_settings().

iread_until(*args, **kwargs)

Read lines, implemented as generator. It will raise StopIteration on timeout (empty read).

isatty()

Return whether this is an ‘interactive’ stream.

Return False if it can’t be determined.

log_event(payload: bytes, duration_ns: int) → None

Log the read/write event with performance data.

Parameters:
  • payload (bytes) – The data that was read or written.

  • duration_ns (int) – The duration of the read/write operation in nanoseconds.

nonblocking()

DEPRECATED - has no use

open()

Open port with current settings. This may throw a SerialException if the port cannot be opened.

read(size=1) → bytes

Read bytes from the serial port and log the event.

Parameters:

size (int, optional) – The number of bytes to read, by default 1.

Returns:

The bytes read from the serial port.

Return type:

bytes

read_all()

Read all bytes currently available in the buffer of the OS.

read_until(expected=b'\n', size=None)

Read until an expected sequence is found (’ ‘ by default), the size

is exceeded or until timeout occurs.

readable()

Return whether object was opened for reading.

If False, read() will raise OSError.

readall()

Read until EOF, using multiple read() call.

readline(size: Optional[int] = -1, /) → bytes

Read a line from the serial port and log the event.

Parameters:

size (int, optional) – The maximum number of bytes to read, by default -1 (read until timeout).

Returns:

The line read from the serial port.

Return type:

bytes

readlines(hint=-1, /)

Return a list of lines from the stream.

hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.

reset_input_buffer()

Clear input buffer, discarding all that is in the buffer.

reset_output_buffer()

Clear output buffer, aborting the current output and discarding all that is in the buffer.

seek()

Change stream position.

Change the stream position to the given byte offset. The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • 0 – start of stream (the default); offset should be zero or positive

  • 1 – current stream position; offset may be negative

  • 2 – end of stream; offset is usually negative

Return the new absolute position.

seekable()

Return whether object supports random access.

If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().

send_break(duration=0.25)

Send break condition. Timed, returns to idle state after given duration.

set_input_flow_control(enable=True)

Manually control flow - when software flow control is enabled. This will send XON (true) or XOFF (false) to the other device. WARNING: this function is not portable to different platforms!

set_output_flow_control(enable=True)

Manually control flow of outgoing data - when hardware or software flow control is enabled. WARNING: this function is not portable to different platforms!

tell()

Return current stream position.

truncate()

Truncate file to size bytes.

File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.

writable()

Return whether object was opened for writing.

If False, write() will raise OSError.

write(data: bytes)

Write data to the serial port and log the event.

Parameters:

data (bytes) – Data to be written to the serial port.

writelines(lines, /)

Write a list of lines to stream.

Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.

property baudrate

Get the current baud rate setting.

property bytesize

Get the current byte size setting.

property cd

Carrier Detect

Type:

Read terminal status line

property cts

Clear To Send

Type:

Read terminal status line

property dsr

Data Set Ready

Type:

Read terminal status line

property dsrdtr

Get the current DSR/DTR flow control setting.

property exclusive

Get the current exclusive access setting.

property in_waiting

Return the number of bytes currently in the input buffer.

property inter_byte_timeout

Get the current inter-character timeout setting.

property out_waiting

Return the number of bytes currently in the output buffer.

property parity

Get the current parity setting.

property port

Get the current port setting. The value that was passed on init or using setPort() is passed back.

property ri

Ring Indicator

Type:

Read terminal status line

property rs485_mode

Enable RS485 mode and apply new settings, set to None to disable. See serial.rs485.RS485Settings for more info about the value.

property rtscts

Get the current RTS/CTS flow control setting.

property stopbits

Get the current stop bits setting.

property timeout

Get the current timeout setting.

property write_timeout

Get the current timeout setting.

property xonxoff

Get the current XON/XOFF setting.

Previous Next

© Copyright 2025, Dean Lab, UT Southwestern Medical Center.