ModTest Manual v2.15 - 3.1. Defining commands
You can use the Define Command page to define and send Modbus commands.
A command definition consists of:
-
The Command Type. There are three kinds of command types:
Custom command. This option enables you to define and send non-standard Modbus commands, and is described in the Custom commands section.
Send raw data. This option enables you to send arbitrary data to the slave, and is described in the Sending raw data section.
Standard commands. These are standard Modbus commands, which are described in the Standard commands section.
Values to be sent to the slave as part of the command (e.g. Slave ID and Address).
-
The Expected outcome. The options are:
OK. The slave should send a normal response.
Timed out. The slave should not respond.
Invalid response. The slave should send an invalid response, i.e. one that is not correctly formatted. This option is provided for completeness only, and would not normally be used.
Error response: ... The slave should send the specified error response.
-
Values expected to be returned by the slave in its response. The expected values are only relevant if the expected outcome is OK.
You can simply enter the expected value in the relevant field, or you can leave the field empty to accept any value in the slave's response.
If more than one value is acceptable in the response, you can enter a list of acceptable values, separated by spaces.
You can also enter ranges of acceptable values. A range consists of a minimum value and a maximum value, separated by ':'. For example, the range '9:12' would have the same effect as the list of values '9 10 11 12'. Either the minimum or the maximum can be omitted from a range. For example, the range ':100' would accept any value up to 100, and the range '123:' would accept any value from 123 upwards.
Individual values and ranges can be mixed in the same list. For example, the list ':10 13 17:19 30:' would accept the values 13, 17, 18 and 19, and also values up to 10 and values from 30 upwards.
When you have entered a command definition, you can click the Test button to send the command to the slave. The result of sending the command will be displayed in the page. Any differences between the actual and expected results (i.e. outcome and values) will be highlighted in red.
If you know that the actual outcome and values from the slave are correct, you can use them as the expected outcome and values by clicking the Expect actual button. This is often much quicker than manually entering expected values.
If you want to save the command definition, enter a unique name for the command in the Name field and click the Save button. All saved command definitions are listed in the Command table.
You can provide a description of the command in the Description field. ModTest displays the description, but does not use it in any other way. It is purely for your benefit, to remind you of what the command is used for.
The Reset button will restore the values to their last saved state.