Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!texsun!convex!smu!radigan From: radigan@smu Newsgroups: comp.unix.wizards Subject: Through nfpipe Message-ID: <54900001@smu> Date: Sat, 26-Sep-87 22:08:00 EDT Article-I.D.: smu.54900001 Posted: Sat Sep 26 22:08:00 1987 Date-Received: Thu, 1-Oct-87 05:21:14 EDT Lines: 72 Nf-ID: #N:smu:54900001:000:1823 Nf-From: smu!radigan Sep 26 21:08:00 1987 HELP HELP HELP The following program uses a null modem between 2 rs232 ports on a Sun 3.. All I want to do is send charaters at a time but this does not work The second write read will show that the second char written is in wbuff[1] rather than wbuff[0]. I am in raw mode and there is no buffering ? If I open and close fd1 and fd2 in between all is OK FOR 64 dollars .. do you see anything wrong here ? P.S I have several other versions that instantly crash a sun 3 ... its fun to watch for the whole family #include "/usr/include/sys/file.h" #include "/usr/include/sys/ioctl.h" #include struct sgttyb my_parms1, tmp_parms1, my_parms2, tmp_parms2; void set_raw(fd) { ioctl(fd,TIOCGETP, &my_parms1); my_parms1.sg_flags |= RAW; my_parms1.sg_flags |= LITOUT; my_parms1.sg_flags |= FLUSHO; my_parms1.sg_flags |= ~ECHO; ioctl(fd,TIOCSETP, &my_parms1); } main() { int f = O_RDWR ,m= 0777; unsigned char buff[20]; char *n1 = "/dev/ttya" ,*n2 = "/dev/ttyb"; char c; int fd1,fd2,i; extern int errno; char wbuff[128]; int cc; if((fd1 = open(n1,f,m)) == -1){ return; } else{ set_raw(fd1); } if( (fd2 = open(n2,f,m)) == -1){ return; } else{ set_raw(fd2); } buff[0] = 0xFF; if ( write(fd1,buff,1 ) == 0){ return; } if( (cc = read(fd2,buff,1)) == 0){ return; } printf("\n read 1 --->%x<<< \n", buff[0]); printf(" %d\n",ioctl(fd1,TIOCFLUSH,0)); wbuff[0] = 7; if ( write(fd2,wbuff,1 ) == 0){ return; } if( (cc = read(fd1,wbuff,1)) == 0){ return; } printf("\n read 2--------->%x %x %x %x<----\n",wbuff[0],wbuff[1],wbuff[2],wbuff[3]); exit(0); }