8. Error response generator
| 651 | |
| 652 | // 8. Error response generator |
| 653 | Error ModbusMessage::setError(uint8_t serverID, uint8_t functionCode, Error errorCode) { |
| 654 | // No error checking for server ID or function code here, as both may be the cause for the message!? |
| 655 | MM_data.reserve(3); |
| 656 | MM_data.shrink_to_fit(); |
| 657 | MM_data.clear(); |
| 658 | add(serverID, static_cast<uint8_t>((functionCode | 0x80) & 0xFF), static_cast<uint8_t>(errorCode)); |
| 659 | return SUCCESS; |
| 660 | } |
| 661 | |
| 662 | // Error output in case a message constructor will fail |
| 663 | void ModbusMessage::printError(const char *file, int lineNo, Error e, uint8_t serverID, uint8_t functionCode) { |