Replace sp_set_params with sp_set_config, which takes a struct.
This commit is contained in:
parent
728f6de510
commit
d1202734fb
|
@ -52,6 +52,17 @@ struct sp_port {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Configuration for a serial port. */
|
||||||
|
struct sp_port_config {
|
||||||
|
int baudrate;
|
||||||
|
int bits;
|
||||||
|
int parity;
|
||||||
|
int stopbits;
|
||||||
|
int flowcontrol;
|
||||||
|
int rts;
|
||||||
|
int dtr;
|
||||||
|
};
|
||||||
|
|
||||||
/* Return values. */
|
/* Return values. */
|
||||||
enum {
|
enum {
|
||||||
/* Operation completed successfully. */
|
/* Operation completed successfully. */
|
||||||
|
@ -104,8 +115,7 @@ int sp_close(struct sp_port *port);
|
||||||
int sp_flush(struct sp_port *port);
|
int sp_flush(struct sp_port *port);
|
||||||
int sp_write(struct sp_port *port, const void *buf, size_t count);
|
int sp_write(struct sp_port *port, const void *buf, size_t count);
|
||||||
int sp_read(struct sp_port *port, void *buf, size_t count);
|
int sp_read(struct sp_port *port, void *buf, size_t count);
|
||||||
int sp_set_params(struct sp_port *port, int baudrate, int bits, int parity,
|
int sp_set_config(struct sp_port *port, struct sp_port_config *config);
|
||||||
int stopbits, int flowcontrol, int rts, int dtr);
|
|
||||||
int sp_last_error_code(void);
|
int sp_last_error_code(void);
|
||||||
char *sp_last_error_message(void);
|
char *sp_last_error_message(void);
|
||||||
void sp_free_error_message(char *message);
|
void sp_free_error_message(char *message);
|
||||||
|
|
17
serialport.c
17
serialport.c
|
@ -821,19 +821,18 @@ static int apply_config(struct sp_port *port, struct sp_port_data *data)
|
||||||
|
|
||||||
#define TRY(x) do { int ret = x; if (ret != SP_OK) return ret; } while (0)
|
#define TRY(x) do { int ret = x; if (ret != SP_OK) return ret; } while (0)
|
||||||
|
|
||||||
int sp_set_params(struct sp_port *port, int baudrate, int bits, int parity,
|
int sp_set_config(struct sp_port *port, struct sp_port_config *config)
|
||||||
int stopbits, int flowcontrol, int rts, int dtr)
|
|
||||||
{
|
{
|
||||||
struct sp_port_data data;
|
struct sp_port_data data;
|
||||||
|
|
||||||
TRY(start_config(port, &data));
|
TRY(start_config(port, &data));
|
||||||
TRY(set_baudrate(&data, baudrate));
|
TRY(set_baudrate(&data, config->baudrate));
|
||||||
TRY(set_bits(&data, bits));
|
TRY(set_bits(&data, config->bits));
|
||||||
TRY(set_parity(&data, parity));
|
TRY(set_parity(&data, config->parity));
|
||||||
TRY(set_stopbits(&data, stopbits));
|
TRY(set_stopbits(&data, config->stopbits));
|
||||||
TRY(set_flowcontrol(&data, flowcontrol));
|
TRY(set_flowcontrol(&data, config->flowcontrol));
|
||||||
TRY(set_rts(&data, rts));
|
TRY(set_rts(&data, config->rts));
|
||||||
TRY(set_dtr(&data, dtr));
|
TRY(set_dtr(&data, config->dtr));
|
||||||
TRY(apply_config(port, &data));
|
TRY(apply_config(port, &data));
|
||||||
|
|
||||||
return SP_OK;
|
return SP_OK;
|
||||||
|
|
Loading…
Reference in New Issue