Omron HVC-P2 icon Omron HVC-P2 — Omron HVC-P/HVC-P2 ARC plugin: Python-based camera integration for body, hand and face detection, gaze, age/gender, expressions and face recognition. Try it →
 

UART

Talk to serial devices connected to an EZB. The hardware UART commands open one of the EZB's serial ports at a speed, write to it and read what has arrived. The send serial commands send bytes or text out of any digital port as software serial, without needing a hardware UART. For the serial ports of the computer itself, use the COM group.

Where to find it: type UART. in a JavaScript script, or open the ARCx API view of the script editor and expand UART


Commands

Command What it does
UART.hardwareUartAvailable Returns how many received bytes are waiting in a hardware UART's buffer on the first EZB, up to 4000.
UART.hardwareUartRead Reads the given number of bytes from a hardware UART of the first EZB.
UART.hardwareUartReadAvailable Reads every byte waiting (up to 4000) on a hardware UART of the first EZB, without waiting for more.
UART.hardwareUartReadString Reads the given number of bytes from a hardware UART of the first EZB as ASCII text.
UART.hardwareUartReadStringAvailable Reads everything waiting (up to 4000 bytes) on a hardware UART of the first EZB as ASCII text, without waiting for more.
UART.hardwareUartWrite Sends one byte out of a hardware UART on the first EZB.
UART.hardwareUartWriteString Sends text as ASCII out of a hardware UART on the first EZB.
UART.initHardwareUart Sets up a hardware UART on the first EZB at the given baud rate.
UART.sendSerial Sends one byte as serial data out of a digital port on the first EZB.
UART.sendSerialString Sends text as ASCII serial data out of a digital port on the first EZB.

Details

UART.hardwareUartAvailable

Returns how many received bytes are waiting in a hardware UART's buffer on the first EZB, up to 4000. An error is raised if the EZB is not connected.

UART.hardwareUartAvailable(uartIndex)
UART.hardwareUartAvailable(uartIndex, ezbIndex)
Value Type What it is
uartIndex number The hardware UART number, 0, 1 or 2.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number. The number of bytes waiting to be read.

UART.hardwareUartRead

Reads the given number of bytes from a hardware UART of the first EZB. The script waits until that many bytes have arrived, so check how many are available first.

UART.hardwareUartRead(uartIndex, bytesToRead)
UART.hardwareUartRead(uartIndex, bytesToRead, ezbIndex)
Value Type What it is
uartIndex number The hardware UART number, 0, 1 or 2.
bytesToRead number How many bytes to read, up to 4000.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number[]. The received bytes.

UART.hardwareUartReadAvailable

Reads every byte waiting (up to 4000) on a hardware UART of the first EZB, without waiting for more. Gives an empty array when nothing has arrived.

UART.hardwareUartReadAvailable(uartIndex)
UART.hardwareUartReadAvailable(uartIndex, ezbIndex)
Value Type What it is
uartIndex number The hardware UART number, 0, 1 or 2.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number[]. The received bytes, or an empty array.

UART.hardwareUartReadString

Reads the given number of bytes from a hardware UART of the first EZB as ASCII text. The script waits until that many bytes have arrived, so check how many are available first.

UART.hardwareUartReadString(uartIndex, bytesToRead)
UART.hardwareUartReadString(uartIndex, bytesToRead, ezbIndex)
Value Type What it is
uartIndex number The hardware UART number, 0, 1 or 2.
bytesToRead number How many bytes to read, up to 4000.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: string. The received text.

UART.hardwareUartReadStringAvailable

Reads everything waiting (up to 4000 bytes) on a hardware UART of the first EZB as ASCII text, without waiting for more. Gives an empty string when nothing has arrived.

UART.hardwareUartReadStringAvailable(uartIndex)
UART.hardwareUartReadStringAvailable(uartIndex, ezbIndex)
Value Type What it is
uartIndex number The hardware UART number, 0, 1 or 2.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: string. The received text, or an empty string.

UART.hardwareUartWrite

Sends one byte out of a hardware UART on the first EZB. The UART must be initialised first, and an error is raised if the EZB is not connected.

