Plus applications user manual  2.9.0.bf99f0e
Software library for tracked ultrasound image acquisition, calibration, and processing.
Generic serial device

This device communicates with external hardware using serial (RS-232) connection It does not collect tracking or image data, only allows sending and receiving data using OpenIGTLink commands (see PlusServer commands).

A (customizable) newline string is appended after each sent command and the device listens for reponse that is terminated by the same newline string.

Supported hardware devices

  • Any device communicating through serial (RS-232) interface.

Supported platforms

Installation

  • Connect the device to the serial port. Make sure communication speed matches the setting in the configuration file.
  • If a USB to serial converter is used then the port number can be obtained (and modified, if needed) in the Device Manager.

Device configuration settings

  • attribute.png
    Type = "GenericSerial"
    required.png
  • attribute.png
    AcquisitionRate Defines how frequently Plus should read data sent by the serial device
    optional.png
    Default = "10"
  • attribute.png
    SerialPort Used COM port number for serial communication (ComPort: 1 => Port name: "COM1").
    required.png
  • attribute.png
    BaudRate Baud rate for serial communication.
    optional.png
    Default = "9600"
  • attribute.png
    MaximumReplyDelaySec Maximum time to wait for the device to start replying.
    optional.png
    Default = "0.100"
  • attribute.png
    MaximumReplyDurationSec Maximum time to wait for the device to finish replying.
    optional.png
    Default = "0.300"
  • attribute.png
    LineEnding Line ending character(s). Used when sending and receiving text to the device. Each character encoded as 2-digit hexadecimal, separated by spaces. For example: CR line ending is "0d", CR/LF line ending is "0d 0a"
    optional.png
    Default = "0d"
  • element.png
    DataSources No DataSource should be defined

Example configuration file PlusDeviceSet_Server_GenericSerial.xml

<PlusConfiguration version="2.1">
<DataCollection StartupDelaySec="1.0">
<DeviceSet
Name="PlusServer: Generic serial device"
Description="Send text and receive response through OpenIGTLink"
/>
<Device
Id="SerialDevice"
Type="GenericSerialDevice"
SerialPort="5"
BaudRate="9600"
LineEnding="0d"
>
<DataSources>
<DataSource Id="SerialData" Type="FieldData"/>
</DataSources>
<OutputChannels>
<OutputChannel Id="FieldChannel">
<DataSource Id="SerialData"/>
</OutputChannel>
</OutputChannels>
</Device>
</DataCollection>
<PlusOpenIGTLinkServer
MaxNumberOfIgtlMessagesToSend="1"
MaxTimeSpentWithProcessingMs="50"
ListeningPort="18944"
LogWarningOnNoDataAvailable="false"
OutputChannelId="FieldChannel" >
<DefaultClientInfo>
<MessageTypes>
<Message Type="STRING" />
</MessageTypes>
<StringNames>
<String Name="SerialData" />
</StringNames>
</DefaultClientInfo>
</PlusOpenIGTLinkServer>
</PlusConfiguration>

Example script for sending command from 3D Slicer

connectorNode = slicer.vtkMRMLIGTLConnectorNode() connectorNode.SetTypeClient('127.0.0.1', 18944) slicer.mrmlScene.AddNode(connectorNode) connectorNode.Start()

arduinoCmd = slicer.vtkSlicerOpenIGTLinkCommand() arduinoCmd.SetCommandName('SendText') arduinoCmd.SetCommandAttribute('DeviceId','SerialDevice') arduinoCmd.SetCommandTimeoutSec(1.0)

arduinoCmd.SetCommandAttribute('Text', "123456") slicer.modules.openigtlinkremote.logic().SendCommand(arduinoCmd, connectorNode.GetID())

def onArduinoCmdCompleted(observer, eventid): print("Command completed with status: " + arduinoCmd.StatusToString(arduinoCmd.GetStatus())) print("Response message: " + arduinoCmd.GetResponseMessage()) print("Full response: " + arduinoCmd.GetResponseText())

arduinoCmd.AddObserver(arduinoCmd.CommandCompletedEvent, onArduinoCmdCompleted)