- 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->sp_data, config);
- sp_free_config(config);
-
- switch (ret) {
- case SP_ERR_ARG:
- sr_err("Invalid arguments for setting serial port parameters.");
- return SR_ERR_ARG;
- case SP_ERR_FAIL:
- error = sp_last_error_message();
- sr_err("Error setting serial port parameters (%d): %s.",
- sp_last_error_code(), error);
- sp_free_error_message(error);
- return SR_ERR;
- }
-
- serial->comm_params.bit_rate = baudrate;
- serial->comm_params.data_bits = bits;
- serial->comm_params.parity_bits = parity ? 1 : 0;
- serial->comm_params.stop_bits = stopbits;
- sr_dbg("DBG: %s() rate %d, %d%s%d", __func__,
- baudrate, bits,
- (parity == 0) ? "n" : "x",
- stopbits);