Overview
The Port Input function captures raw serial/Ethernet input and behaves similarly to the General ASCII Frame driver when used with the Raw Serial Port driver. [portinputapp | Word]
Function Syntax
C
cstring PortInput(int Port, int Start, int End, int Timeout, int Length)
``
Parameters
| Parameter | Description |
|---|---|
| Port | Port number to capture input |
| Start | Start delimiter (0 = none) |
| End | End delimiter (0 = none) |
| Timeout | Character timeout (ms, 0 = none) |
| Length | Max string length (0 = 256 default) |
Port Numbers
| Port | Description |
|---|---|
| 1 | Programming Port |
| 2 | RS232 |
| 3 | RS485 |
| 4–7 | Ethernet Ports |
Behavior
- Captures incoming data between delimiters
- Returns empty string on timeout
- Limits capture length
- Works on raw serial/Ethernet streams [portinputapp | Word]
Implementation Steps
1. Create String Tag
- Type: String
- Set length (e.g., 20)
- Optional: Retentive [portinputapp | Word]
- cstring PortInput(int Port, int Start, int End, int Timeout, int Length)
2. Create Program
Example:
C
return PortInput(2, 'A', 'B', 5000, 20);
- Port = RS232
- Start = ‘A’
- End = ‘B’
- Timeout = 5000 ms
- Length = 20 [portinputapp | Word]
3. Configure Communications
- Select port used in function
-
Driver:
Red Lion → Raw Serial Port ``` [1](https://hms365-my.sharepoint.com/personal/james_jolly_hms-networks_com/_layouts/15/Doc.aspx?sourcedoc=%7B6219C0B6-1C0E-497B-A885-49784736A880%7D&file=portinputapp.docx&action=default&mobileredirect=true)
4. Link Program to Tag
Data := Comms()
- Executes program
- Stores captured data into string tag [portinputapp | Word]
Result
- Captured ASCII data is stored in string tag
- Can be used like any other tag in Crimson [portinputapp | Word]
© HMS Networks AB 2025