Use new libserialport opaque configuration structure.

This commit is contained in:
Martin Ling 2013-11-23 21:00:28 +00:00 committed by Uwe Hermann
parent 3182932d36
commit 25b66c3c61
1 changed files with 15 additions and 13 deletions

View File

@ -286,7 +286,7 @@ SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial, int baudrate,
{ {
int ret; int ret;
char *error; char *error;
struct sp_port_config config; struct sp_port_config *config;
if (!serial) { if (!serial) {
sr_dbg("Invalid serial port."); 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, sr_spew("Setting serial parameters on port %s (fd %d).", serial->port,
serial->fd); serial->fd);
config.baudrate = baudrate; sp_new_config(&config);
config.bits = bits; sp_set_config_baudrate(config, baudrate);
sp_set_config_bits(config, bits);
switch (parity) { switch (parity) {
case 0: case 0:
config.parity = SP_PARITY_NONE; sp_set_config_parity(config, SP_PARITY_NONE);
break; break;
case 1: case 1:
config.parity = SP_PARITY_EVEN; sp_set_config_parity(config, SP_PARITY_EVEN);
break; break;
case 2: case 2:
config.parity = SP_PARITY_ODD; sp_set_config_parity(config, SP_PARITY_ODD);
break; break;
default: default:
return SR_ERR_ARG; return SR_ERR_ARG;
} }
config.stopbits = stopbits; sp_set_config_stopbits(config, stopbits);
config.rts = flowcontrol == 1 ? SP_RTS_FLOW_CONTROL : rts; sp_set_config_rts(config, flowcontrol == 1 ? SP_RTS_FLOW_CONTROL : rts);
config.cts = flowcontrol == 1 ? SP_CTS_FLOW_CONTROL : SP_CTS_IGNORE; sp_set_config_cts(config, flowcontrol == 1 ? SP_CTS_FLOW_CONTROL : SP_CTS_IGNORE);
config.dtr = dtr; sp_set_config_dtr(config, dtr);
config.dsr = SP_DSR_IGNORE; sp_set_config_dsr(config, SP_DSR_IGNORE);
config.xon_xoff = flowcontrol == 2 ? SP_XONXOFF_INOUT : SP_XONXOFF_DISABLED; sp_set_config_xon_xoff(config, flowcontrol == 2 ? SP_XONXOFF_INOUT : SP_XONXOFF_DISABLED);
ret = sp_set_config(serial->data, &config); ret = sp_set_config(serial->data, config);
sp_free_config(config);
switch (ret) { switch (ret) {
case SP_ERR_ARG: case SP_ERR_ARG: