Skip to content

Sharing a serial port

Multiple programs can share access to a single serial port and daisy chain when using Zaber Motion Library (ZML) in conjunction with Zaber Launcher to connect to Zaber devices.

Traditionally only one program can access a serial port. The first program to open a serial port locks the port, and other programs can only access the port after the first program closes the port.

However, if you add the serial port to Zaber Launcher, it shares that port with any scripts or programs written using Zaber Motion Library. Zaber Launcher uses an intermediate process called zaber_message_router to control access to serial ports. When a program instructs ZML to open a serial port, ZML first checks for the message router and, if present, opens the port using the message router. The message router will route replies back to the program that sent the command. For example, you can have a script running that controls the stages while using Zaber Launcher to monitor their current positions.

Zaber Launcher must be running for sharing to work. Closing Zaber Launcher will result in Zaber Motion Library losing the connection to the port and throwing an exception. If Zaber Launcher is not running, Zaber Motion Library opens the port directly and assumes exclusive ownership.

If you want to bypass the message router, use the @method OpenSerialPortDirectly method when opening the serial port.

Zaber Console

Zaber Console opens the serial port exclusively. No other program (including your scripts) can access the serial port while it's open by Zaber Console. Use the Close button in Zaber Console to release the port prior to running other programs accessing the port. If the port is open by another program, Zaber Motion Library will throw @class SerialPortBusyException.