From: Martin Ling Date: Sat, 23 Nov 2013 21:00:28 +0000 (+0000) Subject: Use new libserialport opaque configuration structure. X-Git-Tag: libsigrok-0.3.0~532 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=25b66c3c61629d2c679d3c1b6dea9e4a0c9f1a1e;p=libsigrok.git Use new libserialport opaque configuration structure. --- diff --git a/hardware/common/serial.c b/hardware/common/serial.c index 7cc81c64..b2515a34 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -286,7 +286,7 @@ SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial, int baudrate, { int ret; char *error; - struct sp_port_config config; + struct sp_port_config *config; if (!serial) { sr_dbg("Invalid serial port."); @@ -302,29 +302,31 @@ SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial, int baudrate, sr_spew("Setting serial parameters on port %s (fd %d).", serial->port, serial->fd); - config.baudrate = baudrate; - config.bits = bits; + sp_new_config(&config); + sp_set_config_baudrate(config, baudrate); + sp_set_config_bits(config, bits); switch (parity) { case 0: - config.parity = SP_PARITY_NONE; + sp_set_config_parity(config, SP_PARITY_NONE); break; case 1: - config.parity = SP_PARITY_EVEN; + sp_set_config_parity(config, SP_PARITY_EVEN); break; case 2: - config.parity = SP_PARITY_ODD; + sp_set_config_parity(config, SP_PARITY_ODD); break; default: return SR_ERR_ARG; } - config.stopbits = stopbits; - config.rts = flowcontrol == 1 ? SP_RTS_FLOW_CONTROL : rts; - config.cts = flowcontrol == 1 ? SP_CTS_FLOW_CONTROL : SP_CTS_IGNORE; - config.dtr = dtr; - config.dsr = SP_DSR_IGNORE; - config.xon_xoff = flowcontrol == 2 ? SP_XONXOFF_INOUT : SP_XONXOFF_DISABLED; - - ret = sp_set_config(serial->data, &config); + sp_set_config_stopbits(config, stopbits); + sp_set_config_rts(config, flowcontrol == 1 ? SP_RTS_FLOW_CONTROL : rts); + sp_set_config_cts(config, flowcontrol == 1 ? SP_CTS_FLOW_CONTROL : SP_CTS_IGNORE); + sp_set_config_dtr(config, dtr); + sp_set_config_dsr(config, SP_DSR_IGNORE); + sp_set_config_xon_xoff(config, flowcontrol == 2 ? SP_XONXOFF_INOUT : SP_XONXOFF_DISABLED); + + ret = sp_set_config(serial->data, config); + sp_free_config(config); switch (ret) { case SP_ERR_ARG: