Commands Supported by TCP ASCII Communication and Returned Status Codes

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

When TCP ASCII communication is used, the external device should use the following types of commands to trigger the Mech-MSR project to run and obtain the corresponding results.

  • trigger command: for triggering a project or projects to run.

  • return command: for obtaining the judgment result and measurement result of a specified project.

  • judge command: for obtaining the overall quality judgment result of a specified project or the quality judgment result of individual measurement items.

  • value command: mainly for obtaining the measured values of a specified project.

  • The return/judge/value command can only be sent after the project is triggered to run successfully by the trigger command.

  • After making changes in the Mech-MSR’s Output management window, you should re-send the trigger command to trigger the project to run, and then send other commands to obtain relevant results. If the project is not triggered to run again, the obtained results will not be updated as modified.

Trigger Command

The trigger command is used to trigger Mech-MSR projects to run. Multiple projects can be triggered to run at the same time.

Step 1: Determine Project ID

In the Project List area of Mech-MSR’s home interface, check the ID of the project to be triggered.

project number
  • If the project does not have an ID, select the solution in which the project is located, and then right-click it and select Autoload Solution option to autoload all projects under the solution. Only when this option is selected can an external device trigger the project under the solution.

  • Drag the project to adjust the project order, and then select Reset Project IDs option in the right-click menu to update the project IDs.

Step 2: Send a Command

The sent trigger command should consist of trigger, project ID, and string delimiter.

  • trigger: the exact command name, case-sensitive.

  • Project ID: the ID of the project to be triggered in the Mech-MSR solution.

  • String delimiter: The symbol that separates “trigger” from the project ID. The default value is the English comma (,). You can change it in Mech-MSR’s Communication Configuration window under the Other data formats parameter.

The table below illustrates the format of trigger commands.

Format Description Example

trigger, project ID

Triggers a project to run.

Triggers the project with an ID value of 1 to run:

trigger, 1

trigger, project ID 1, project ID 2, project ID 3

Triggers multiple projects to run.

Triggers projects with ID values of 1, 2, and 3 to run:

trigger, 1, 2, 3

For projects newly created under a solution, you need to close and reopen the solution before triggering the project to run using this command.

Step 3: Check the Returned Results

After a trigger command is sent, if the received status code is 0, the command has been executed successfully.

If command execution fails, an error code -1 or -4 will be returned. See Error Codes for possible causes and solutions.

Return Command

After sending a trigger command to trigger the project to run, use the return command to obtain the running results of the project. You can use the return command to get the results of only one Mech-MSR project at a time.

Step 1: Determine the Format of Returned Results

In Mech-MSR’s Communication Configuration window, set the Data format of return commands according to actual needs.

The default data format is %judge,%value[%id],%judge[%id].

return command format

Step 2: Send a Command

The sent return command should consist of return, project ID, and string delimiter.

  • return: the exact command name, case-sensitive.

  • Project ID: The ID of the project triggered by the trigger command in the Mech-MSR solution.

  • String delimiter: The symbol that separates “return” from the project ID. The default value is the English comma (,).

The table below illustrates the format of return commands.

Format Description Example

return, project ID

Used to obtain the running result of the project.

Command to send for obtaining the running result of project 1:

return, 1

Ensure that the specified project has been triggered to run by the trigger command, or else the result cannot be obtained normally after the return command is sent.

Step 3: Check the Returned Results

In the example of project 1, after the external device sends return, 1 command, Mech-MSR will return the results according to the Data format of return commands set in the Communication Configuration window.

If the command execution fails, an error code -1, -2, -3 or -4 will be returned. See Error Codes for possible causes and solutions.

Data format of return commands Returned results (example) Description

%judge

0

It indicates that the overall quality judgment result of project 1 is OK.

%judge

1

It indicates that the overall quality judgment result of project 1 is NG.

%judge,%value[%id],%judge[%id]

0,0.0224,0,54.0000,1

It indicates that the overall quality judgment result of project 1 is OK, and in this project, only two measurement items are specified to be output. The first measurement item in sequence has a value of 0.0224 and is judged as OK, and the second measurement item has a value of 54.0000 and is judged as NG.

1,invalid,1

It indicates that the overall quality judgment result of project 1 is NG. In this project, only one measurement item is specified to be output. The measurement item has no measurement result, and thus invalid is returned, and the value of the measurement item is judged as NG.

%judge,%value[2],%judge[2]

0,invalid,invalid

It indicates that the overall quality judgment result of project 1 is OK, and both the value of measurement item 2 and the corresponding judgment result are invalid.

Possible cause:

  • In Mech-MSR’s Output Management window, no measurement item with an ID value of 2 is added in the Communication output tab.

Solutions:

  • Ensure that there is a measurement item with an ID value of 2 under the Communication output tab of Mech-MSR’s Output Management window.

  • Change the Data format of return commands to ensure that valid results can be returned.

See Measured values and judgment results to learn the basic conditions for Mech-MSR returning results to an external device.

Judge Command