UART.hardwareUartWrite(uartIndex, @byte)
UART.hardwareUartWrite(uartIndex, byteArray)
UART.hardwareUartWrite(uartIndex, @byte, ezbIndex)
UART.hardwareUartWrite(uartIndex, byteArray, ezbIndex)
Value Type What it is
uartIndex number The hardware UART number, 0, 1 or 2.
byteArray number[] Only in some forms. The bytes to send, as an array of numbers from 0 to 255.
ezbIndex number Only in some forms. Which EZB to use, 0 being the first one.
@byte number Only in some forms.
  • UART.hardwareUartWrite(uartIndex, @byte): Sends one byte out of a hardware UART on the first EZB. The UART must be initialised first, and an error is raised if the EZB is not connected.
  • UART.hardwareUartWrite(uartIndex, byteArray): Sends bytes out of a hardware UART on the first EZB. The UART must be initialised first, and an error is raised if the EZB is not connected.
  • UART.hardwareUartWrite(uartIndex, @byte, ezbIndex): Sends one byte out of a hardware UART on the chosen EZB. The UART must be initialised first, and an error is raised if the EZB is not connected.
  • UART.hardwareUartWrite(uartIndex, byteArray, ezbIndex): Sends bytes out of a hardware UART on the chosen EZB. The UART must be initialised first, and an error is raised if the EZB is not connected.

UART.hardwareUartWriteString

Sends text as ASCII out of a hardware UART on the first EZB. The UART must be initialised first, and an error is raised if the EZB is not connected.

UART.hardwareUartWriteString(uartIndex, str)
UART.hardwareUartWriteString(uartIndex, str, ezbIndex)
Value Type What it is
uartIndex number The hardware UART number, 0, 1 or 2.
str string The text to send. Characters outside ASCII are sent as a question mark.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

UART.initHardwareUart

Sets up a hardware UART on the first EZB at the given baud rate. Do this once before sending or receiving on that UART.

UART.initHardwareUart(uartIndex, baud)
UART.initHardwareUart(uartIndex, baud, ezbIndex)
Value Type What it is
uartIndex number The hardware UART number, 0, 1 or 2.
baud number The baud rate in bits per second, such as 9600 or 115200.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

UART.sendSerial

Sends one byte as serial data out of a digital port on the first EZB. This is transmit only, and an error is raised if the EZB is not connected.

UART.sendSerial(port, baud, @byte)
UART.sendSerial(port, baud, byteArray)
UART.sendSerial(port, baud, @byte, ezbIndex)
UART.sendSerial(port, baud, byteArray, ezbIndex)
Value Type What it is
port number The digital port, such as d0.
baud number The baud rate in bits per second: 4800, 9600, 19200, 38400, 57600 or 115200. The older codes are still accepted too (0 = 4800, 1 = 9600, 2 = 19200, 3 = 38400, 4 = 57600, 5 = 115200, 6 = custom). Other values raise an error listing the supported speeds.
byteArray number[] Only in some forms. The bytes to send, as an array of numbers from 0 to 255.
ezbIndex number Only in some forms. Which EZB to use, 0 being the first one.
@byte number Only in some forms.
  • UART.sendSerial(port, baud, @byte): Sends one byte as serial data out of a digital port on the first EZB. This is transmit only, and an error is raised if the EZB is not connected.
  • UART.sendSerial(port, baud, byteArray): Sends bytes as serial data out of a digital port on the first EZB, any length. This is transmit only, and an error is raised if the EZB is not connected.
  • UART.sendSerial(port, baud, @byte, ezbIndex): Sends one byte as serial data out of a digital port on the chosen EZB. This is transmit only, and an error is raised if the EZB is not connected.
  • UART.sendSerial(port, baud, byteArray, ezbIndex): Sends bytes as serial data out of a digital port on the chosen EZB, any length. This is transmit only, and an error is raised if the EZB is not connected.

UART.sendSerialString

Sends text as ASCII serial data out of a digital port on the first EZB. This is transmit only, and an error is raised if the EZB is not connected.

UART.sendSerialString(port, baud, str)
UART.sendSerialString(port, baud, str, ezbIndex)
Value Type What it is
port number The digital port, such as d0.
baud number The baud rate in bits per second: 4800, 9600, 19200, 38400, 57600 or 115200. The older codes are still accepted too (0 = 4800, 1 = 9600, 2 = 19200, 3 = 38400, 4 = 57600, 5 = 115200, 6 = custom). Other values raise an error listing the supported speeds.
str string The text to send. Characters outside ASCII are sent as a question mark.
ezbIndex number Optional. Which EZB to use, 0 being the first one.