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.

816X EVM ttyO0 serial port receive problem

Hi,

I have been able to use the secondary serial port (/dev/ttyO0) on the 816X EVM to send data, but I have not been able to receive data on it.  I am using EZSDK 5.02.02.60 with a Rev. E EVM.  The Linux console port (/dev/ttyO2) works fine in both directions.

I am setting up the serial port with the following code, then I call write() to write data to the serial port or read() to read data from it.  The read() blocks forever, even though I am typing characters at the other end.

Is this a known issue with the EVM?  Has anyone else tried using this port?  Am I missing something in my port setup?

Paul

#define BAUDRATE B9600
/* change this definition for the correct port */
#define MODEMDEVICE "/dev/ttyO0"

    /*
      Open modem device for reading and writing and not as controlling tty
      because we don't want to get killed if linenoise sends CTRL-C.
    */
    fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
    if (fd <0)
    {
        perror(MODEMDEVICE);
        exit(-1);
    }

    tcgetattr(fd, &oldtio); /* save current serial port settings */
    bzero(&newtio, sizeof(newtio)); /* clear struct for new port settings */

    /*
      BAUDRATE: Set bps rate. You could also use cfsetispeed and cfsetospeed.
      CRTSCTS : output hardware flow control (only used if the cable has
                all necessary lines. See sect. 7 of Serial-HOWTO)
      CS8     : 8n1 (8bit,no parity,1 stopbit)
      CLOCAL  : local connection, no modem contol
      CREAD   : enable receiving characters
    */
    newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;

    /*
      IGNPAR  : ignore bytes with parity errors
      ICRNL   : map CR to NL (otherwise a CR input on the other computer
                will not terminate input)
      otherwise make device raw (no other input processing)
    */
    newtio.c_iflag = IGNPAR | ICRNL;

    /*
     Raw output.
    */
    newtio.c_oflag = 0;

    /*
      ICANON  : enable canonical input
      disable all echo functionality, and don't send signals to calling program
    */
    newtio.c_lflag = ICANON;

    /*
      initialize all control characters
      default values can be found in /usr/include/termios.h, and are given
      in the comments, but we don't need them here
    */
    newtio.c_cc[VINTR]    = 0;     /* Ctrl-c */
    newtio.c_cc[VQUIT]    = 0;     /* Ctrl-\ */
    newtio.c_cc[VERASE]   = 0;     /* del */
    newtio.c_cc[VKILL]    = 0;     /* @ */
    newtio.c_cc[VEOF]     = 4;     /* Ctrl-d */
    newtio.c_cc[VTIME]    = 0;     /* inter-character timer unused */
    newtio.c_cc[VMIN]     = 1;     /* blocking read until 1 character arrives */
    newtio.c_cc[VSWTC]    = 0;     /* '\0' */
    newtio.c_cc[VSTART]   = 0;     /* Ctrl-q */
    newtio.c_cc[VSTOP]    = 0;     /* Ctrl-s */
    newtio.c_cc[VSUSP]    = 0;     /* Ctrl-z */
    newtio.c_cc[VEOL]     = 0;     /* '\0' */
    newtio.c_cc[VREPRINT] = 0;     /* Ctrl-r */
    newtio.c_cc[VDISCARD] = 0;     /* Ctrl-u */
    newtio.c_cc[VWERASE]  = 0;     /* Ctrl-w */
    newtio.c_cc[VLNEXT]   = 0;     /* Ctrl-v */
    newtio.c_cc[VEOL2]    = 0;     /* '\0' */

    /*
      now clean the modem line and activate the settings for the port
    */
    tcflush(fd, TCIFLUSH);
    tcsetattr(fd,TCSANOW,&newtio);

  • Hi,

    It has been a long time time since my original post, but I haven't gotten a response.  I'm replying to my own post in the hopes that someone will see it and give me some help.

    Paul

  • Hi Paul,

    I think the  baud rate should be set to 115200 instead of 9600.

    Regards,

    Deepthy

  • Hi Deepthy,

    I would think I should be able to set the baud rate to a number of different values.  I think the baud rate is not a problem, since I am able to see (on my PC's Hyperterminal session) characters that the 8168 UART is transmitting.  I am just not able to see (in my 8168 software) any characters being received on the same UART.

    Best regards,

    Paul

  • Perhaps a pinmux problem? Maybe UART0 RX is not pinmuxed properly. Flow control RTS and CTS pinmux problems might also stop the Rx.

  • Hi,

    I figured out the problem.

    In the serial port settings, I removed CRTSCTS from the newtio.c_cflag element of the structure as I am not using hardware flow control.  Once I did this, everything worked fine.

    I also noticed that I would not receive any characters until I hit the enter key.  I removed ICANON from the newtio.c_lflag element of the structure and the driver gave me characters as they were received.

    I also got a PL2303-based USB to serial adapter working on the eval board.  I had to go into the kernel configuration using menuconfig and enable support for the USB Serial Converter.

    Device Drivers--> USB Support --> USB Serial Converter support  --->

    and select the following items:

    USB Serial Console device support

    USB Generic Serial Driver

    USB Prolific 2303 Single Port Serial Driver

    Then, I rebuilt the kernel.  Afterwards, I was able to send and receive characters over the /dev/ttyUSB0 device.

    Paul