Forum Discussion
Altera_Forum
Honored Contributor
8 years agoHi,
I am trying to establish an UART communication between two cyclone V SoCs. I am using the FPGA option enabled in Qsys for UART in both SoCs. I have got the communication running between them, for eg. I can send a string using 'echo hello SoC > /dev/ttyS1' and my application running on other SoC receives the string. Now I am running an application at Tx side, where I want to send a string(for test purposes, later on will be a data of around 20 bytes) cyclically,(running Angstrom with a RT patch). However, at the Rx side, I receive the string only once, and then the 'read' function call blocks. At the Tx side, the further transmission fails with an error 'Invalid Argument', basically for the 'write' function. However, the first write succeeds. Here is a snippet : // Init code, common for both SoCs.if ((file_des_uart = open("/dev/ttyS1", O_RDWR | O_NOCTTY )) < 0) {
perror("Failed to open the UART device file: ");
exit(1);
}
else {
puts ("uart ok");
}
struct termios options;
tcgetattr(file_des_uart, &options);
options.c_cflag = B115200 | CS8 | CLOCAL | CREAD; //<Set baud rate
options.c_iflag = IGNPAR;
options.c_oflag = 0;
options.c_lflag = 0;
tcflush(file_des_uart, TCIFLUSH);
tcsetattr(file_des_uart, TCSANOW, &options); //At Tx side char* tx_buf = "Hello SoC";
while(1 && cntr < 5) {
bytesSent = write(file_des_uart,(tx_buf),(strlen(tx_buf)+1));
if(bytesSent != strlen(tx_buf)+1) {
perror("Error: ");
break;
}
cntr++; //break after sending 5 times // At Rx side while(1)
{
if ((bytesSent = read(file_des_uart,(void*)rx_buf,50)) > 0) {
printf("uart : Received msg = %s\n",rx_buf);
}
if(bytesSent < 0) {
perror("uart : error in reading uart : ");
//break;
}
if(bytesSent == 0 {
printf("No data");
}
} As far as I know, I am not using the DMA option, since I have not configured it anywhere, and I prefer not to use it. I would like to have a simple UART communication, between the two SoCs. Does anyone have a hand on this issue?