Difference between revisions of "IoTGateway/BSP/Android/Gettingstarted/How to use UART"

From ESS-WIKI
Jump to: navigation, search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
1. Overview
+
= <span style="color: rgb(0, 0, 205);">'''<span style="font-size: large;">Overview</span>'''</span> =
  
<span lang="en" style="font-family: &quot;新細明體","serif"; font-size: 12pt; mso-bidi-font-family: 新細明體; mso-font-kerning: 0pt; mso-ansi-language: en; mso-fareast-language: zh-tw; mso-bidi-language: ar-sa;"><font color="#000000">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.</font></span><br/>2. Configuration
+
<span lang="en"><font color="#000000">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.</font></span>
  
<span lang="en"><font color="#000000">The utility stty can configure the serial speed. Then the com port can be accessed as a file:</font></span> Check baudrate
+
= <br/><span style="color: rgb(0, 0, 205);"><span style="font-size: large;">'''Configuration'''</span></span> =
 +
 
 +
== <span style="font-size: medium;"><font color="#0066cc">standard baud rate</font></span> ==
 +
 
 +
<span lang="en"><font color="#000000">The utility stty can configure the serial speed. Then the com port can be accessed as a file:</font></span>
 +
 
 +
Check baudrate
  
 
  # stty -F /dev/ttymxc1 115200
 
  # stty -F /dev/ttymxc1 115200
Line 15: Line 21:
 
  #echo test > /dev/ttymxc1  
 
  #echo test > /dev/ttymxc1  
  
3. Boards
+
== <span style="font-size: medium;"><font color="#0066cc">Change&nbsp;COM mode</font></span> ==
 +
 
 +
The COM port need to change mode for user space (APK). your can add the chmod cammand in the android init.rc file in device/fsl/rom_3420_a1/.
 +
 
 +
ex: chmod 666 /dev/ttymxc*
 +
 
 +
== <span style="font-size: medium;"><font color="#0066cc">RS-485</font></span> ==
 +
 
 +
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:
  
