Skip to content

Conversation

@dhoomakethu
Copy link
Contributor

Fixes #84 , #135, #139, #233, #107, #190

rahul and others added 30 commits November 20, 2017 10:28
- The issue listed was due to wrong messages being passed by the user.
Upon passing the right messages codes, the parser works as expected
on all counts.

- There is also changes that make the parser compatible with python2
and python3

- Verifier that the tool works on both python3 and python2 for all
MODBUS message codes on TCP, RTU, and BIN
we take the unit address as the second incoming bite as opposed
to the first bite.
This is was done while fixing the message parsers for binary messages
According to the docs:
    Modbus Binary Frame Controller::

        [ Start ][Address ][ Function ][ Data ][ CRC ][ End ]
          1b        1b         1b         Nb     2b     1b
This switch is meant to be used when we wish to parse messages directly
from the logs of Modbus.
The format of a message as shown in the logs is like bellow:
        0x7b 0x1 0x5 0x0 0x0 0xff 0x0 0x8c 0x3a 0x7d
We can pass this as the message to the parser along with the -t witch
to convert it into a compatible message to be parsed.
EG:

(modbus3) [~/pymodbus/examples/contrib]$ ./message-parser.py -b -t -p binary -m "0x7b 0x1 0x5 0x0 0x0 0xff 0x0 0x8c 0x3a 0x7d"
================================================================================
Decoding Message b'7b01050000ff008c3a7d'
================================================================================
ServerDecoder
--------------------------------------------------------------------------------
name            = WriteSingleCoilRequest
transaction_id  = 0x0
protocol_id     = 0x0
unit_id         =
                . [1]
skip_encode     = 0x0
check           = 0x0
address         = 0x0
value           = 0x1
documentation   =
    This function code is used to write a single output to either ON or OFF
    in a remote device.

    The requested ON/OFF state is specified by a constant in the request
    data field. A value of FF 00 hex requests the output to be ON. A value
    of 00 00 requests it to be OFF. All other values are illegal and will
    not affect the output.

    The Request PDU specifies the address of the coil to be forced. Coils
    are addressed starting at zero. Therefore coil numbered 1 is addressed
    as 0. The requested ON/OFF state is specified by a constant in the Coil
    Value field. A value of 0XFF00 requests the coil to be ON. A value of
    0X0000 requests the coil to be off. All other values are illegal and
    will not affect the coil.

ClientDecoder
--------------------------------------------------------------------------------
name            = WriteSingleCoilResponse
transaction_id  = 0x0
protocol_id     = 0x0
unit_id         =
                . [1]
skip_encode     = 0x0
check           = 0x0
address         = 0x0
value           = 0x1
documentation   =
    The normal response is an echo of the request, returned after the coil
    state has been written.
PYM-2 message parser fix and port

Approved-by: sanjay <[email protected]>
PYM-3: Generator script fix and port to Python3

Approved-by: sanjay <[email protected]>
The header for Binary trasaction is of size 1. This was recrtified
earlier commits of this branch.
The test ensure these changes
Removing the argument handler in TCP Syncronous server.
This argument is not used any where.
ModbusUdpServer and ModbusTcpServer will now accept any legal
Modbus request handler. The request handler being passed will have
to be of instance ModbusBaseRequestHandler.

The default request handler is ModbusDisconnectedRequestHandler.
I.e., is no handler is passed, or if the handler is not of type
ModbusBaseRequestHandler, ModbusDisconnectedRequestHandler will
be made use of.
…afddress to a database and then read from that address
…s to database. The process first checks if the address and value are already present in the database before performing a write. This ensures that database transaction errors will now occur in cases where repetetive data is being written.
PYM-6 fix passing handler to tcp sync server

Approved-by: sanjay <[email protected]>
…#8)

PYM-8 remote client reading database store fix

Approved-by: sanjay <[email protected]>
@dhoomakethu dhoomakethu merged commit 829cddc into dev Nov 28, 2017
@dhoomakethu dhoomakethu deleted the test-dev branch November 28, 2017 06:41
wexi pushed a commit to wexi/pymodbus that referenced this pull request Dec 1, 2017
* PYM-2:
- The issue listed was due to wrong messages being passed by the user.
Upon passing the right messages codes, the parser works as expected
on all counts.

- There is also changes that make the parser compatible with python2
and python3

- Verifier that the tool works on both python3 and python2 for all
MODBUS message codes on TCP, RTU, and BIN

* PYM-2: Checking the incoming framer. If te Framer is a Binary Framer,
we take the unit address as the second incoming bite as opposed
to the first bite.
This is was done while fixing the message parsers for binary messages

* PYM-2: Changed the modbus binary header size from 2 to 1.
According to the docs:
    Modbus Binary Frame Controller::

        [ Start ][Address ][ Function ][ Data ][ CRC ][ End ]
          1b        1b         1b         Nb     2b     1b

