/* Temperature logger based on PIC18F4550 */ #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 Rsize 56 #define Half Rsize/2 #define Nchan 13 int fd; unsigned char Word[Rsize]; unsigned char *Wpt; int Count = 0; int InitPort(void) { struct termios options; fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { fputs("Unable to open port\n", stdout); return 0; } else { tcgetattr(fd, &options); cfsetispeed(&options, B57600); /* Set the input baud rate */ cfsetospeed(&options, B57600); /* 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 ReadPort(void) { int i; for (i=0; i