*3.1 ROM3420 Borad
+
Enable the RS-485 feature by either using ioctrl ''TIOCSRS485'' from user space as described in [https://github.com/ADVANTECH-Corp/linux-imx6/blob/imx_4.1.15_1.0.0_ga/Documentation/serial/serial-rs485.txt <font color="#0066cc">RS-485 Kernel Documentation</font>].
  
{| style="width: 100.54%;" cellpadding="0" cellspacing="0" border="0" width="100%"
+
&nbsp;
|-
 
! style="width: 18.32%;" |
 
'''COM Name'''
 
  
! style="width: 25.82%;" |
+
= '''<span style="font-size: large;"><span style="color: rgb(0, 0, 205);">Boards</span></span>''' =
'''NXP/Freescale Name'''
 
  
! style="width: 27.92%;" |
+
== ROM3420 Borad ==
'''Device'''
 
  
! style="width: 27.92%;" |  
+
{| style="width: 500px;" cellpadding="1" cellspacing="1" border="1" align="left"
 +
|-
 +
! scope="col" | '''COM Name'''
 +
! scope="col" | '''NXP/Freescale Name'''
 +
! scope="col" | '''Device'''
 +
! scope="col" |  
 
'''RS485 support'''
 
'''RS485 support'''
  
 
|-
 
|-
| style="width: 18.32%;" |
+
| COM0
COM0
+
| UART2
 
+
|  
| style="width: 25.82%;" |
 
UART2
 
 
 
| style="width: 27.92%;" |  
 
 
/dev/ttymxc1
 
/dev/ttymxc1
  
| style="width: 27.92%;" |  
+
|  
 
Yes
 
Yes
  
 
|-
 
|-
| style="width: 18.32%;" |
+
| COM1
COM1
+
| UART4
 
+
|  
| style="width: 25.82%;" |
 
UART4
 
 
 
| style="width: 27.92%;" |  
 
 
/dev/ttymxc3
 
/dev/ttymxc3
  
| style="width: 27.92%;" |  
+
|  
 
Yes
 
Yes
  
 
|-
 
|-
| style="width: 18.32%;" |
+
| COM2
COM2
+
| UART5
 
+
|  
| style="width: 25.82%;" |
 
UART5
 
 
 
| style="width: 27.92%;" |  
 
 
/dev/ttymxc4
 
/dev/ttymxc4
  
| style="width: 27.92%;" |  
+
|  
 
Yes
 
Yes
  
 
|}
 
|}
  
*3.2 ROM7421 Borad
 
  
{| style="width: 100.54%;" cellpadding="0" cellspacing="0" border="0" width="100%"
 
|-
 
! style="width: 18.32%;" |
 
'''COM Name'''
 
  
! style="width: 25.82%;" |
 
'''NXP/Freescale Name'''
 
  
! style="width: 27.92%;" |
 
'''Device'''
 
  
! style="width: 27.92%;" |  
+
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
&nbsp;
 +
 
 +
[[File:ROM3420 COM.png|252x213px|ROM3420 COM.png]]
 +
 
 +
== ROM7421 Borad ==
 +
 
 +
{| style="width: 500px;" cellpadding="1" cellspacing="1" border="1" align="left"
 +
|-
 +
! scope="col" | '''COM Name'''
 +
! scope="col" | '''NXP/Freescale Name'''
 +
! scope="col" | '''Device'''
 +
! scope="col" |  
 
'''RS485 support'''
 
'''RS485 support'''
  
 
|-
 
|-
| style="width: 18.32%;" |
+
| COM0
COM0
+
| UART2
 
+
|  
| style="width: 25.82%;" |
 
UART2
 
 
 
| style="width: 27.92%;" |  
 
 
/dev/ttymxc1
 
/dev/ttymxc1
  
| style="width: 27.92%;" |  
+
|  
 
No
 
No
  
 
|-
 
|-
| style="width: 18.32%;" |
+
| COM1
COM1
+
| UART4
 
+
|  
| style="width: 25.82%;" |
 
UART4
 
 
 
| style="width: 27.92%;" |  
 
 
/dev/ttymxc3
 
/dev/ttymxc3
  
| style="width: 27.92%;" |  
+
|  
 
No
 
No
  
 
|}
 
|}
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
= <span style="color: rgb(0, 0, 205);"><span style="font-size: large;">'''Test Sample'''</span></span> =
 +
 +
1. Click "Serial Port"
 +
 +
[[File:Imx6ABV1 APP serialport.png|972x187px|Imx6ABV1 APP serialport.png]]
 +
 +
2. Click "Setup"
 +
 +
[[File:Imx6ABV1 serialport setup.png|973x552px|Imx6ABV1 serialport setup.png]]
 +
 +
3. Click "Device" , and choose the used device(e.g. ttymxc1)
 +
 +
[[File:Imx6ABV1 serialport setup device 1.png|492x140px|Imx6ABV1 serialport setup device 1.png]]
 +
 +
4. Click "Baud rate" , and choose the used baudrate(e.g. 115200)
 +
 +
[[File:Imx6ABV1 serialport setup device 2.png|428x140px|Imx6ABV1 serialport setup device 2.png]]

Latest revision as of 07:39, 6 February 2017

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 

Change COM mode

The COM port need to change mode for user space (APK). your can add the chmod cammand in the android init.rc file in device/fsl/rom_3420_a1/.

ex: chmod 666 /dev/ttymxc*

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







 

ROM3420 COM.png

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"

Imx6ABV1 APP serialport.png

2. Click "Setup"

Imx6ABV1 serialport setup.png

3. Click "Device" , and choose the used device(e.g. ttymxc1)

Imx6ABV1 serialport setup device 1.png

4. Click "Baud rate" , and choose the used baudrate(e.g. 115200)

Imx6ABV1 serialport setup device 2.png