This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem in serial communication AM335x Beagle Bone Black

Hi,

I am new one for Beagle Bone Black(AM335x Processor), I am trying to communicate PC to  BBB through serial communication.

Now, The transmitting bytes are sending properly( BBB to PC)

But I am not receiving any data from PC. I am using LINUX OS and eclipse tool. Here I attached my source code.

Please can anyone suggest me to solve this issue, and also help me to get data from serial through ISR.

Thanks in Advance,

Regards,

SATHYA

//# dtc -O dtb -o uart1-00A0.dtbo -b 0 -@ uart1.dts
//# cp uart1-00A0.dtbo /lib/firmware/uart1-00A0.dtbo
//# echo uart1 > /sys/devices/bone_capemgr.8/slots 
 
#include <stdio.h> // standard input / output functions
#include <stdlib.h>
#include <string.h> // string function definitions
#include <unistd.h> // UNIX standard function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
#include <termios.h> // POSIX terminal control definitions
#include <time.h>   // time calls
#include <errno.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>  
 
 
void signal_handler_IO (int status);   /* definition of signal handler */ 

int open_port(void)
{
    int fd; /* File descriptor for the port */
    fd = open("/dev/ttyO0", O_RDWR | O_NOCTTY | O_NDELAY );//open the tty01 folder in readwrite and nodelay
    //fd = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY | O_SYNC);
    printf("text openport\n");
    if (fd == -1)
    {
        /* Could not open the port. */
        perror("open_port: Unable to open /dev/ttyO0");//throw error
    }
    else
    {
        fcntl(fd, F_SETFL, 0);//set the flag to 0 for file descriptor
        printf("Port1 has been succesfully opened.\n");
    }
    return(fd);
 
}

 
int configure_port(int fd)      // configure the port
{
    struct termios port_settings;      // structure to store the port settings in
    struct sigaction saio;
 
    //cfsetispeed(&port_settings, B9600);    // set baud rates
    //cfsetospeed(&port_settings, B9600);
    saio.sa_handler = signal_handler_IO;
    saio.sa_flags = 0;
    saio.sa_restorer = NULL;
    sigaction(SIGIO,&saio,NULL);
 
    fcntl(fd, F_SETFL, FNDELAY);
    fcntl(fd, F_SETOWN, getpid());
    fcntl(fd, F_SETFL,  O_ASYNC ); /**<<<<<<------This line made it work.**/
 
 
    cfsetispeed(&port_settings, B115200);    // set baud rates
    cfsetospeed(&port_settings, B115200);
 
 
    port_settings.c_cflag &= ~PARENB;    // set no parity, stop bits, data bits
    port_settings.c_cflag &= ~CSTOPB;
    port_settings.c_cflag &= ~CSIZE;
    port_settings.c_cflag |= CS8;
    port_settings.c_cflag |= (CLOCAL | CREAD);
    port_settings.c_cflag &= ~OPOST;
    tcsetattr(fd, TCSANOW, &port_settings);    // apply the settings to the port
    printf("UART1 configured\n");
    return(fd);
 
}
 
int query_modem(int fd)   // query modem with an AT command
{
 //int m,n,d,e;
 int d;
 
char buff[10];

printf("AT+CMGF=1\r\n");
d = write(fd, "Hello Sathya\r\n", 12);
if (d < 0)
fputs("write() of 4 bytes failed!\n", stderr);
else
printf("write succeed n0 %i\n",d);
sleep(2);
 
d=read(fd, buff, 1);
//printf("Buf = %s\n", buff);
memset(buff, 0, 1);
 
/*printf("AT+CMGS=\"901xxxx797\"\r\n"); // \r and \n CR n LF
e = write(fd, "AT+CMGS=\"9019354797\"\rhello,hi from aj group\n\x1A", 30);
 
if (e < 0)
fputs("write() of 4 bytes failed!\n", stderr);
else
printf("write succeed n0 %i\n",e);
sleep(8);
//e=read(fd, buff, 100);
//printf("Buf = %s\n\n\n", buff);*/
close(fd);
return (fd);
}
 
 
void close_port(unsigned int fd)
{
close(fd);
printf("text close port\n");
}
 
int main(void)
{
int fd = open_port();
sleep(5);
configure_port(fd);
while(1)
{
query_modem(fd);
}
close_port(fd);
return(0);
} //main
 
 
void signal_handler_IO (int status)
{
  printf("received SIGIO signal\n");
 
}