/* PL155-P control */ #include /* Standard input/output definitions */ #include /* String function definitions */ #include /* UNIX standard function definitions */ #include /* File control definitions */ #include /* Error number definitions */ #include /* POSIX terminal control definitions */ #define Wsize 32 int fd; unsigned char Word[Wsize]; int InitPort(void) { struct termios options; fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { fputs("Unable to open port\n", stdout); return 0; } else { tcgetattr(fd, &options); cfsetispeed(&options, B9600); /* Set the input baud rate */ cfsetospeed(&options, B9600); /* Set the output baud rate */ options.c_cflag |= (CLOCAL | CREAD); /* Enable receiver, set local */ options.c_cflag &= ~PARENB; /* Clear parity enable */ options.c_cflag &= ~CSTOPB; /* Remove 2nd stop bit */ options.c_cflag &= ~CSIZE; /* Clear data length */ options.c_cflag |= CS8; /* Character size = 8 bits */ options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /* RAW input */ options.c_oflag &= ~OPOST; /* RAW output */ options.c_cflag &= ~CRTSCTS; /* Disable hardware flow control */ tcsetattr(fd, TCSANOW, &options); /* set attributes immediately */; return 1; } } void WritePort(char Command[]) { char *BufPtr; int i; BufPtr = Command; for (i=0; i