Module author: Galen Collins <bashwork@gmail.com>
Section author: Galen Collins <bashwork@gmail.com>
Base class for Messages Requesting bit values
Decodes a request pdu
Parameters: | data – The packet data to decode |
---|
Encodes a request pdu
Returns: | The encoded pdu |
---|
Base class for Messages responding to bit-reading values
Decodes response pdu
Parameters: | data – The packet data to decode |
---|
Encodes response pdu
Returns: | The encoded packet message |
---|
Helper function to get the specified bit’s value
Parameters: | address – The bit to query |
---|---|
Returns: | The value of the requested bit |
Helper function to set the specified bit to 0
Parameters: | address – The bit to reset |
---|
Helper function to set the specified bit
Parameters: |
|
---|
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.
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 |
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.
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.
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 |
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.