I am trying to configure the UART on the Pi 4. I have entered enable_uart=1 into /boot/config.txt and I have
sudo systemctl disable serial-getty@ttyS0.service
and removed console=serial0,115200 from /boot/cmdline.txt.
Here is the C code I got fromwiringPi:
include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringPi.h>
#include <wiringSerial.h>
int main ()
{
int serial_port ;
char dat;
if ((serial_port = serialOpen ("/dev/ttyAMA0", 115200)) < 0) /* open serial port */
{
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
return 1 ;
}
if (wiringPiSetup () == -1) /* initializes wiringPi setup */
{
fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
return 1 ;
}
while(1){
if(serialDataAvail (serial_port) )
{
//dat = serialGetchar (serial_port); /* receive character serially*/
//printf ("%c", dat) ;
//fflush (stdout) ;
serialPutchar(serial_port, '@'); /* transmit character serially on port */
}
}
}
What did I not do?