Serial port

From FriendlyELEC WiKi
Revision as of 06:02, 14 February 2019 by Wuweidong (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

查看中文

1 Serial port communication in C

Please refre:[1]

2 Serial Device Names under Multiple Platforms

2.1 Allwinner H3/H5 Based Boards (NanoPi M1/NanoPi M1 Plus etc)

UART1-> /dev/ttyS1
UART2 -> /dev/ttyS2
UART3 -> /dev/ttyS3 (Only applies to NanoPi M1, NanoPi K1 and NanoPi K1 Plus)

2.2 S5P4418 Based Boards (NanoPi Fire2A/NanoPi M2A/NanoPi S2/NanoPC-T2 etc)

UART1 -> /dev/ttyAMA1 [Note 1]
UART2 -> /dev/ttyAMA2 [Note 1]
UART3 -> /dev/ttyAMA3
UART4 -> /dev/ttyAMA4

2.3 S5P6818 Based Boards (NanoPi M3/NanoPC-T3 etc)

UART1 -> /dev/ttySAC1 [Note 1]
UART2 -> /dev/ttySAC2 [Note 1]
UART3 -> /dev/ttySAC3
UART4 -> /dev/ttySAC4

Note 1: only applies to specific boards, you need to check if a board has that serial device populated.

2.4 NanoPC T4

UART4 Only

Serial Port Funcation
UART0 Bluetooth
UART1 Ehternet
UART2 Debug UART
UART3 Ehternet
UART4 Available, /dev/ttyS4

3 Uart Test Demo

  • General test method

The serial device test method described below is a general test method, which is applicable to the Allwinner H3/H5 platform development board, the S5P4418 platform development board, and the S5P6818 platform development board.

step1)Get test demo:

$ git clone https://github.com/friendlyarm/comtest.git
$ cd comtest
$ gcc -o comtest comtest.c

step2)Usage.

$ ./comtest -d /dev/ttyS2 -s 115200

After that, the data can be received through the ttyS2.
Press the Esc key 3 times to exit the program.