Morgan Du
/
Serial-to-Ethernet
Transfer data between UART ports and Ethernet.
Transfer data between UART ports and Ethernet.
- Support multiple UART ports.
- Support fixed IP address and DHCP.
- Support TCP server and TCP client modes.
- Support a simple web server for UART and Ethernet configuration.
README.md@8:e9248126f512, 2021-02-26 (annotated)
- Committer:
- morgandu
- Date:
- Fri Feb 26 06:30:37 2021 +0000
- Revision:
- 8:e9248126f512
- Parent:
- 6:dc9f344f4bf0
Fix code to compliant Mbed OS 6 but still set to Mbed OS 5 as default.; Remove BufferedSerial library if switch to Mbed OS 6 before compile.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
morgandu | 2:35f2cc8b05fa | 1 | # Serial to Ethernet |
morgandu | 2:35f2cc8b05fa | 2 | |
morgandu | 2:35f2cc8b05fa | 3 | This example shows how to transfer data between serial port and ethernet. |
morgandu | 2:35f2cc8b05fa | 4 | |
morgandu | 2:35f2cc8b05fa | 5 | ## Required hardware |
morgandu | 6:dc9f344f4bf0 | 6 | * A supported target - |
morgandu | 6:dc9f344f4bf0 | 7 | [NuMaker-IoT-M487](https://os.mbed.com/platforms/NUMAKER-IOT-M487/) |
morgandu | 6:dc9f344f4bf0 | 8 | [NuMaker-PFM-M487](https://os.mbed.com/platforms/NUMAKER-PFM-M487/) |
morgandu | 6:dc9f344f4bf0 | 9 | [Numaker-PFM-NUC472](https://os.mbed.com/platforms/Nuvoton-NUC472/) |
morgandu | 6:dc9f344f4bf0 | 10 | |
morgandu | 6:dc9f344f4bf0 | 11 | * MicroSD card is optional. It uses to store configuration when existed. |
morgandu | 2:35f2cc8b05fa | 12 | |
morgandu | 2:35f2cc8b05fa | 13 | ## Compile Settings |
morgandu | 2:35f2cc8b05fa | 14 | |
morgandu | 2:35f2cc8b05fa | 15 | * Default socket number is 4, please add following settings to mbed_app.json to increase it. |
morgandu | 2:35f2cc8b05fa | 16 | |
morgandu | 2:35f2cc8b05fa | 17 | "target_overrides": { |
morgandu | 2:35f2cc8b05fa | 18 | "*": { |
morgandu | 2:35f2cc8b05fa | 19 | "lwip.socket-max": 8, |
morgandu | 2:35f2cc8b05fa | 20 | "lwip.tcp-socket-max": 8, |
morgandu | 2:35f2cc8b05fa | 21 | "lwip.udp-socket-max": 8 |
morgandu | 2:35f2cc8b05fa | 22 | } |
morgandu | 2:35f2cc8b05fa | 23 | |
morgandu | 2:35f2cc8b05fa | 24 | ## Configuration |
morgandu | 2:35f2cc8b05fa | 25 | |
morgandu | 8:e9248126f512 | 26 | * Mbed OS version |
morgandu | 8:e9248126f512 | 27 | |
morgandu | 8:e9248126f512 | 28 | The template set Mbed OS 5 as defalut but it has been updated for Mbed OS 6. |
morgandu | 8:e9248126f512 | 29 | Because BufferedSerial has built in Mbed OS 6, the BufferedSerial library in the template has to be removed if you switch Mbed OS to version 6 to avoid conflict. |
morgandu | 8:e9248126f512 | 30 | |
morgandu | 5:7e7ad7c079fe | 31 | * Following configurations are set in ste_config.h |
morgandu | 2:35f2cc8b05fa | 32 | |
morgandu | 5:7e7ad7c079fe | 33 | ENABLE_WEB_CONFIG |
morgandu | 5:7e7ad7c079fe | 34 | Define ENABLE_WEB_CONFIG to active a simple web server for UART ports and Ethernet port configuration. |
morgandu | 5:7e7ad7c079fe | 35 | |
morgandu | 5:7e7ad7c079fe | 36 | MAX_UART_PORTS |
morgandu | 5:7e7ad7c079fe | 37 | Maximum UART ports supported. It should be 1, 2, or 3. Please also define mapping table "port_config[]" in main.c |
morgandu | 5:7e7ad7c079fe | 38 | |
morgandu | 5:7e7ad7c079fe | 39 | DEFAULT_UART_BAUD |
morgandu | 5:7e7ad7c079fe | 40 | Default UART baud |
morgandu | 5:7e7ad7c079fe | 41 | |
morgandu | 5:7e7ad7c079fe | 42 | NET_PORT_BASE |
morgandu | 5:7e7ad7c079fe | 43 | Network base port number to listen. The base port maps to the 1st UART port, the (base port + 1) maps to the 2nd UART port, etc. |
morgandu | 5:7e7ad7c079fe | 44 | |
morgandu | 5:7e7ad7c079fe | 45 | SER_CONFIG_FILE // for serial ports |
morgandu | 5:7e7ad7c079fe | 46 | NET_CONFIG_FILE // for network |
morgandu | 5:7e7ad7c079fe | 47 | Files in SD card to store settings via web configuration |
morgandu | 5:7e7ad7c079fe | 48 | |
morgandu | 5:7e7ad7c079fe | 49 | MAX_SERVER_ADDRESS_SIZE |
morgandu | 5:7e7ad7c079fe | 50 | Maximum size of server address for web configuration |
morgandu | 5:7e7ad7c079fe | 51 | |
morgandu | 5:7e7ad7c079fe | 52 | MAX_IPV4_ADDRESS_SIZE |
morgandu | 5:7e7ad7c079fe | 53 | Maximum size of IP address for web configuration |