IoTGateway/BSP/Android/Gettingstarted/How to use UART
Contents
Overview
The Android/Linux UART/serial port access from user is through the tty-devices. The tty-devices have different names depending on UART driver on different board.
Configuration
standard baud rate
The utility stty can configure the serial speed. Then the com port can be accessed as a file:
Check baudrate
# stty -F /dev/ttymxc1 115200
Read
#cat /dev/ttymxc1 &
Send
#echo test > /dev/ttymxc1
RS-485
RS-485 uses half-duplex communication, which means that one medium is shared for transmitting and receiving data. Therefore the system needs to control the RS-485 transceiver's transmit mode. Usually the UART RTS signal is used to switch the transmitter on and off. Our modules provide the following support:
Enable the RS-485 feature by either using ioctrl TIOCSRS485 from user space as described in RS-485 Kernel Documentation.
Boards
ROM3420 Borad
COM Name | NXP/Freescale Name | Device |
RS485 support |
---|---|---|---|
COM0 | UART2 |
/dev/ttymxc1 |
Yes |
COM1 | UART4 |
/dev/ttymxc3 |
Yes |
COM2 | UART5 |
/dev/ttymxc4 |
Yes |
ROM7421 Borad
COM Name | NXP/Freescale Name | Device |
RS485 support |
---|---|---|---|
COM0 | UART2 |
/dev/ttymxc1 |
No |
COM1 | UART4 |
/dev/ttymxc3 |
No |
Test Sample
1. Click "Serial Port"
2. Click "Setup"
3. Click "Device" , and choose the used device(e.g. ttymxc1)
4. Click "Baud rate" , and choose the used baudrate(e.g. 115200)