* PYM-3: Script is now compatible with both python2 and python3

* WIP

* PYM-2: Added a new switch: -t --transaction
This switch is meant to be used when we wish to parse messages directly
from the logs of Modbus.
The format of a message as shown in the logs is like bellow:
        0x7b 0x1 0x5 0x0 0x0 0xff 0x0 0x8c 0x3a 0x7d
We can pass this as the message to the parser along with the -t witch
to convert it into a compatible message to be parsed.
EG:

(modbus3) [~/pymodbus/examples/contrib]$ ./message-parser.py -b -t -p binary -m "0x7b 0x1 0x5 0x0 0x0 0xff 0x0 0x8c 0x3a 0x7d"
================================================================================
Decoding Message b'7b01050000ff008c3a7d'
================================================================================
ServerDecoder
--------------------------------------------------------------------------------
name            = WriteSingleCoilRequest
transaction_id  = 0x0
protocol_id     = 0x0
unit_id         =
                . [1]
skip_encode     = 0x0
check           = 0x0
address         = 0x0
value           = 0x1
documentation   =
    This function code is used to write a single output to either ON or OFF
    in a remote device.

    The requested ON/OFF state is specified by a constant in the request
    data field. A value of FF 00 hex requests the output to be ON. A value
    of 00 00 requests it to be OFF. All other values are illegal and will
    not affect the output.

    The Request PDU specifies the address of the coil to be forced. Coils
    are addressed starting at zero. Therefore coil numbered 1 is addressed
    as 0. The requested ON/OFF state is specified by a constant in the Coil
    Value field. A value of 0XFF00 requests the coil to be ON. A value of
    0X0000 requests the coil to be off. All other values are illegal and
    will not affect the coil.

ClientDecoder
--------------------------------------------------------------------------------
name            = WriteSingleCoilResponse
transaction_id  = 0x0
protocol_id     = 0x0
unit_id         =
                . [1]
skip_encode     = 0x0
check           = 0x0
address         = 0x0
value           = 0x1
documentation   =
    The normal response is an echo of the request, returned after the coil
    state has been written.

* PYM-2: Removing additional dependancy and making use of existing porting tools

* PYM-3: Removing additional dependancy and making use of existing porting tools

* Initial Bitbucket Pipelines configuration

* bitbucket-pipelines.yml edited online with Bitbucket

* bitbucket-pipelines.yml edited online with Bitbucket

* PYM-2: Updated the transaction tests for BinaryFramerTransaction.
The header for Binary trasaction is of size 1. This was recrtified
earlier commits of this branch.
The test ensure these changes

* PYM-6: Minor Cleanup task

Removing the argument handler in TCP Syncronous server.
This argument is not used any where.

* PYM-6:
ModbusUdpServer and ModbusTcpServer will now accept any legal
Modbus request handler. The request handler being passed will have
to be of instance ModbusBaseRequestHandler.

The default request handler is ModbusDisconnectedRequestHandler.
I.e., is no handler is passed, or if the handler is not of type
ModbusBaseRequestHandler, ModbusDisconnectedRequestHandler will
be made use of.

* PYM-6: Removing uneccessary check if handler is of type ModbusBaseRequestHandler

* PYM-8: Example that read from a database as a datastore

* PYM-8: Added two new datastores that can be used.
- SQLite3
- Reddis

* Small fixes

* Small fixes

* Small fixes

* Cleanup

* PYM-8: Updated the example to first write a random value at a random afddress to a database and then read from that address

* PYM-8: Added neccessary checks and methods to allow hassle free writes to database. The process first checks if the address and value are already present in the database before performing a write. This ensures that database transaction errors will now occur in cases where repetetive data is being written.

* Cleanup: Removing pdb placed during testing and other comments

* bitbucket-pipelines.yml deleted online with Bitbucket

* pymodbus-dev#240 Fix PR failures

* pymodbus-dev#240 fix Travis build failures

* pymodbus-dev#190 fix import error in dbstore-update-server example

* Small changes and typo fixed in pymodbus utilities and redis datastore helpers

* Added tests for redis datastore helpers

* Minor fixes to SQL datastore

* Unit tests for SQL datastore - 100% coverage

* Tests now compatible with python3 and python2
dhoomakethu added a commit that referenced this pull request Dec 21, 2017
* PYM-2:
- The issue listed was due to wrong messages being passed by the user.
Upon passing the right messages codes, the parser works as expected
on all counts.

- There is also changes that make the parser compatible with python2
and python3

- Verifier that the tool works on both python3 and python2 for all
MODBUS message codes on TCP, RTU, and BIN

