- Main
- Tutorials
- Library
- Samples

- Namespace List
- Namespace Members

Functions | Variables
uart Namespace Reference

## Functions
def | main ()

## Variables
int | BUF_LEN = 4096
int | UART_MODE_RS232 = 0
int | UART_PORT_1 = 0

## Detailed Description

        Copyright (C) 2019 Moxa Inc. All rights reserved.
        SPDX-License-Identifier: Apache-2.0

        UART Python Sample Application

        Date          Author            Comment
        2019-02-11    William Chang     Created it.

## Function Documentation

def uart.main | ( |  | ) |

Definition at line 29 of file uart.py.

29 def main():
30 parser = argparse.ArgumentParser(description="Miscellaneous sample program.")
31 parser.add_argument("-b", "--baudrate", dest="uart_baudrate", type=int, default=115200)
32 parser.add_argument("-p", "--port", dest="uart_port", type=int, default=UART_PORT_1)
33 parser.add_argument("-m", "--mode", dest="uart_mode", type=int, default=UART_MODE_RS232)
34 args = parser.parse_args()
35
36 uart_slot = 0
37 uart_port = args.uart_port
38 uart_mode = args.uart_mode
39 uart_baudrate = args.uart_baudrate
40 print("UART slot = {}".format(uart_slot))
41 print("UART port = {}".format(uart_port))
42 print("UART mode = {}".format(uart_mode))
43 print("UART baudrate = {}".format(uart_baudrate))
44
45 device = ioThinx_4530_API.ioThinx_4530_API()
46 fd = device.ioThinx_Uart_Open(uart_slot, uart_port, uart_mode, uart_baudrate)
47 print("fd = {}".format(fd))
48 print("Start UART echo.")
49
50 while True:
51 buf = os.read(fd, BUF_LEN)
52 print(len(buf))
53 print(buf)
54 if len(buf) > 0:
55 os.write(fd, buf)
56 if 'quit' in buf.decode():
57 break
58
59 print("Stop UART echo.")
60 os.close(fd)
61
62
uart.main
def main()
Definition: uart.py:29
format
char const int const cJSON_bool format
Definition: cJSON.h:161

## Variable Documentation

int BUF_LEN = 4096

Definition at line 24 of file uart.py.

int UART_MODE_RS232 = 0

Definition at line 25 of file uart.py.

int UART_PORT_1 = 0

Definition at line 26 of file uart.py.