Skip to content

Added bit mask and constant for SerialConfig parameter #1625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2016

Conversation

hallard
Copy link
Contributor

@hallard hallard commented Feb 11, 2016

Permit use bit config avoiding test/compare all "hard-coded" values.
example:

if (section & CFG_HLP_MODBUS) {
DebuglnF("\r\n===== Modbus");
DebugF("Speed       : "); Debug(config.modbus.baud);

switch (config.modbus.proto & UART_NB_BIT_MASK) {
  case UART_NB_BIT_5: Debug(" 5"); break;
  case UART_NB_BIT_6: Debug(" 6"); break;
  case UART_NB_BIT_7: Debug(" 7"); break;
  case UART_NB_BIT_8: Debug(" 8"); break;
  default : Debug(" ?"); break;
}
switch (config.modbus.proto & UART_PARITY_MASK) {
  case UART_PARITY_NONE: Debug("N"); break;
  case UART_PARITY_EVEN: Debug("E"); break;
  case UART_PARITY_ODD : Debug("O"); break;
  default : Debug("?"); break;
}
switch (config.modbus.proto & UART_NB_STOP_BIT_MASK) {
  case UART_NB_STOP_BIT_0: Debug("0"); break;
  case UART_NB_STOP_BIT_1: Debug("1"); break;
  case UART_NB_STOP_BIT_15: Debug("15"); break;
  case UART_NB_STOP_BIT_2 : Debug("2"); break;
  default : Debug("?"); break;
}

DebugF("\r\nSlave Addr  : "); Debugln(config.modbus.slave);
DebugF("Holding Reg : 0x"); Debugln2(config.modbus.hr_addr,HEX);
DebugF("Enable Pin  : "); Debugln(config.modbus.en_pin);
}

Permit use bit config avoiding test/compare all "hard-coded" values.
example
```arduino
if (section & CFG_HLP_MODBUS) {
DebuglnF("\r\n===== Modbus");
DebugF("Speed       : "); Debug(config.modbus.baud);

switch (config.modbus.proto & UART_NB_BIT_MASK) {
case UART_NB_BIT_5: Debug(" 5"); break;
case UART_NB_BIT_6: Debug(" 6"); break;
case UART_NB_BIT_7: Debug(" 7"); break;
case UART_NB_BIT_8: Debug(" 8"); break;
default : Debug(" ?"); break;
}
switch (config.modbus.proto & UART_PARITY_MASK) {
case UART_PARITY_NONE: Debug("N"); break;
case UART_PARITY_EVEN: Debug("E"); break;
case UART_PARITY_ODD : Debug("O"); break;
default : Debug("?"); break;
}
switch (config.modbus.proto & UART_NB_STOP_BIT_MASK) {
case UART_NB_STOP_BIT_0: Debug("0"); break;
case UART_NB_STOP_BIT_1: Debug("1"); break;
case UART_NB_STOP_BIT_15: Debug("15"); break;
case UART_NB_STOP_BIT_2 : Debug("2"); break;
default : Debug("?"); break;
}

DebugF("\r\nSlave Addr  : "); Debugln(config.modbus.slave);
DebugF("Holding Reg : 0x"); Debugln2(config.modbus.hr_addr,HEX);
DebugF("Enable Pin  : "); Debugln(config.modbus.en_pin);
}
```
igrr added a commit that referenced this pull request Feb 13, 2016
Added bit mask and constant for SerialConfig parameter
@igrr igrr merged commit 4f5f003 into esp8266:master Feb 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants