X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=serialport.c;h=6a6e305bb2988ecc20d421b9a1f1b576f33dd2b4;hb=9069c2fbb2f4b9f07e1bf9729e61044c65e09027;hp=418d48bfbe2d8596dd56d57b5337dd837cde2fc3;hpb=9cb98459a847c667d3a14677c8c57a54048e9e16;p=libserialport.git diff --git a/serialport.c b/serialport.c index 418d48b..6a6e305 100644 --- a/serialport.c +++ b/serialport.c @@ -961,6 +961,24 @@ int sp_set_config(struct sp_port *port, struct sp_port_config *config) return SP_OK; } +#define CREATE_SETTER(x) int sp_set_##x(struct sp_port *port, int x) { \ + struct sp_port_data data; \ + TRY(start_config(port, &data)); \ + TRY(set_##x(&data, x)); \ + TRY(apply_config(port, &data)); \ + return SP_OK; \ +} + +CREATE_SETTER(baudrate) +CREATE_SETTER(bits) +CREATE_SETTER(parity) +CREATE_SETTER(stopbits) +CREATE_SETTER(rts) +CREATE_SETTER(cts) +CREATE_SETTER(dtr) +CREATE_SETTER(dsr) +CREATE_SETTER(xon_xoff) + int sp_last_error_code(void) { #ifdef _WIN32