[LCP]reg serial communication in linux.

Andrew Weaver Andrew.Weaver at tecnomen.fi
Tue Oct 14 18:35:02 UTC 2003


On Tuesday, October 14, 2003 12:19 PM, sowmya.k [SMTP:sowmi99 at yahoo.com]
wrote:
> I had connected 2 systems using null modem
> cable(RS232). 
> My problem comes in the reading part.
> My coding goes this way.
>    First I had opened my tty (i.e my terminal screen
> and keyboard)
>    Then I set some parameters to it.
>    Third I opened my port and finished all my
> settings.
>    Fourth I started to write and read datas from the
> port.
>    Atlast I closed everything.
>  Let me give the code I used to read and write
> 
> 
> To write datas to the port
>   
>      while (STOP==FALSE)   //STOP is defined to be
> TRUE
>       {
>          status = fread(&Key,1,1,input);
>          if (status==1)  //if a key was hit
>          {
>              fputc((int) Key,output);
>              write(fd,&Key,1);          //write 1 byte
> to the port
>            }      
>        }
> 
> 
> 
> To read from the port
> 
>          if (wait_flag==FALSE)  //if input is
> available
>          {
>             res = read(fd,buf,255);
>             if (res)
>             {
>                for (i=0; i<res; i++)  //for all chars
> in string
>                {
>                   In1 = buf[i];
>                   printf(message,"%c ",In1);
>                         fputs(message,output);
>                       }
>                    }
>             wait_flag = TRUE;      /* wait for new
> input */
>          }  //end if wait flag == FALSE
> 
>       }  //while stop==FALSE
>       
> 
> Thanking you
> 
> sowmya
> 
So... what is the problem that you are getting?




> __________________________________
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
> _______________________________________________
> This is the Linux C Programming List
> :  http://lists.linux.org.au/listinfo/linuxcprogramming List



More information about the linuxCprogramming mailing list