Serial stuff

thielen at uwovax.uwo.ca thielen at uwovax.uwo.ca
Thu Feb 21 01:42:34 AEST 1991


I have been having a bunch of trouble reading the output
from a very simple voice activator box attached to a
serial line on my Sun 3/50. Now, I think I am just completely
off base, but can't really fathom what else I should do.
The code I am using is the following... and the program
just sits in the fread command and never gets out of it.

Any Ideas???

The code is here.. /* It's pretty simple stuff */

#include <stdio.h> 
#include <fcntl.h> 
#include <sys/termios.h> 
#define TRUE 1
#define FALSE 0 
int size = 1; 
int nitems = 1; 
FILE *stream; 
char    *buf; 
char   input[10]; 
main() 
{ 
if ((stream = fopen("/dev/ttya", "r")) == NULL){        
    printf("cannot open serial port \n");         
    exit(0); 
}      
setbuffer(stream,buf, size); 
fread( input, size, nitems, stream);
fprintf("\nread character input %s", input); 
fclose(stream); 
} 

Any, suggestions, flames, whining would be greatly appreciated.


Susan KJ Thielen
Centre for Cognitive Science
UWO



More information about the Comp.lang.c mailing list