Article View: gnu.gcc.help
Article #41585C Character Input over Serial Port
From: Jeff Klein
Date: Wed, 13 Mar 1996 00:00
Date: Wed, 13 Mar 1996 00:00
59 lines
1745 bytes
1745 bytes
I have been trying to read "Character Input" from a serial port from
C on a SUN Sparc (SUN OS 4.1.3), and have gone thru infinite variations
of READ, FGETC, ACONONICAL, NON-CONONICAL, STREAMS, IOCTL's til I cant
see anymore but can only read when a CR is sent (Line Mode).
Any help would be greatly appreciated. Follows my latest attempt:
(JEFF.H) is standard set of includes...
#include "jeff.h"
main(argc, argv)
int argc;
char* argv[];
{
FILE *in;
int out;
int i,c;
char filen[80];
char device[80];
char line[100];
char ch;
/*
strcpy(device,argv[1]);
*/
strcpy(device,"/dev/cuAe");
out=open(device,O_RDWR);
if(out==NULL) {
printf("CANNOT OPEN %s\n",device);
exit(0);
}
else
printf("%s OPEN\n",device);
strcpy(line,"Test Test");
write(out,line,strlen(line));
printf("Test Line Sent!\n");
while(1) {
memset(line,0,sizeof(line));
c=read(out,line,1);
if(c>0) {
printf("%s",line);
if(line[0]==113) break;
}
if(c<0) {
printf("Read Failure errno=%d\n",errno);
perror("");
}
}
printf("\nDone.\n");
exit(0);
}
Technical Details
Message-ID:
<4i7fe9$fka@park.interport.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,9c29a4309b636b58,start X-Google-Attributes: gid11318c,public From: Jeff Klein <klein@intelligentinfo.com> Subject: C Character Input over Serial Port Date: 1996/03/13 Message-ID: <4i7fe9$fka@park.interport.net> X-Deja-AN: 142682781 content-type: text/plain; charset=us-ascii organization: Interport Communications Corp. mime-version: 1.0 newsgroups: gnu.gcc.help x-mailer: Mozilla 1.1N (Windows; I; 16bit)