---
description: This section describes how can you use digital I/Os in your test sequence
---

# Digital I/O

{% embed url="https://www.youtube.com/watch?t=4s&v=MBMFrD14s-8" %}

## <mark style="color:blue;">#catchio (Wait for a specified IO device input)</mark>

Repetitively send the command to read inputs of IO mapping device and block executing the program until matches the expected value. When #oninput event occurs, the #catchio will break.

### Examples

{% tabs %}
{% tab title="Example 1 " %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#catchio</td><td>cmd="r:0:2:4";accept="1:1:1"</td></tr></tbody></table>

Read inputs 0, 2 and 4 every 10ms and block program executing until all inputs become logical 1.
{% endtab %}

{% tab title="Example 2" %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#catchio</td><td>cmd="r:0:1";accept="1:1":accept="0:0"</td></tr></tbody></table>

Almost the same as Example 1, but more states of inputs are accepted
{% endtab %}

{% tab title="Example 3" %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#catchio</td><td>cmd="r:fixture";accept="0";interval=200</td></tr></tbody></table>

This requires the "fixture" pin alias to be defined. Read the "fixture" input every 200ms and wait until it becomes a logical 0.
{% endtab %}

{% tab title="Example 4" %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#catchio</td><td>cmd="r:active";accept="1";interval=100;timeout=5000</td></tr></tbody></table>

This requires the "active" pin alias to be defined. Read the "active" input every 100ms and wait until it becomes a logical 1 for a maximum of 5 seconds. If the "active" input will not change to a log. 1 until timeout is reached, the return status will be set to one and return value to "0" (because of no change).
{% endtab %}

{% tab title="Example 5" %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#catchio</td><td>cmd="r:in0:in1:break";accept="1:0:0";accept="?:?:1"</td></tr></tbody></table>

Wild-card example. This accepts the exact combination of 1:0:0 or any combination with "break" input is active.
{% endtab %}
{% endtabs %}

### Return Value

Last state of inputs in colon-separated format, i.e. "0:1:1". Returns BREAK when paused while debugging or #oninput event.

### Command Overview

<table data-full-width="true"><thead><tr><th width="141">Command<select><option value="69d37e59dbc44aaca6dc72161f84784b" label="#msg" color="blue"></option><option value="b928d283a7784fae8c94f7bc27467b23" label="#dlg" color="blue"></option><option value="dd3ea796575b44beb6fe421f4c920096" label="#goto" color="blue"></option><option value="1576fb8a623240f6a5cd19b0086ec379" label="#return" color="blue"></option><option value="5d7a98d7acab42ebae94f38253cd4252" label="#throw" color="blue"></option><option value="6c4f0bb0151b47dfba70bb09cbe953b1" label="#onerror" color="blue"></option><option value="4456763d3e2e4df9a8fe186c05a233d0" label="#onfail" color="blue"></option><option value="1fb65c562db94959b92fecd477c64baa" label="#catchio" color="blue"></option><option value="245770ec76da438ba7f63acf8dcd0c35" label="#oninput" color="blue"></option></select></th><th>Parameter</th></tr></thead><tbody><tr><td><span data-option="1fb65c562db94959b92fecd477c64baa">#catchio</span></td><td>cmd=[string];accept=[string]{;accept2=[string];...;acceptN=[string]} {;timeout=[number]}{;interval=[number]}{set-cnt=[number]}</td></tr></tbody></table>

#### Parameter Description

<table data-full-width="true"><thead><tr><th width="162.33333333333331">Parameter</th><th width="103">Type</th><th>Options</th></tr></thead><tbody><tr><td>cmd</td><td>[string]</td><td>Command of funTEST IO mapping device to read specified inputs. Alias or input numbers can be used, separated by a colon ":".</td></tr><tr><td>accept</td><td>[string]</td><td>Return string sequence of IO command to be accepted. The #catchio command blocks executing the program until one of these string will match the return value. Since funTEST version 1.0.1912.410 the accept argument support wild-cards (? for any one charater and * for any number of charaters).</td></tr><tr><td>timeout</td><td>[number]</td><td>Time limit in [ms] to wait to pass all accept strings. If the timeout is reached, the #catchio command return status will be one and current state of inputs will be returned. <br><strong>Default:</strong> (no timeout)</td></tr><tr><td>interval</td><td>[number]</td><td>Interval in [ms] between executing of IO commands.<br><strong>Default</strong>: 10 [ms]</td></tr><tr><td>set-cnt</td><td>[number]</td><td>Needed count of internal iteration before "accept filter" will be accepted. Interval between iteration is depended on interval parameter<br><strong>Default</strong>: 1</td></tr></tbody></table>

## <mark style="color:blue;">#oninput (External input interrupt)</mark>

This command controls external input interrupt. Functionality requires IO mapping to be configured with used inputs enabled. When interrupt is configured, funTEST checks for change of specified input. If there is a transition on input of configured interrupt, the funTEST will go to a specified label or call a specified function. \
\
More than one interrupt can be set. Each interrupt is identified by its input pin number or alias. Interrupts are bounded to thread from which they were configured. If specific thread finishes, all bounded interrupts to this thread are cleared.

### Examples

{% tabs %}
{% tab title="Example 1 " %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#oninput</td><td>goto:start:pin=fixture-closed:change=tohigh</td></tr></tbody></table>

This example requires a defined label "start" and input pin with "fixture-closed" alias. If pin value raises from low to high, funTEST will go to on the label "start".
{% endtab %}

{% tab title="Example 2" %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#oninput</td><td>call:stop:pin=force-stop:change=tolow</td></tr></tbody></table>

This example requires a defined function block "stop" and input pin with "force-stop" alias. If pin value falls from high to low, funTEST will call the "stop" function block.
{% endtab %}

{% tab title="Example 3" %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#oninput</td><td>none/disable</td></tr></tbody></table>

Disable configured interrupts of caller's thread. If this command is executed in the main thread, all interrupts are disabled (including all another running threads).
{% endtab %}

{% tab title="Example 4" %}
<table data-full-width="true"><thead><tr><th width="214">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#oninput</td><td>stop:force-stop</td></tr></tbody></table>

Disable interrupt for the "force-stop" input.
{% endtab %}
{% endtabs %}

### Return Value

No return value.

### Command Overview

<table data-full-width="true"><thead><tr><th width="136">Command<select><option value="69d37e59dbc44aaca6dc72161f84784b" label="#msg" color="blue"></option><option value="b928d283a7784fae8c94f7bc27467b23" label="#dlg" color="blue"></option><option value="dd3ea796575b44beb6fe421f4c920096" label="#goto" color="blue"></option><option value="1576fb8a623240f6a5cd19b0086ec379" label="#return" color="blue"></option><option value="5d7a98d7acab42ebae94f38253cd4252" label="#throw" color="blue"></option><option value="6c4f0bb0151b47dfba70bb09cbe953b1" label="#onerror" color="blue"></option><option value="4456763d3e2e4df9a8fe186c05a233d0" label="#onfail" color="blue"></option><option value="1fb65c562db94959b92fecd477c64baa" label="#catchio" color="blue"></option><option value="245770ec76da438ba7f63acf8dcd0c35" label="#oninput" color="blue"></option></select></th><th>Parameter</th></tr></thead><tbody><tr><td><span data-option="245770ec76da438ba7f63acf8dcd0c35">#oninput</span></td><td>&#x3C;command>:&#x3C;label>:pin=[string/number]:change=[enum]{:single=[bool]}</td></tr></tbody></table>

#### Parameter Description

<table data-full-width="true"><thead><tr><th width="162.33333333333331">Parameter</th><th width="103">Type</th><th>Options</th></tr></thead><tbody><tr><td>command</td><td>[enum]</td><td>What should be done if error or fail has occurred. It can be on of these option: <br>• <strong>goto</strong> - go to line with a specified label, no return <br>• <strong>call</strong> - asynchronously call specified function block, there is no blocking of running program</td></tr><tr><td>label</td><td>[string]</td><td>Target label to go to or name of function block to call. Function block must ends with #return command.</td></tr><tr><td>pin</td><td>[string] or [number]</td><td>Input pin number or alias that can cause an extern interrupt. It must be defined in teststation's IO mapping.</td></tr><tr><td>change</td><td>[enum]</td><td>Specify a pin level transition. It can be: <br><strong>tohigh</strong> - a transition from low to high <br><strong>tolow</strong> - a transition from high to low</td></tr><tr><td>single</td><td>[bool]</td><td>Single-shot option. If true, the configured interrupt is automatically disabled when first occur.</td></tr></tbody></table>

## <mark style="color:blue;">Controlling and Reading I/Os from IO Column</mark>

You can also read and control digital I/Os in a dedicated column IO.

<figure><img src="https://3835935664-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F10lD1MSN8sl0KAFokfI3%2Fuploads%2FtAKaRWZMMiKHG4Rs3xRW%2Fimage.png?alt=media&#x26;token=e868aa3c-f662-4cb6-8f26-206ad983b64c" alt=""><figcaption></figcaption></figure>

### Commands available:

<table data-full-width="true"><thead><tr><th>Command</th><th width="172">Parameter</th><th width="166">Return Value</th><th>Example</th></tr></thead><tbody><tr><td><strong>*rst</strong><br>Clear all outputs (without applying outputs) and clear current segment setting.</td><td>No parameters</td><td>No return value</td><td></td></tr><tr><td><strong>s: &#x3C;out></strong><br>Set specified output(s) to ON state. The command reflect current segment settings.</td><td>out [int] or [string] Pin number or pin alias of output</td><td>No return value</td><td><strong>s:3:7:gnd:vcc</strong><br>Set outputs with numbers 3 and 7 and all outputs with aliases "gnd" and "vcc" in currently active segment (s).</td></tr><tr><td><strong>c:&#x3C;out></strong><br>Set specified output(s) to OFF state (clear). The command reflect current segment settings.</td><td>out [int] or [string] Pin number or pin alias of output</td><td>No return value</td><td><strong>c:3:7:gnd:vcc</strong><br>Clears outputs with numbers 3 and 7 and all outputs with aliases "gnd" and "vcc" in currently active segment(s).</td></tr><tr><td><strong>r:&#x3C;in></strong><br>Read state of specified inputs(s). The command reflect current segment settings.</td><td>in [int] or [string] Pin number or pin alias of input</td><td>1 = ON <br>0 = OFF</td><td><strong>r:state</strong> <br>Read all inputs with alias "state" in currently active segment(s).</td></tr></tbody></table>



{% hint style="info" %}
**IO mapping system accepts more commands in a chain at once.**\
\
![](https://3835935664-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F10lD1MSN8sl0KAFokfI3%2Fuploads%2FHPpMzjrICsS2U65lKrcm%2Fimage.png?alt=media\&token=a66be3d8-e1c9-4960-bfb0-4b960d68d226)
{% endhint %}