* PYM-2: Checking the incoming framer. If te Framer is a Binary Framer,
we take the unit address as the second incoming bite as opposed
to the first bite.
This is was done while fixing the message parsers for binary messages

* PYM-2: Changed the modbus binary header size from 2 to 1.
According to the docs:
    Modbus Binary Frame Controller::

        [ Start ][Address ][ Function ][ Data ][ CRC ][ End ]
          1b        1b         1b         Nb     2b     1b

* PYM-3: Script is now compatible with both python2 and python3

* WIP

* PYM-2: Added a new switch: -t --transaction
This switch is meant to be used when we wish to parse messages directly
from the logs of Modbus.
The format of a message as shown in the logs is like bellow:
        0x7b 0x1 0x5 0x0 0x0 0xff 0x0 0x8c 0x3a 0x7d
We can pass this as the message to the parser along with the -t witch
to convert it into a compatible message to be parsed.
EG:

(modbus3) [~/pymodbus/examples/contrib]$ ./message-parser.py -b -t -p binary -m "0x7b 0x1 0x5 0x0 0x0 0xff 0x0 0x8c 0x3a 0x7d"
================================================================================
Decoding Message b'7b01050000ff008c3a7d'
================================================================================
ServerDecoder
--------------------------------------------------------------------------------
name            = WriteSingleCoilRequest
transaction_id  = 0x0
protocol_id     = 0x0
unit_id         =
                . [1]
skip_encode     = 0x0
check           = 0x0
address         = 0x0
value           = 0x1
documentation   =
    This function code is used to write a single output to either ON or OFF
    in a remote device.

    The requested ON/OFF state is specified by a constant in the request
    data field. A value of FF 00 hex requests the output to be ON. A value
    of 00 00 requests it to be OFF. All other values are illegal and will
    not affect the output.

    The Request PDU specifies the address of the coil to be forced. Coils
    are addressed starting at zero. Therefore coil numbered 1 is addressed
    as 0. The requested ON/OFF state is specified by a constant in the Coil
    Value field. A value of 0XFF00 requests the coil to be ON. A value of
    0X0000 requests the coil to be off. All other values are illegal and
    will not affect the coil.

ClientDecoder
--------------------------------------------------------------------------------
name            = WriteSingleCoilResponse
transaction_id  = 0x0
protocol_id     = 0x0
unit_id         =
                . [1]
skip_encode     = 0x0
check           = 0x0
address         = 0x0
value           = 0x1
documentation   =
    The normal response is an echo of the request, returned after the coil
    state has been written.

* PYM-2: Removing additional dependancy and making use of existing porting tools

* PYM-3: Removing additional dependancy and making use of existing porting tools

* Initial Bitbucket Pipelines configuration

* bitbucket-pipelines.yml edited online with Bitbucket

* bitbucket-pipelines.yml edited online with Bitbucket

* PYM-2: Updated the transaction tests for BinaryFramerTransaction.
The header for Binary trasaction is of size 1. This was recrtified
earlier commits of this branch.
The test ensure these changes

* PYM-6: Minor Cleanup task

Removing the argument handler in TCP Syncronous server.
This argument is not used any where.

* PYM-6:
ModbusUdpServer and ModbusTcpServer will now accept any legal
Modbus request handler. The request handler being passed will have
to be of instance ModbusBaseRequestHandler.

The default request handler is ModbusDisconnectedRequestHandler.
I.e., is no handler is passed, or if the handler is not of type
ModbusBaseRequestHandler, ModbusDisconnectedRequestHandler will
be made use of.

* PYM-6: Removing uneccessary check if handler is of type ModbusBaseRequestHandler

* PYM-8: Example that read from a database as a datastore

* PYM-8: Added two new datastores that can be used.
- SQLite3
- Reddis

* Small fixes

* Small fixes

* Small fixes

* Cleanup

* PYM-8: Updated the example to first write a random value at a random afddress to a database and then read from that address

* PYM-8: Added neccessary checks and methods to allow hassle free writes to database. The process first checks if the address and value are already present in the database before performing a write. This ensures that database transaction errors will now occur in cases where repetetive data is being written.

* Cleanup: Removing pdb placed during testing and other comments

* bitbucket-pipelines.yml deleted online with Bitbucket

* #240 Fix PR failures

* #240 fix Travis build failures

* #190 fix import error in dbstore-update-server example

* Small changes and typo fixed in pymodbus utilities and redis datastore helpers

* Added tests for redis datastore helpers

* Minor fixes to SQL datastore

* Unit tests for SQL datastore - 100% coverage

* Tests now compatible with python3 and python2
dhoomakethu added a commit that referenced this pull request Dec 22, 2017
* PYM-2:
- The issue listed was due to wrong messages being passed by the user.
Upon passing the right messages codes, the parser works as expected
on all counts.

