/*serin.c*/
#include <fcntl.h>
#include <sys/termios.h>
#include<sys/errno.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include <sys/types.h>
#include <sys/stat.h>


main()

    {
    int myfd=0;
    int n;
    char c[81];
    struct termios options;

    myfd=open_port();
    fcntl(myfd,F_SETFL,FNDELAY);
    tcgetattr(myfd, &options);
    cfsetispeed(&options,B9600);
    cfsetospeed(&options,B9600);
    tcsetattr(myfd,TCSANOW,&options);
    while ((n=read(myfd,c,80))!=0)
        if ((c[0]=='Z')&&(n==2))
            close(myfd);
        else
            if (n!=-1)
                puts(c);
    }

int open_port(void)

    {
    int fd;

    fd=open("/dev/ttyC1",O_RDWR | O_NOCTTY | O_NDELAY);
    if (fd==-1)
        fprintf(stderr, "open_port unable to open /dev/ttyC1 -%s\n",
                strerror(errno));
    return (fd);
    }

