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.

Reading from UART port....

Other Parts Discussed in Thread: OMAP3530


Hi,

I am using Mistral (OMAP3530 EVM).
We are using /dev/ttyS0 for console.. UART1/2 we have connected to the PC.

I would like to send some data from other pc to UART3.. So can come one .. guide me .. how can i read the data which is coming at UART3 port..

How can i configure UART3.. to read the data.. form other device...

Thanks,
BHARATH.M

  • Hey,

    A few days ago I connected a small PIC Microcontroller to my brandnew OMAP3550EVM and set up a serial connection which works quite well [:)].
    The first thing to note is that the layer representing the UART3 port can be found under "/dev/ttyS2"

    For first initial tests, I used a small c program that reads incomming bytes from UART3 port and then prints them to the console. The source-code might help you to get a small overview about serial programming.

     

    #include <stdio.h>
    #include <stdlib.h>
    #include <termios.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <sys/signal.h>
    #include <sys/types.h>


    #define BAUDRATE B9600
    #define MODEMDEVICE "/dev/ttyS2"
    #define _POSIX_SOURCE 1
    #define FALSE 0
    #define TRUE 1

    volatile int STOP=FALSE;

    int main(int argc, char *argv[])
    {
        int fd,c,res;
        struct termios oldtio,newtio;
        char buf[255];
       
        printf("serial test start configuring...\n");

        fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY | O_NDELAY);
        /*
            open(...); is a system call

            O_NCTTY program is not controlling terminal for that port
            O_NDELAY DCD line is not considered
            O_RDWR --> read write mode       
        */   

        if(fd<0){
            perror(MODEMDEVICE); // prints standard error
            exit(-1);
        }
       
        tcgetattr(fd,&oldtio);
        /*
            get current serial configuration and store
            it ins struct oldtio (function from termios.h)
        */
       
        bzero(&newtio,sizeof(newtio));
        /*
            reset configuration of newtio
        */

        // control options
        newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
       
        // input options
        newtio.c_iflag = IGNPAR;
       
        // output options
        newtio.c_oflag = 0;
       
        // control characters
        newtio.c_cc[VTIME] = 0;
        newtio.c_cc[VMIN] = 5;
        /*
            configure new settings
        */
       

        tcflush(fd,TCIFLUSH);

        tcsetattr(fd,TCSANOW,&newtio);
        /*
            set new configuration
        */


        printf("serial device configured...\n");

        printf("start listening...");
        while(STOP==FALSE){
            res = read(fd,buf,255);
            buf[res] = 0;
            printf(":%s:%d\n",buf,res);
            if(buf[0] =='z')
                STOP = TRUE;
        }
        /*
            read from fd (which is configured to read at least 5 chars)
            print result
            if first char is 'z' exit
        */

        printf("finish");

        tcsetattr(fd,TCSANOW,&oldtio);
        /*
            restore serial device settings
        */
      return EXIT_SUCCESS;
    }

     

    As you can see the <termios> library that comes with Linux handles the whole serial connection stuff. For a far more detailed insight you should have a look at

    http://tldp.org/HOWTO/Serial-HOWTO.html

    http://tldp.org/HOWTO/Serial-Programming-HOWTO/

     

    These papers really helped me to understand whats going on and how to handle the whole connection.Hope that helps...

    Cheers,
    Maik

  • Just 2 cents to add:

    I was a bit disappointed when I noticed that only the Receive/Tranceive Pins are connected to the board ?! What about the other pins for flow control and so on?
    Serial Connections seem to sneak away step by step [:D]

  • Sorry to post this on OMAP forum, but I think this may be related to Davinci more closely than we could imagine! Well I can write from serial port and read from serial port using Ubuntu Linux. I  was successful. It sends and reads prints valid results (printf statement with DGB and ERR for debugging). I changed "gcc" in the make file to "arm_v5t_le-gcc" to port the same code on dm6446. Now I expected to see same behaviour. whenever I send data it does what it did on Ubuntu and when it read/ recieves data I do get "0" on being successful read and "-1" when no character recieved so I am sure dm6446 is reading but I fail to understand why would it not echo any read character onto the screen which it does on ubuntu. In my boot parameters "bootarg" I have set console to serial port but my program overrides it and I have verified the same. Also since I have a static IP hence I am using SSH as I don't need to reenter bootargs each time I start evm. Any aspect I override you think could be affecting this behaviour.

  • Hi Maik,

     

    I have the same requirements where I have to configure UART3 so that I can send data from a terminal emulator like teraterm and display it on the omap3evm lcd display. Basically, UART3 should act like a keyboard port. Should I have to configure the kernel to accomplish this? I am using OpenEmbedded with kernel version 2.6.32. Any help would be appreciated.

     

    Thanks,

    Krishnan.