LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   read on pty files is not hapenning! (https://www.linuxquestions.org/questions/linux-newbie-8/read-on-pty-files-is-not-hapenning-746614/)

mrsq 08-10-2009 11:18 PM

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!!!

Wim Sturkenboom 08-11-2009 04:58 AM

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


All times are GMT -5. The time now is 05:35 PM.