UART – UART communication block
Block SymbolLicensing group: STANDARD
Function Description
The UART block allows you to read and write data via the Universal Asynchronous
Receiver-Transmitter. The port parameter specifies device name. There it is possible to use
two name types:
- the address of the physical device – Usually /dev/ttyS* for Linux target or COM* for Windows. Replace "*" symbol according to the chosen serial port!
- the virtual address – REXYGEN enables the creation of a virtual UART with which you can communicate inside REXYGEN with other blocks supporting UART such as REXLANG, PYTHON, another UART block or Modbus driver. On Linux devices, the virtual port is marked with the prefix pty: (pseudo terminal) and it is possible to connect to it from another application running on the device. On Windows devices, it is possible to use the prefix vcom, which enables communication within REXYGEN. Virtual port examples: pty:/tmp/vslave, vcom:vmaster.
UART communication has several general properties that are set using parameters such as baudrate, parity, databits and stopbits. Each packet that is received or transmitted is assigned a unique ID. The ID of the next packet is always one higher than the ID of the previous packet. Once the maximum ID is reached, the next ID assigned will be 0. The maximum ID value is determined by the maxId parameter. Data is sent with the rising edge of the idTx input. If there is still data in the buffer to be sent, the WAIT output is set to on.
This block does not propagate the signal quality. More information can be found in the 1.4 section.
Input
dataTx | Vector reference to transmitted data | Reference |
lenTx | Transmitted data length (0 = whole vector) 0 | Long (I32) |
idTx | ID of the transmitted data packet 0 | Long (I32) |
idRxAck | ID of the last processed received data packet 0 | Long (I32) |
WAIT | Transmission suspended flag (data is buffered) | Bool |
R1 | Block reset | Bool |
dataRx | Vector reference to received data | Reference |
lenRx | Received data length 0 | Long (I32) |
idRx | ID of the received data packet 0 | Long (I32) |
idTxAck | ID of the last processed transmitted data packet 0 | Long (I32) |
MORE | Additional data in the receive buffer flag | Bool |
status | Internal status indicator | Long (I32) |
|
|
|
Parameter
port | Communication device name | String |
baudrate | Baudrate [bit/s] (0 = not set) 0 4000000 | Long (I32) |
parity | Parity | Long (I32) |
|
|
|
databits | Number of data bits (0 = not set) 0 3 | Long (I32) |
stopbits | Number of stop bits (0 = not set) 0 2 | Long (I32) |
maxId | Max value used as ID of a packet 2 10000000 4 | Long (I32) |
maxLen | Maximum length of the received data 1 10000000 64 | Long (I32) |
nmax | Allocated size of array 8 10000000 256 | Long (I32) |
[Previous] [Back to top] [Up]
2024 © REX Controls s.r.o., www.rexygen.com