42 #if defined(LIGHTMODBUS_BIG_ENDIAN) && defined(LIGHTMODBUS_LITTLE_ENDIAN) 43 #error LIGHTMODBUS_BIG_ENDIAN and LIGHTMODBUS_LITTLE_ENDIAN cannot be used at once! 146 return n != 0 ? ( 1 + ( ( n - 1 ) >> 3 ) ) : 0;
158 static inline uint16_t
modbusSwapEndian( uint16_t data ) {
return ( data << 8 ) | ( data >> 8 ); }
169 #ifdef LIGHTMODBUS_BIG_ENDIAN 183 extern uint8_t
modbusMaskRead(
const uint8_t *mask, uint16_t maskLength, uint16_t bit );
194 extern uint8_t
modbusMaskWrite( uint8_t *mask, uint16_t maskLength, uint16_t bit, uint8_t value );
203 extern uint16_t
modbusCRC(
const uint8_t *data, uint16_t length );
Index value request-response mismatch.
Definition: lightmodbus.h:107
Input register.
Definition: lightmodbus.h:134
Illegal function code.
Definition: lightmodbus.h:120
static uint16_t modbusBitsToBytes(uint16_t n)
Converts number of bits to number of bytes required to store them.
Definition: lightmodbus.h:144
Data value request-response mismatch.
Definition: lightmodbus.h:109
Modbus frame OK. No error.
Definition: lightmodbus.h:93
Holding register.
Definition: lightmodbus.h:133
General Modbus slave functions.
modbusFrameError
Provides more information on frame building/parsing error.
Definition: lightmodbus.h:91
Invalid frame length.
Definition: lightmodbus.h:95
Memory problem.
Definition: lightmodbus.h:71
A NULL pointer provided as some crucial parameter.
Definition: lightmodbus.h:73
Indicates that slave had thrown an exception.
Definition: lightmodbus.h:64
Frame building error occurred - check ModbusMaster::buildError.
Definition: lightmodbus.h:82
Illegal data value.
Definition: lightmodbus.h:122
Invalid CRC.
Definition: lightmodbus.h:94
Acknowledge.
Definition: lightmodbus.h:124
Function request-response mismatch.
Definition: lightmodbus.h:105
modbusError
Represents a library runtime error code.
Definition: lightmodbus.h:49
uint16_t modbusCRC(const uint8_t *data, uint16_t length)
Calculates 16-bit Modbus CRC of provided data.
Definition: lightmodbus.c:46
Other reason causing the function to abort (eg. bad function parameter)
Definition: lightmodbus.h:72
No write access to one of requested regsiters.
Definition: lightmodbus.h:101
No read access to at least one of requested regsiters.
Definition: lightmodbus.h:100
General Modbus master functions.
uint8_t modbusMaskWrite(uint8_t *mask, uint16_t maskLength, uint16_t bit, uint8_t value)
Writes n-th bit in an array.
Definition: lightmodbus.c:33
enum modbusExceptionCode ModbusExceptionCode
Represents a Modbus exception code, defined by the standart.
enum modbusFrameError ModbusFrameError
Provides more information on frame building/parsing error.
Invalid register range.
Definition: lightmodbus.h:98
Count value request-response mismatch.
Definition: lightmodbus.h:108
Slave address request-response mismatch.
Definition: lightmodbus.h:106
static uint16_t modbusMatchEndian(uint16_t data)
Swaps endianness of provided 16-bit data portion if needed.
Definition: lightmodbus.h:170
Negative acknowledge.
Definition: lightmodbus.h:125
Received response for broadcast message.
Definition: lightmodbus.h:111
Definition: lightmodbus.h:81
modbusExceptionCode
Represents a Modbus exception code, defined by the standart.
Definition: lightmodbus.h:118
Coil.
Definition: lightmodbus.h:135
Slave could not process the request.
Definition: lightmodbus.h:123
No error.
Definition: lightmodbus.h:51
Illegal data address.
Definition: lightmodbus.h:121
modbusDataType
Stores information about Modbus data types.
Definition: lightmodbus.h:131
No error. Alias of MODBUS_ERROR_OK.
Definition: lightmodbus.h:83
Illegal data value (eg. when writing a single coil)
Definition: lightmodbus.h:97
Requested a parsing function to parse a frame with wrong function code.
Definition: lightmodbus.h:103
uint8_t modbusMaskRead(const uint8_t *mask, uint16_t maskLength, uint16_t bit)
Reads n-th bit from an array.
Definition: lightmodbus.c:24
static uint16_t modbusSwapEndian(uint16_t data)
Swaps endianness of provided 16-bit data portion.
Definition: lightmodbus.h:158
Discrete input.
Definition: lightmodbus.h:136
There's neither callback function nor value array provided for this data type.
Definition: lightmodbus.h:99
Invalid declared data item count.
Definition: lightmodbus.h:96
Function not supported.
Definition: lightmodbus.h:102
Mask value request-response mismatch.
Definition: lightmodbus.h:110
Function overriden by user with NULL pointer.
Definition: lightmodbus.h:104
enum modbusDataType ModbusDataType
Stores information about Modbus data types.
enum modbusError ModbusError
Represents a library runtime error code.