39 #include <px4_platform_common/px4_config.h> 40 #include <px4_platform_common/defines.h> 42 #include <sys/types.h> 52 #include <arch/board/board.h> 64 int uart2 = open(
"/dev/ttyS2", O_RDWR | O_NONBLOCK | O_NOCTTY);
67 printf(
"ERROR opening UART2, aborting..\n");
71 struct termios uart2_config;
73 struct termios uart2_config_original;
75 int termios_state = 0;
79 if ((termios_state = tcgetattr(uart2, &uart2_config)) < 0) {
80 printf(
"ERROR getting termios config for UART2: %d\n", termios_state);
85 if ((termios_state = tcgetattr(uart2, &uart2_config_original)) < 0) {
86 printf(
"ERROR getting termios config for UART2: %d\n", termios_state);
92 if (cfsetispeed(&uart2_config, B9600) < 0 || cfsetospeed(&uart2_config, B9600) < 0) {
93 printf(
"ERROR setting termios config for UART2: %d\n", termios_state);
98 if ((termios_state = tcsetattr(uart2, TCSANOW, &uart2_config)) < 0) {
99 printf(
"ERROR setting termios config for UART2\n");
105 if ((termios_state = tcsetattr(uart2, TCSANOW, &uart2_config_original)) < 0) {
106 printf(
"ERROR setting termios config for UART2\n");
111 uint8_t sample_uart2[] = {
'U',
'A',
'R',
'T',
'2',
' ',
'#', 0,
'\n'};
115 for (i = 0; i < 100; i++) {
117 r =
write(uart2, sample_uart2,
sizeof(sample_uart2));
126 printf(
"uart2_nwrite %d\n", uart2_nwrite);
static void write(bootloader_app_shared_t *pshared)
int test_uart_baudchange(int argc, char *argv[])