I open the port and set the UART
uart_fd = open("/dev/serial0", O_RDWR | O_NOCTTY | O_NDELAY);
if (uart_fd < 0)
{
printf("Failed to open UART\n");
return -1;
}
config.c_cflag = UART_SPEED | CS8 | CLOCAL | CREAD;
config.c_iflag = IGNPAR;
config.c_oflag = 0;
config.c_lflag = 0;
if (tcsetattr(uart_fd, TCSANOW, &config) < 0)
{
printf("Error setting UART configuration\n");
return -1;
}
And I send strings to terminal
void UART_WriteString(const char *str)
{
write (uart_fd, str, strlen(str));
//wait all chars are sent
tcdrain(uart_fd);
}
now I get gibberish on terminal no matter what baud rate I choose. What could be a problem?
(2) USB Serial Ports https://raspberrypi.stackexchange.com/questions/96697/how-many-serial-ports-are-on-the-pi-3
(3) Rpi3 to Arduino Serial UART Communication Tutorial https://raspberrypi.stackexchange.com/questions/96184/rpi3-to-arduino-serial-uart-
– tlfong01 Jan 08 '20 at 13:34