modbus: stop bits can now be set individually in client mode
Added the stop_bits_client parameter to the modbus_serial_param struct. Being able to configure the number of stop bits for the client independently from the parity setting, allows to support connecting to modbus server that do not follow the MODBUS over Serial Line Specification and Implementation Guide. Signed-off-by: Constantin Krischke <constantin.krischke@lemonbeat.com> Signed-off-by: Jan Geldmacher <jan.geldmacher@lemonbeat.com>
This commit is contained in:
parent
0d9c1c2516
commit
8ee675946c
5 changed files with 31 additions and 2 deletions
|
@ -547,6 +547,20 @@ int modbus_serial_init(struct modbus_context *ctx,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ctx->client) {
|
||||
/* Allow custom stop bit settings only in client mode */
|
||||
switch (param.serial.stop_bits_client) {
|
||||
case UART_CFG_STOP_BITS_0_5:
|
||||
case UART_CFG_STOP_BITS_1:
|
||||
case UART_CFG_STOP_BITS_1_5:
|
||||
case UART_CFG_STOP_BITS_2:
|
||||
uart_cfg.stop_bits = param.serial.stop_bits_client;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (uart_configure(cfg->dev, &uart_cfg) != 0) {
|
||||
LOG_ERR("Failed to configure UART");
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue