#include #include #include #include #include #include #include int main(int argc, char** argv) { int fd, readfd; int icount=100; struct termios TS; char buff[1024]; int buffsize; if(argc < 3){ printf("Error, usage: "); printf(argv[0]); printf(" /dev/serXX file-to-read\n"); return -1; } fd = open(argv[1], O_RDWR); if(fd == -1){ printf("Open failed on "); printf(argv[1]); printf("\n"); return -1; } tcgetattr(fd , &TS); cfsetispeed(&TS, 115200); cfsetospeed(&TS, 115200); TS.c_cflag = CS8 | CLOCAL | CREAD; TS.c_iflag = IGNBRK | IGNCR | IGNPAR; tcsetattr(fd, TCSANOW, &TS); readfd = open(argv[2], O_RDONLY); if(readfd == -1){ printf("Open failed on "); printf(argv[2]); printf("\n"); return -1; } while(--icount > 0){ buffsize=read(readfd, buff, sizeof(buff)); if(buffsize ==0 || buffsize == -1) return 1; write(fd, buff, buffsize); fsync(fd); } printf("Done "); close(fd); printf("Exiting"); return 1; }