I'm trying to write a program to talk to a serial port (eventually to=20 talk to an embedded device but for now i'm using a null modem cable=20 hooked up to a windows PC running putty). The program was initially=20 written in pascal but I translated it to C both to check if the problem=20 was a bug in the fpc run time library and to make it easier to get=20 assistance with it. The word test is sent sucessfully to the machine running putty but=20 nothing is received. This issue happens with both the pascal and C=20 versions of the code. Anyone familiar with termios able to tell me where=20 i'm going wrong? i'm pretty sure the hardware is ok because I have tested it using minicom. pascal version program gateway; uses baseunix, unix, unixutil, termio; // despite the name the fpc termio unit seems to be an=20 interface to termios var device: string; fd : longint; config : termios; count : longint; buf : array[0..1023] of byte; begin device :=3D paramstr(1); fd :=3D fpopen(device,O_RDWR or O_NOCTTY); writeln(fd); if isatty(fd)=3D0 then begin writeln('not a tty'); halt(1); end; if tcgetattr(fd,config) <0 then begin writeln('could not get termios attributes'); halt(2); end; config.c_iflag :=3D 0; config.c_oflag :=3D 0; config.c_cflag :=3D 0; config.c_lflag :=3D 0; cfmakeraw(config); cfsetispeed(config,B19200); cfsetospeed(config,B19200); config.c_cc[VMIN] :=3D 1; config.c_cc[VTIME] :=3D 0; if tcsetattr(fd,TCSAFLUSH,config) <0 then begin writeln('could not set termios attributes'); halt(3); end; fpwrite(fd,'test'#13#10,6); while true do begin writeln(fd); count :=3D fpread(fd,buf,sizeof(buf)); writeln(count); fpwrite(fd,buf,count); // writeln(count); end; fpclose(fd); end. C version #include #include #include #include #include int main(int argc, char *argv[]) { struct termios config; char * device; int fd; char buf[1024]; int count; device =3D argv[1]; fd =3D open(device,O_RDWR | O_NOCTTY); printf("%i\n",fd); if (!isatty(fd)) { printf("not a tty\n"); return 1; } if (tcgetattr(fd,&config) <0) { printf("could not get termios attributes\n"); return 2; } config.c_iflag =3D 0; config.c_oflag =3D 0; config.c_cflag =3D 0; config.c_lflag =3D 0; cfmakeraw(&config); cfsetispeed(&config,B19200); cfsetospeed(&config,B19200); config.c_cc[VMIN] =3D 1; config.c_cc[VTIME] =3D 0; if (tcsetattr(fd,TCSAFLUSH,&config) <0) { printf("could not set termios attributes\n"); return 3; } write(fd,"test\r\n",6); while (1) { printf("%i\n",fd); count =3D read(fd,&buf,sizeof(buf)); printf("%i\n",count); write(fd,&buf,count); // writeln(count); } close(fd); return 0; } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .