LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-11-2009, 12:18 AM   #1
mrsq
LQ Newbie
 
Registered: Aug 2009
Posts: 4

Rep: Reputation: 0
read on pty files is not hapenning!


i have 2 pty devices (/dev/ptya0 -master & /dev/ttya0 -slave). i am able to open both devices. Both devices file descriptor is same. i am writing to master pty but while reading from the slave its not reading.

Sample code:
Master:

int serialDev,i;
char ch = 'M';

serialDev = open("/dev/ptyp9",O_RDWR|O_NOCTTY);
while(1)
{
i = write(serialDev,&ch,1);
printf("i= %d\n",i);
}

Slave:
int fd,i;
char ch;

fd = open("/dev/ttyp9",O_RDWR);
printf("fd= %d\n",fd);

while(1)
{
i = read(fd,&ch,1);
if(ch != 0)
printf("ch= %d\n",ch);
}

Thanks in advance!!!
 
Old 08-11-2009, 05:58 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Maybe some error handling will help. serialDev and/or fd might be '-1'. You can add a perror() when an error is encountered.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vpn poptop - CTRL: PTY read or GRE write failed (pty,gre)=(5,6) dezeque Linux - Networking 9 08-26-2016 11:39 AM
Trouble with making a bash script to read in different files and rename output files. rystke Linux - Software 1 05-07-2009 09:00 AM
Shell programming: Question about source files and read data from the files ccwq Programming 3 08-05-2007 01:13 AM
mozzla problems-can not read files online, can not read attachments sarajevo Linux - Software 1 09-20-2005 07:58 PM
How program to read files with extension .dat y .cfg files COMTRADE in fedora 1? ivonne Linux - Software 0 11-22-2004 12:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration