UART Interaction
Configure UART
Configure UART1 at 9600 baud, 8 data bits, no parity, 1 stop bit:
- command: uartCfg UART1 9600 8N1
Configure channel 1 on an external FT4232-based FT4232H Mini Module USB to UART adapter as UART2:
- command: uartCfg UART2 115200
path: "1"
interface: "1"
id: "0x0403:0x6011"
Commands
Send and Receive
Example: extract ICCID from cellular modem, storing in the ICCID
key.
- command: uart UART0
expect: "+CCID:"
extract: "CCID: (\\d{20})\r\n"
extractKey: ICCID
send: "AT+ICCID\r\n"
Example: extract multiple keys at once
- command: uart UART0
send: "\r\nkernel version\r\n"
extract: "\r\n(.*) version (.*)\r\n"
extractKey: KERNEL_NAME KERNEL_VERSION
Example: send and expect bytes from hex strings.
- command: uart UART0
send: hex "decafe01"
expect: hex "badc0ffee1"
Example: expect string
- command: uartExpect UART0 Pressed
- command: operator "Press button"
- command: uartAwait UART0 1
Example: expect bytes
- command: uartExpect UART0 "hex ef0102"
- command: operator "Press button"
- command: uartAwait UART0 1
Commands
Expected Timeouts
Example: test for read timeout after sending a string
- command: uartReadTimeout UART0 1 "AT"
Example: test for read timeout after sending bytes
- command: uartReadTimeout UART0 1 "hex badc0ffee1"
Commands
See also