F
ollowing is LoopBack Program to Write and Read from UART
while (flag) {
mraa_uart_write(uart, buffer, sizeof(buffer));
sleep(5);
mraa_uart_read(uart,buffer1,sizeof(buffer1));
printf("Data Read %s\n",buffer1);
sleep(5);
buffer1[0]='\0';
}
I tried with /dev/ttyS0 /ttyS1 /ttyS2 /ttyS3 and /dev/ttyS4. I short Port-4 pins (Pin no.1 and Pin no.2) pins
I request you to do a loopback test for the designated UART port using the process below and then proceed for the program in C or Python:
RuggedBoard has 5x UART on different ports. To test UART1, locate P4 port on your RB (refer hardware manual) and
Step1:
Locate the port P4 on the RuggedBoard. Refer to the Hardware manual.
Step 2:
Short PIN 1 (RS232_TX_1) and PIN 2 (RS232_RX_1) using a patch cord provided in the Box to echo the transmitted data back to RuggedBoard.
Step 3:
Use the following command to check the loop-back of the transmitted data. Microcom is an application used to access serial ports.
microcom /dev/ttyS4
Note: Microcom is a serial terminal and it is installed in RuggedBoard by default.
Step 4:
Type anything on the keyboard. If the system is working fine the characters you are typing should be displayed in the terminal.
Step 5:
Press Ctrl + X to come out of the Microcom terminal and back to the Minicom.
Note: After entering the above command you will notice that whatever you type on your keyboard are getting displayed on the terminal and when you remove short of the PIN 1 and PIN 2 keyboard entries are not displayed anymore and resume the loop-back once you short the PINs again.