After sending a trigger command to trigger the project to run, use the judge command to obtain the judgment results of the specified Mech-MSR project or individual measurement items.

Step 1: Send a Command

The sent judge command should consist of judge, project ID, and string delimiter.

  • judge: the exact command name, case-sensitive.

  • Project ID: The ID of the project triggered by the trigger command in the Mech-MSR solution.

  • String delimiter: The symbol that separates “judge” from the project ID. The default value is the English comma (,).

The table below illustrates the format of judge commands.

Format Description Example

judge, project ID

Used to obtain the overall quality judgment result of the specified project and the judgment results of individual measurement items.

Command to send for obtaining the overall judgment result of project 1 and the judgment results of individual measurement items:

judge, 1

Step 2: Check the Returned Results

In the example of project 1, after an external device sends judge, 1, Mech-MSR will return the overall quality judgment result of the project and the quality judgment results of individual measurement items according to the set quality judgment rule and communication output in the Output Management window.

If the command execution fails, an error code -1, -2, -3 or -4 will be returned. See Error Codes for possible causes and solutions.

Returned result Description

0,0,0

(example)

The first 0 indicates that the overall judgment result of project 1 is OK, and the next two 0s indicate that 2 measurement items have been set to be output for the project, and the judgment result of both is OK.

1,1,1

(example)

The first 1 indicates that the overall judgment result of project 1 is NG, and the next two 1s indicate that 2 measurement items have been set to be output for the project, and the judgment result of both is NG.

See Judgment results to learn about the basic conditions for Mech-MSRreturning results to an external device.

Value Command

After sending a trigger command to trigger the project to run, use the value command to obtain the measured values of the specified project.

Step 1: Send a Command

The sent value command should consist of value, project ID, and string delimiter.

  • value: the exact command name, case-sensitive.

  • Project ID: The ID of the project triggered by the trigger command in the Mech-MSR solution.

  • String delimiter: The symbol that separates “value” from the project ID. The default value is the English comma (,).

The table below illustrates the format of value commands.

Format Description Example

value, project ID

Used to obtain the measured values of a specified project.

Command to send for obtaining the measured values of project 1:

value, 1

Step 2: Check the Returned Results

In the example of project 1, after an external device sends value, 1, Mech-MSR will return the overall quality judgment result of the project and the values of each measurement item according to the set quality judgment rule and communication output in the Output Management window.

If the command execution fails, an error code -1, -2, -3 or -4 will be returned. See Error Codes for possible causes and solutions.

Returned result Description

0,54.0000

(example)

0 indicates that the overall judgment result of project 1 is OK, and the value of measurement item 1 is 54.000. This project only specifies the output of one measurement item.

1,54.0000

(example)

1 indicates that the overall judgment result of project 1 is NG, and the value of measurement item 1 is 54.0000. This project only specifies the output of one measurement item.

1,invalid

(example)

1 indicates that the overall judgment result of project 1 is NG. This project only specifies the output of one measurement item, but the measurement item does not have a corresponding value. Thus, the returned value is invalid.

Possible cause:

  • There are no measurement results for this measurement item.

Solutions:

  • Check the measurement and ensure that the project can output valid results.

See Measured values and judgment results to learn the basic conditions for Mech-MSR returning results to an external device.

Error Codes

The possible causes and solutions for returned error codes are shown in the table below.

Error code Description Possible cause Solution

-1

Indicates that the project ID does not exist.

  • The specified project ID did not exist in Mech-MSR’s Project List.

  • The solution that includes the project was not autoloaded.

  • The specified project is a new project, and the solution in which the project is located has not been closed and reopened.

  • Ensure that the specified project ID exists in Mech-MSR’s Project List.

  • Select the solution in Mech-MSR, right-click it and confirm that the Autoload Solution option is selected.

  • Try closing and reopening the solution in Mech-MSR.

-2

Indicates no results.

  • The specified project was not triggered to run.

  • The Mech-MSR software was running abnormally.

  • Ensure that the project has been triggered by the trigger command.

  • Ensure that the Mech-MSR software is running normally and the project can output results normally.

-3

If the project has not finished running within 10 seconds after a command is sent, this error code will be returned.

The project execution time is too long, exceeding the timeout period (10 seconds).

Check if the execution time of the project is longer than 10 seconds, and check if the execution time is abnormal. If there is an exception, figure out the reason for the excessive project execution time and fix it; if it is normal, try solving the problem as follows:

  • Add an appropriate delay before the client calls this command.

  • Increase the timeout period (self.vision_timeout) in the msr_dispatcher.py program. The default timeout period is 10 seconds. Please save and restart the software after modification.

-4

Indicates that an illegal command was sent.

  • trigger/return/judge/value is misspelled or has inconsistent case.

  • The string delimiter between trigger/return/judge/value and project ID does not match the one set in Mech-MSR’s Communication Configuration window.

  • Check the spelling and case of trigger/return/judge/value.

  • Ensure that the string delimiter between trigger/return/judge/value and project ID is the same as the one set in Mech-MSR’s Communication Configuration window.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.