/*serout.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;
    struct termios options;

    myfd=open_port();
    tcgetattr(myfd, &options);
    cfsetispeed(&options,B9600);
    cfsetospeed(&options,B9600);
    tcsetattr(myfd,TCSANOW,&options);
    while ((c=getchar())!='Z')
        if ((n=(write(myfd,&c,1)))<0)
            printf("write failed:n=%d\n",n);
    close(myfd);
    }

int open_port(void)

    {
    int fd;

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

