Dynamic Modbus Master
A dynamic wrapper for the modbus master part of esp-modbus written in C++.
 
Loading...
Searching...
No Matches
ModbusErrorHelper.h
Go to the documentation of this file.
1//Copyright (c) 2024 Dominik M. Glogowski
2//
3//Permission is hereby granted, free of charge, to any person obtaining a copy
4//of this software and associated documentation files (the "Software"), to deal
5//in the Software without restriction, including without limitation the rights
6//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7//copies of the Software, and to permit persons to whom the Software is
8//furnished to do so, subject to the following conditions:
9//
10//The above copyright notice and this permission notice shall be included in all
11//copies or substantial portions of the Software.
12//
13//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19//SOFTWARE.
20
21#ifndef DYNAMIC_MODBUS_MASTER_MODBUSERRORHELPER_H
22#define DYNAMIC_MODBUS_MASTER_MODBUSERRORHELPER_H
23
24#include <ModbusError.h>
25#include <string>
26
27namespace dynamic_modbus_master{
28
30public:
40[[maybe_unused]] constexpr static std::string modbusErrorToName(const ModbusError error) {
41 switch (error) {
42 case ModbusError::OK:
43 return "OK";
44 break;
46 return "INVALID_ARG";
47 break;
49 return "INVALID_RESPONSE";
50 break;
52 return "ADDRESS_UNAVAILABLE";
53 break;
55 return "SLAVE_NOT_SUPPORTED";
56 break;
58 return "PORT_NOT_SUPPORTED";
59 break;
61 return "INVALID_STATE";
62 break;
64 return "TIMEOUT";
65 break;
67 return "FAILURE";
68 break;
70 return "ILLEGAL FUNCTION";
71 break;
73 return "ILLEGAL DATA ADDRESS";
74 break;
76 return "ILLEGAL DATA VALUE";
77 break;
79 return "SLAVE DEVICE FAILURE";
80 break;
82 return "ACKNOWLEDGE";
83 break;
85 return "SLAVE DEVICE BUSY";
86 break;
88 return "MEMORY PARITY ERROR";
89 break;
91 return "GATEWAY PATH UNAVAILABLE";
92 break;
94 return "GATEWAY TARGET NO RESPONSE";
95 break;
96 }
97 return "Invalid Error";
98 }
99};
100
101} // dynamic_modbus_master
102
103#endif //DYNAMIC_MODBUS_MASTER_MODBUSERRORHELPER_H
Definition ModbusErrorHelper.h:29
static constexpr std::string modbusErrorToName(const ModbusError error)
Converts a ModbusError enum value to its corresponding name.
Definition ModbusErrorHelper.h:40
Definition DynamicModbusMaster.cpp:26
ModbusError
Modbus Error Type Enum.
Definition ModbusError.h:30
@ TIMEOUT
The Driver experienced a timeout.
@ ADDRESS_UNAVAILABLE
This slave address is not available.
@ MEMORY_PARITY_ERROR
The Extended File Area failed to pass a consistency check.
@ ACKNOWLEDGE
The Target accepted the Request but will take some time to complete it, this is returned to prevent a...
@ ILLEGAL_DATA_VALUE
The Data Value received is of an invalid length.
@ GATEWAY_PATH_UNAVAILABLE
No Path was found between the Input and the Output Port of the Gateway, gateway is possibly misconfig...
@ FAILURE
The slave device experienced an undermined failure.
@ INVALID_RESPONSE
The Slave Device Response was invalid.
@ SLAVE_NOT_SUPPORTED
The slave does not support this function.
@ INVALID_STATE
The Modbus Driver or the Device is in an invalid state.
@ INVALID_ARG
A given Argument was invalid.
@ SLAVE_DEVICE_BUSY
The Target is currently busy executing a command, retransmit the command at a later time.
@ ILLEGAL_DATA_ADDRESS
The Data Address received is not available.
@ SLAVE_DEVICE_FAILURE
An Unrecoverable Error occured while trying to perform the request.
@ ILLEGAL_FUNCTION
The received Function code is not available on the target device.
@ OK
Indicates no error has occured.
@ GATEWAY_TARGET_NO_RESPONSE
Gateway Target Device did not respond or does not exist.
@ PORT_NOT_SUPPORTED
This Port is not supported.