bit_read_message
— Bit Read Modbus Messages¶
API Documentation¶
Bit Reading Request/Response messages¶
-
class
pymodbus.bit_read_message.
ReadBitsRequestBase
(address, count, **kwargs)¶ Base class for Messages Requesting bit values
-
__init__
(address, count, **kwargs)¶ Initializes the read request data
Parameters: - address – The start address to read from
- count – The number of bits after ‘address’ to read
-
__str__
()¶ Returns a string representation of the instance
Returns: A string representation of the instance
-
decode
(data)¶ Decodes a request pdu
Parameters: data – The packet data to decode
-
encode
()¶ Encodes a request pdu
Returns: The encoded pdu
-
get_response_pdu_size
()¶ Func_code (1 byte) + Byte Count(1 byte) + Quantity of Coils (n Bytes)/8, if the remainder is different of 0 then N = N+1 :return:
-
-
class
pymodbus.bit_read_message.
ReadBitsResponseBase
(values, **kwargs)¶ Base class for Messages responding to bit-reading values
-
__init__
(values, **kwargs)¶ Initializes a new instance
Parameters: values – The requested values to be returned
-
__str__
()¶ Returns a string representation of the instance
Returns: A string representation of the instance
-
decode
(data)¶ Decodes response pdu
Parameters: data – The packet data to decode
-
encode
()¶ Encodes response pdu
Returns: The encoded packet message
-
getBit
(address)¶ Helper function to get the specified bit’s value
Parameters: address – The bit to query Returns: The value of the requested bit
-
resetBit
(address)¶ Helper function to set the specified bit to 0
Parameters: address – The bit to reset
-
setBit
(address, value=1)¶ Helper function to set the specified bit
Parameters: - address – The bit to set
- value – The value to set the bit to
-
-
class
pymodbus.bit_read_message.
ReadCoilsRequest
(address=None, count=None, **kwargs)¶ This function code is used to read from 1 to 2000(0x7d0) contiguous status of coils in a remote device. The Request PDU specifies the starting address, ie the address of the first coil specified, and the number of coils. In the PDU Coils are addressed starting at zero. Therefore coils numbered 1-16 are addressed as 0-15.
-
__init__
(address=None, count=None, **kwargs)¶ Initializes a new instance
Parameters: - address – The address to start reading from
- count – The number of bits to read
-
execute
(context)¶ Run a read coils request against a datastore
Before running the request, we make sure that the request is in the max valid range (0x001-0x7d0). Next we make sure that the request is valid against the current datastore.
Parameters: context – The datastore to request from Returns: The initializes response message, exception message otherwise
-
-
class
pymodbus.bit_read_message.
ReadCoilsResponse
(values=None, **kwargs)¶ The coils in the response message are packed as one coil per bit of the data field. Status is indicated as 1= ON and 0= OFF. The LSB of the first data byte contains the output addressed in the query. The other coils follow toward the high order end of this byte, and from low order to high order in subsequent bytes.
If the returned output quantity is not a multiple of eight, the remaining bits in the final data byte will be padded with zeros (toward the high order end of the byte). The Byte Count field specifies the quantity of complete bytes of data.
-
__init__
(values=None, **kwargs)¶ Intializes a new instance
Parameters: values – The request values to respond with
-
-
class
pymodbus.bit_read_message.
ReadDiscreteInputsRequest
(address=None, count=None, **kwargs)¶ This function code is used to read from 1 to 2000(0x7d0) contiguous status of discrete inputs in a remote device. The Request PDU specifies the starting address, ie the address of the first input specified, and the number of inputs. In the PDU Discrete Inputs are addressed starting at zero. Therefore Discrete inputs numbered 1-16 are addressed as 0-15.
-
__init__
(address=None, count=None, **kwargs)¶ Intializes a new instance
Parameters: - address – The address to start reading from
- count – The number of bits to read
-
execute
(context)¶ Run a read discrete input request against a datastore
Before running the request, we make sure that the request is in the max valid range (0x001-0x7d0). Next we make sure that the request is valid against the current datastore.
Parameters: context – The datastore to request from Returns: The initializes response message, exception message otherwise
-
-
class
pymodbus.bit_read_message.
ReadDiscreteInputsResponse
(values=None, **kwargs)¶ The discrete inputs in the response message are packed as one input per bit of the data field. Status is indicated as 1= ON; 0= OFF. The LSB of the first data byte contains the input addressed in the query. The other inputs follow toward the high order end of this byte, and from low order to high order in subsequent bytes.
If the returned input quantity is not a multiple of eight, the remaining bits in the final data byte will be padded with zeros (toward the high order end of the byte). The Byte Count field specifies the quantity of complete bytes of data.
-
__init__
(values=None, **kwargs)¶ Intializes a new instance
Parameters: values – The request values to respond with
-