41 #include <px4_platform_common/px4_config.h> 43 #include <sys/types.h> 52 #include <arch/board/board.h> 70 int uart2 = open(
"/dev/ttyS1", O_RDWR | O_NONBLOCK | O_NOCTTY);
73 printf(
"ERROR opening UART2, aborting..\n");
77 int uart5 = open(
"/dev/ttyS2", O_RDWR | O_NONBLOCK | O_NOCTTY);
84 printf(
"ERROR opening UART5, aborting..\n");
88 uint8_t sample_stdout_fd[] = {
'C',
'O',
'U',
'N',
'T',
' ',
'#',
'\n'};
89 uint8_t sample_uart2[] = {
'C',
'O',
'U',
'N',
'T',
' ',
'#', 0};
90 uint8_t sample_uart5[] = {
'C',
'O',
'U',
'N',
'T',
' ',
'#', 0};
94 for (i = 0; i < 1000; i++) {
96 write(stdout_fd, sample_stdout_fd,
sizeof(sample_stdout_fd));
99 r =
write(uart2, sample_uart2,
sizeof(sample_uart2));
106 write(stdout_fd, sample_stdout_fd,
sizeof(sample_stdout_fd));
109 r =
write(uart5, sample_uart5,
sizeof(sample_uart5));
116 write(stdout_fd, sample_stdout_fd,
sizeof(sample_stdout_fd));
120 r =
read(uart5, sample_uart2,
sizeof(sample_uart2));
128 write(stdout_fd, sample_stdout_fd,
sizeof(sample_stdout_fd));
131 r =
read(uart2, sample_uart5,
sizeof(sample_uart5));
142 for (i = 0; i < 200000; i++) {
145 r =
read(uart5, sample_uart2,
sizeof(sample_uart2));
151 r =
read(uart2, sample_uart5,
sizeof(sample_uart5));
157 if ((uart2_nread == uart2_nwrite) && (uart5_nread == uart5_nwrite)) {
167 printf(
"uart2_nwrite %d\n", uart2_nwrite);
168 printf(
"uart5_nwrite %d\n", uart5_nwrite);
169 printf(
"uart2_nread %d\n", uart2_nread);
170 printf(
"uart5_nread %d\n", uart5_nread);
int test_uart_loopback(int argc, char *argv[])
static void read(bootloader_app_shared_t *pshared)
static void write(bootloader_app_shared_t *pshared)