Welcome Guest, you are in: Login

EventIDE Wiki

RSSRSS

Navigation




Search the wiki


PoweredBy

Page History: COM Port Element

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2011/08/23 03:38


Element Icon COM Port Element
Info
Category: Communications AddIn: Base Elements
Creator: OkazoLab Team Scope: Parent Event
Owns Snippets: no Usage: Runtime Screen,Snippets
Serial port is an element that provides bidirectional data exchange through the serial computer ports.


Description

COM port is an element that provides bidirectional data exchange through the serial computer ports: COM ports and USB ports (with special drivers). Using the COM port element is very easy: you simply chose one of the existing serial ports on a computer, set up a few port settings and select the element working mode. The element supports four working modes that cover most of the typical usage scenarios in experiments.

Snapshots

Snapshot 1

Snapshot 1

Snapshot 2

Snapshot 2


Practical Use

Manual Output

In this mode the serial port element can be used for sending data through the serial port at any chosen moment of time. You have to control this process manually in your code snippets in two steps. First, you should settle some data in an output buffer by assigning a string value to the [Output Buffer] property of the element. Then, the output buffer can be sent to the port immediately after you set the [Send now] property of the element to true (initiating the runtime action). You can perform these steps multiple times while your experiment is running (it not necessary to have the parent event active in this working mode).

Auto Output

In this mode the serial port element can be used for sending data through the serial port synchronously with activation of the parent event. Before the activation or in the design time you should settle data in an output buffer by a string value to the [Output Buffer] property of the element. Immediately after activation of the parent event the output buffer will be sent automatically through the serial port. The output buffer can be changed at the runtime at any time but each new sending will require reactivation of the parent event.

Input Trigger

In this working mode the serial port element monitors all input coming through the serial port in order to detect a moment when the specific string value, the trigger string, arrives. The sought value is defined by the [Trigger String] property of the element. The serial port element signals the arrival moment by switching to the triggered state. Such triggering is always accompanied with recording of the exact trigger time and executing of the dedicated code snippet (if present). Thus, you can use the specific port input for controlling a flow of your experiment, performing custom actions and collecting accurate input timing. Notice that the element in this working mode has an action scope - the input monitoring and element triggering are possible only while the parent event is active.

You can share the same port input among several serial port elements with each element seeking for its own trigger string. The elements also can be set to have multiple triggering in case in the port input may contains multiple occurrences of the trigger string (by default, in this working mode the element is triggered only once on the first trigger string arrival).

Listener

In this working mode the serial port element simply collects all port input coming through the serial port while the parent event is active. The coming input is placed into the input buffer which can be accessed at runtime by reading the [Input Buffer] property of the element in code snippets. The input buffer is designed to be forcibly refreshed on every Running Cycle of the parent event. If you want to avoid data losses, you should take into account the expected input intensity and provide continuous reading of the input buffer. The best strategy is to read the input buffer in OnRunning snippet of the parent event (a fresh data is guaranteed) and set the size of the input buffer to be always sufficient to store all input coming between two Running cycles.

Testing the serial port element

You can test a work of the serial port element with its current settings at designtime by initiating either of two design-time actions: [Test Output] and [Test Input]. EventIDE will try to simulate element's runtime behavior for a short time, while it can be checked with an external hardware or software. [TestOutput] action initiates a single transfer of the current output buffer through the port. [TestInput] action calls a text window that, while open, shows the coming port input.

Notes

  1. For better synchronization of output transfers (in AutoOutput mode), move the Serial Port element at the top of the elements list in the parent event. The elements in the list are activated one by one, as soon as the parent event is activated, so the top position in the list decreases possible time delays.
  2. The serial port element always operates with input and output port data in the string format, performing string-binary conversion automatically. For the desired adequacy of this conversion the appropriate encoding has to be selected in the element port settings.
  3. You can use multiple serial port elements that share the same serial port. However, in this case you should take in account possible performance issues, which are likely, for example, in cases of the intensive port input.

Properties

Generic Properties

NameDescriptionAttributesValue Type
Control
Working modeDefines the working mode for the given serial port element. One of 4 available working modes can be selected: ManulOutput – the element is set for sending output through the port by a manual request, at any time. AutoOutput - the element is set for sending output synchronously with the activation of the parent event. Input Trigger - the element is set for monitoring the port input in order to detect a specific input string while the parent event is active. Listener - the element is set to listen all port input and store it into a temporal buffer.D List
Test port Initiates opening the port and a test transfer of the current Data string through the port. Use this property at the design time to check availability of the selected port and settings.Design-time action
Output
Output BufferContains a string to be sent as an output through the serial port.D,R String
Send NowAssigning True to this property at runtime initiates a single transfer of the output buffer through the port.Run-time actionBoolean
Test OutputInitiates a single transfer of the current output buffer through the serial port. This property can be also used to check availability of the selected serial port and its settings.Design-time action
Port Settings
Port name The system name of the used serial port. The typical names are COM1, COM2 and so on.D String
Baud RateThe data rate in bits per second (bauds). The typical rates 4800, 9600 and so on.DInt32
Stop bitsNumber of the stop bits per transferred byte. One of the options- None, One, Two or 1.5 can be chosen.DList
ParityParity-checking protocol. One of the options- None, Odd, Even, Mark, Space can be chosen..DList
Data bits numberThe number of data bits in each transferred byte. The typical values are either 8 or 7.DInt32
EncodingThe encoding that is used to convert transferred port bytes in/out of strings. Use the ByteChar encoding for the lossless byte/char conversion.DInt32
Input
Test Input Activates a text window that, while open, shows the currently coming port input. Can be also used to check availability of the selected serial port and its settings.Design-time action
Trigger String String value that has to be detected in the port input when the element works in the InputTrigger mode. D,R String
Buffer size The size of the input buffer in bytes. When the element works in the Listener mode, the size has to be sufficient to store all input arriving during a single Running Cycle of the parent event. Adjust this value according to the expected input intensity.D Int32
Input Buffer A string containing the most recent port input when the element works in the Listener mode. The string is refreshed on each Running Cycle of the parent event. R, Read-Only String
Trigger Once Defines the triggering behavior when the element works in the Input Trigger mode. If the value is true, the element may be triggered only once, while the parent event is active. If the value is false, multiple triggering is allowed.D Boolean
Runtime Info
Is Input LostThis statistics may help to evaluate the port input intensity when the element works in the Listener mode. If this property turns to true, while the parent event is active, it means that the size of the input buffer is not sufficient to store all coming data in a single Running Cycle of the parent event.R, Read-Only Boolean
Was TriggeredIndicates if the element has been triggered at least once starting from the current activation of the parent event R, Read-Only Boolean
Trigger timeIndicates the latest event time when the element was triggered (in ms elapsed since activation of the parent event). The property is usable only when the element works in the Input Trigger mode.R, Read-only UInt64

+=== Properties inherited from clElement === Inherited properties of clElement
NameDescriptionConstraintsValue TypeUpon Change
Control
Is EnabledIf set to false the element is completely omitted when the experiment is run.Boolean
TitleTitle of the element.String

ScrewTurn Wiki version 5.2.0.8. Some of the icons created by FamFamFam.