37 strcpy(sps->
name, name);
43 printf(
"serialport_open: Unable to open port - \"%s\".\n", sps->
name);
67 printf(
"serialport_close: Unable to close port - \"%s\".\n", sps->
name);
85 struct termios options;
118 printf(
"serialport_config: Invalid baud rate. Baud rate set to 9600.\n");
122 cfsetispeed(&options, baudrate);
123 cfsetospeed(&options, baudrate);
126 options.c_cflag |= (CLOCAL | CREAD);
129 options.c_cflag &= ~PARENB;
130 options.c_cflag &= ~CSTOPB;
131 options.c_cflag &= ~CSIZE;
132 options.c_cflag |= CS8;
147 res = tcsetattr(sps->
descriptor, TCSANOW, &options);
152 printf(
"serialport_config: Could not apply new configuration.\n");
195 return read(sps->
descriptor, &buffer,
sizeof(buffer));
int serialport_flush_input(serialport_t *sps)
serialport_t * serialport_open(const char *name)
int serialport_write(serialport_t *sps, unsigned char *data, unsigned int bytes)
int serialport_config(serialport_t *sps, unsigned int baud)
int serialport_close(serialport_t *sps)
int serialport_byte(serialport_t *sps, unsigned char byte)