48 __attribute__((__unused__))
52 struct termios newtermios;
54 if((sn->
Stream = open(Device, O_RDWR | O_NOCTTY | O_NONBLOCK)) <= 0)
55 return "could not open serial port";
58 memset(&newtermios, 0,
sizeof(
struct termios));
59 newtermios.c_cflag = Baud | StopBits | Parity | DataBits
62 newtermios.c_cflag |= CRTSCTS;
64 newtermios.c_cflag |= Protocol;
65 newtermios.c_cc[VMIN] = 1;
66 tcflush(sn->
Stream, TCIOFLUSH);
67 tcsetattr(sn->
Stream, TCSANOW, &newtermios);
68 tcflush(sn->
Stream, TCIOFLUSH);
69 fcntl(sn->
Stream, F_SETFL, O_NONBLOCK);
75 int j = read(sn->
Stream, buffer, size);
88 int j = write(sn->
Stream, buffer, size);
void SerialFree(struct serial *sn)
const char * SerialInit(struct serial *sn, const char *Device, enum SerialBaud Baud, enum SerialStopbits StopBits, enum SerialProtocol Protocol, enum SerialParity Parity, enum SerialDatabits DataBits, int dowrite)
int SerialRead(struct serial *sn, char *buffer, size_t size)
int SerialWrite(struct serial *sn, const char *buffer, size_t size)