Results 1 to 3 of 3

Thread: Problem with serial port program

  1. #1
    Join Date
    Feb 2011
    Location
    Great White North
    Beans
    128
    Distro
    Kubuntu 11.10 Oneiric Ocelot

    Problem with serial port program

    Hi, right now I am new to Ubuntu so I can't solve this issue by myself.

    I wrote a program in C that would communicate data between two computers, and have an issue with the program. Whenever I sent text from one computer to the other, the recieving computer would send it back to the transmitting computer even though I didn't specify it. Here's the code that is involved with receiving.

    Code:
    //First part
    file=fopen("/dev/ttyS0","r");
    // Some Error checking code
    
    while (1==1)
    	{
    		while(fgets(test, sizeof(test), file)!=NULL);
    		{
    		fputs(test, stdout);
    		}
            }
    Last edited by alegomaster; March 2nd, 2011 at 12:35 AM.

  2. #2
    Join Date
    Apr 2006
    Location
    Atlanta, USA
    Beans
    427

    Re: Problem with serial port program

    You probably need to:

    1. retrieve the current tty settings with tcgetattr
    2. mask out the appropriate ECHO flags
    3. update the tty settings with tcsetattr

    check the man pages (man tcsetattr) to get started.

    Hope this helps.
    Here we are, trapped in the amber of the moment. There is no why.

  3. #3
    Join Date
    Feb 2011
    Location
    Great White North
    Beans
    128
    Distro
    Kubuntu 11.10 Oneiric Ocelot

    Re: Problem with serial port program

    Quote Originally Posted by johnl View Post
    You probably need to:

    1. retrieve the current tty settings with tcgetattr
    2. mask out the appropriate ECHO flags
    3. update the tty settings with tcsetattr

    check the man pages (man tcsetattr) to get started.

    Hope this helps.


    Right now I have issues with figuring out which flag does the ECHO. Can anybody help.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •