High Speed UART
This application note demonstrates how to achieve a serial data rate of 400KBytes/s or more between two ZentriOS devices running ZentriOS.
This application uses two ZentriOS devices and a Python Script running on a PC.
- Module 1 and 2 are configured to use the WLAN interface and the TCP server feature.
- Both modules run in 'stream' mode and are connected to each other via UART.
- The Python Script uses separate TCP connections to the TCP server running on each module.
- The modules and the PC running the python script all connect to the same wireless network.
The flow of data is as follows:
- The Python script transmits data to Module 1 via Wi-Fi (TCP socket)
- Module 1 forwards data to Module 2 via UART
- Module 2 forwards data to Python script via Wi-Fi (TCP socket)
- Python script validates received data and calculates throughput.
The diagram below shows the flow of data:
Module 1 - Settings
|ZentriOS Commands (Module 1)||Description|
Module 2 - Settings
|ZentriOS Commands (Module 2)||Description|
Notes for Settings
- The module receiving data from the network (Module 1) has its network.buffer.rxtx_ratio set HIGH so a larger percentage of the network buffer is allocated to the RX packet pool.
- The module transmiting data to the network (Module 2) has its network.buffer.rxtx_ratio set LOW so a larger percentage of the network buffer is allocated to the TX packet pool
- For both modules:
- The bus.stream.flush_time is set to 0. This allows for 'zero-copy' of memory between the network interface and the bus
- UART hardware flow control is enabled. This is absolutely essentially so data bytes are not dropped
- The remote terminal is enabled. This allows remote configuration of the modules via Wi-Fi. Use a standard telnet client to connect and issue ZentriOS commands
- The ZentriOS UDP broadcast feature enables the python script to dynamically determine the IP address of each module
Using the Module 1 Soft AP
You can connect the ZentriOS devices and computer via any available Wi-Fi network. As the diagram above suggests, it is also possible to use the soft AP on Module 1 to create a wireless network between the modules and the PC. To use this setup (rather than a standalone Wi-Fi Access Point), add the following to the Module 1 Settings listed above:
|ZentriOS Commands (Module 1) - enables use of Module 1 softAP|
set softap.auto_start 1 set network.default_interface softap set broadcast.interface default set tcp.server.auto_interface default
Note that the settings for broadcast.interface and tcp.server.auto_interface are not necessary if these variables have not been changed from their factory defaults.
Set the Module 2
wlan.passkey according to the Module 1 settings for softap.ssid and softap.passkey.
IP addresses are allocated to connected devices by the Module 1 soft AP DHCP server, if running, according to the setting for softap.static.ip. Connect your computer to the Module 1 soft AP before running the Python script.
To run this example, follow these steps.
Copy and paste the settings above into a terminal connected to each respective module. Note that after rebooting the module, the module will no longer respond to terminal commands since hardware flow control is enabled and the UART baud rate is set to 10Mbit/s.
Use the remote terminal if a setting needs to be updated or factory reset the module using the external GPIO.
Connect the module UART signals. The signals are connected with Rx/Tx crossover and RTS/CTS crossover, as follows. Header pins shown are for Mackerel boards:
Run Python Script
Copy the following python script to your computer.
Execute the python script. You should see the following
Listening for module UDP broadcast packets...
The Python script procedure is:
- Wait until the server receives a UDP broadcast packet from each module
- When a packet is received, parse the packet for the respective module's IP address
- Connect to the TCP server of each module
- Start transmitting and receiving data
- Display unexpected characters received
- Display upload/download data throughput
Script output is similar to the following:
Supporting ZentriOS Editions and Versions