All pastes #364104 Raw Edit

cruiseoveride

public c v1 · immutable
#364104 ·published 2007-02-19 22:46 UTC
rendered paste body
    #include <stdio.h>   /* Standard input/output definitions */    #include <string.h>  /* String function definitions */    #include <unistd.h>  /* UNIX standard function definitions */    #include <fcntl.h>   /* File control definitions */    #include <errno.h>   /* Error number definitions */    #include <termios.h> /* POSIX terminal control definitions */int main(int argc, char **argv){        int fd;        struct termios options;        fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);        if (fd == -1)perror("open_port: Unable to open /dev/ttyUSB0 - "); fcntl(fd, F_SETFL, 0);         /* get the current options */        tcgetattr(fd, &options);        options.c_cflag &= ~PARENB        options.c_cflag &= ~CSTOPB        options.c_cflag &= ~CSIZE;        options.c_cflag |= CS8;         /* set the options */        tcsetattr(fd, TCSANOW, &options);        close(fd);        return 0;}~