High Speed UART
This application note demonstrates how to achieve a serial data rate of 400KBytes/s or more between two Gecko OS devices running Gecko OS.
This application uses two Gecko OS 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
Gecko OS Commands (Module 1) | Description |
---|---|
|
|
Module 2 - Settings
Gecko OS 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 Gecko OS commands
- The Gecko OS 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 Gecko OS 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:
Gecko OS 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.ssid
and
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.
Setup Instructions
To run this example, follow these steps.
Update Settings
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 UARTs
Connect the module UART signals. The signals are connected with Rx/Tx crossover and RTS/CTS crossover, as follows. Header pins shown are examples. Use the pins appropriate for your evaluation board:
Module 1
UART1 Signal |
Module 1
H2 Pin |
Module 2
UART1 Signal |
Module 2
H2 Pin |
---|---|---|---|
RX | 18 | TX | 17 |
TX | 17 | RX | 18 |
RTS | 16 | CTS | 15 |
CTS | 15 | RTS | 16 |
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 Gecko OS Versions
- Gecko OS 4
Change Log
Modified | Changes |
---|---|
2019-01-01 | Created |