RS232_LIB unsigned int rs232_set_parity(struct rs232_port_t *p, enum rs232_parity_e parity) { DCB pdcb; struct rs232_windows_t *wx = p->pt; DBG("p=%p p->pt=%p parity=%d (parity %s)\n", (void *)p, p->pt, parity, rs232_strparity(parity)); if (!rs232_port_open(p)) return RS232_ERR_PORT_CLOSED; GET_PORT_STATE(wx->fd, &pdcb); switch (parity) { case RS232_PARITY_NONE: pdcb.Parity = NOPARITY; break; case RS232_PARITY_ODD: pdcb.Parity = ODDPARITY; break; case RS232_PARITY_EVEN: pdcb.Parity = EVENPARITY; break; default: return RS232_ERR_UNKNOWN; } SET_PORT_STATE(wx->fd, &pdcb); p->parity = parity; return RS232_ERR_NOERROR; }
RS232_LIB const char * rs232_to_string(struct rs232_port_t *p) { static char str[RS232_STRLEN+1]; DBG("p=%p\n", (void *)p); if (p == NULL) return NULL; snprintf(str, RS232_STRLEN, "device: %s, baud: %s, data bits: %s," " parity: %s, stop bits: %s," " flow control: %s", p->dev, rs232_strbaud(p->baud), rs232_strdata(p->data), rs232_strparity(p->parity), rs232_strstop(p->stop), rs232_strflow(p->flow)); return str; }