- There is also changes that make the parser compatible with python2
and python3

- Verifier that the tool works on both python3 and python2 for all
MODBUS message codes on TCP, RTU, and BIN

* PYM-2: Checking the incoming framer. If te Framer is a Binary Framer,
we take the unit address as the second incoming bite as opposed
to the first bite.
This is was done while fixing the message parsers for binary messages

* PYM-2: Changed the modbus binary header size from 2 to 1.
According to the docs:
    Modbus Binary Frame Controller::

        [ Start ][Address ][ Function ][ Data ][ CRC ][ End ]
          1b        1b         1b         Nb     2b     1b

* PYM-3: Script is now compatible with both python2 and python3

* WIP

* PYM-2: Added a new switch: -t --transaction
This switch is meant to be used when we wish to parse messages directly
from the logs of Modbus.
The format of a message as shown in the logs is like bellow:
        0x7b 0x1 0x5 0x0 0x0 0xff 0x0 0x8c 0x3a 0x7d
We can pass this as the message to the parser along with the -t witch
to convert it into a compatible message to be parsed.
EG:

(modbus3) [~/pymodbus/examples/contrib]$ ./message-parser.py -b -t -p binary -m "0x7b 0x1 0x5 0x0 0x0 0xff 0x0 0x8c 0x3a 0x7d"
================================================================================
Decoding Message b'7b01050000ff008c3a7d'
================================================================================
ServerDecoder
--------------------------------------------------------------------------------
name            = WriteSingleCoilRequest
transaction_id  = 0x0
protocol_id     = 0x0
unit_id         =
                . [1]
skip_encode     = 0x0
check           = 0x0
address         = 0x0
value           = 0x1
documentation   =
    This function code is used to write a single output to either ON or OFF
    in a remote device.

    The requested ON/OFF state is specified by a constant in the request
    data field. A value of FF 00 hex requests the output to be ON. A value
    of 00 00 requests it to be OFF. All other values are illegal and will
    not affect the output.

    The Request PDU specifies the address of the coil to be forced. Coils
    are addressed starting at zero. Therefore coil numbered 1 is addressed
    as 0. The requested ON/OFF state is specified by a constant in the Coil
    Value field. A value of 0XFF00 requests the coil to be ON. A value of
    0X0000 requests the coil to be off. All other values are illegal and
    will not affect the coil.

ClientDecoder
--------------------------------------------------------------------------------
name            = WriteSingleCoilResponse
transaction_id  = 0x0
protocol_id     = 0x0
unit_id         =
                . [1]
skip_encode     = 0x0
check           = 0x0
address         = 0x0
value           = 0x1
documentation   =
    The normal response is an echo of the request, returned after the coil
    state has been written.

* PYM-2: Removing additional dependancy and making use of existing porting tools

* PYM-3: Removing additional dependancy and making use of existing porting tools

* Initial Bitbucket Pipelines configuration

* bitbucket-pipelines.yml edited online with Bitbucket

* bitbucket-pipelines.yml edited online with Bitbucket

* PYM-2: Updated the transaction tests for BinaryFramerTransaction.
The header for Binary trasaction is of size 1. This was recrtified
earlier commits of this branch.
The test ensure these changes

* PYM-6: Minor Cleanup task

Removing the argument handler in TCP Syncronous server.
This argument is not used any where.

* PYM-6:
ModbusUdpServer and ModbusTcpServer will now accept any legal
Modbus request handler. The request handler being passed will have
to be of instance ModbusBaseRequestHandler.

The default request handler is ModbusDisconnectedRequestHandler.
I.e., is no handler is passed, or if the handler is not of type
ModbusBaseRequestHandler, ModbusDisconnectedRequestHandler will
be made use of.

* PYM-6: Removing uneccessary check if handler is of type ModbusBaseRequestHandler

* PYM-8: Example that read from a database as a datastore

* PYM-8: Added two new datastores that can be used.
- SQLite3
- Reddis

* Small fixes

* Small fixes

* Small fixes

* Cleanup

* PYM-8: Updated the example to first write a random value at a random afddress to a database and then read from that address

* PYM-8: Added neccessary checks and methods to allow hassle free writes to database. The process first checks if the address and value are already present in the database before performing a write. This ensures that database transaction errors will now occur in cases where repetetive data is being written.

* Cleanup: Removing pdb placed during testing and other comments

* bitbucket-pipelines.yml deleted online with Bitbucket

* #240 Fix PR failures

* #240 fix Travis build failures

* #190 fix import error in dbstore-update-server example

* Small changes and typo fixed in pymodbus utilities and redis datastore helpers

* Added tests for redis datastore helpers

* Minor fixes to SQL datastore

* Unit tests for SQL datastore - 100% coverage

* Tests now compatible with python3 and python2
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop async Server

2 participants