---
title: "TCP Socket API for MachineMotion"
slug: "application-programming-interface-low-level-sockets-for-machinemotion"
updated: 2026-03-24T16:24:48Z
published: 2026-03-24T16:24:48Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vention.io/llms.txt
> Use this file to discover all available pages before exploring further.

# TCP Socket API for MachineMotion

## Overview

This document details the commands that can be sent to your MachineMotion AI using Ethernet TCP/IP protocol. It is supported on MachineMotion software version v3.1.0 and newer versions. This API uses sockets to exchange data. All information is packaged in string format and sent over the socket communication channel to port `9999` of the MachineMotion AI.

The TCP Socket API is a TCP server that enables a TCP client to :

- Get information about the status of the MachineMotion
- Get information and send commands to motors connected to the MachineMotion
- Set outputs and read inputs of the IO modules connected to the MachineMotion
- Send and receive custom messages over the mqtt broker of the MachineMotion

> [!WARNING]
> ***For details on previous releases of Vention’s Low-Level Socket Programming Interface with MachineMotion 2 and MachineMotion 1, refer to the***[*Documentation for Previous Product Versions*](/technicaldocumentation/docs/application-programming-interface-low-level-sockets-for-machinemotion#documentation-for-previous-releases)***section at the end of this document.***

## Configuring an IP Address

See [MachineMotion AI Controller User Manual](/technicaldocumentation/docs/machinemotion-ai-user-manual) to learn more about how to configure the IP address of the MachineMotion.

A connection must be opened before any commands can be sent or received from the MachineMotion. How to open a connection will depend on the programming language being used.

## Using the TCP Socket API

### End of Line character

> [!NOTE]
> This feature is present on the MachineMotion AI release v3.2.0 and newer.

Each message exchanged on the TCP Socket API must end with `/n` .

This will be the case of the payload received, and sent.

### Heartbeat

> [!NOTE]
> This feature is present on the MachineMotion AI release v3.2.0 and newer.

**Heartbeat message**

To ensure that the TCP connection is alive, make sure that no more than 0.5s span between each message.

If no message has been received by the MachineMotion within 0.5s, the MachineMotion will initiate a disconnection.

Instead of sending one of the commands listed below, you could send a heartbeat message:

#### **Heartbeat**

**Description**

Message exchanged to keep the TCP connection alive. This is a no-operation on the MachineMotion side.

**Format**

`ping`

**Usage**

`ping` will have the MachineMotion keep the TCP connection alive for another 0.5s.

**Response**

- `pong`

**Quickstop on disconnection**

Upon the socket disconnecting, the MachineMotion will stop the motion of all its connected motors.

You can deactivate this behaviour using the `setQuickStopOnDisconnect` command.

#### **Set Quickstop on Disconnect**

**Description**

Sets wether or not to stop the motion of all motors upon a socket disconnection event.

**Format**

`setQuickStopOnDisconnect_&lt;Payload&gt;`

Where `&lt;Payload&gt;`> can be:

- `0` to not stop all the motors upon a socket disconnection
- `1` to stop all motors upon a socket disconnection. This is the default behaviour of the MachineMotion.

**Usage**

`setQuickStopOnDisconnect_0` will change the default behaviour of the MachineMotion. Upon a socket disconnection, the motors won’t stop their on-going motion.

**Response**

- `1` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

## List of Commands

#### **Get Safety State**

**Description**

Returns the safety state of the MachineMotion.

**Format**

`getSafetyState `

**Usage**

`getSafetyState `

**Response**

The safety state of the MachineMotion can be one of those values:

- `-1` corresponds to an error in the safety state
- `0` corresponds to no safety state (this would be the case for the MachineMotion AI Robot and MachineMotion AI Robot Pro models)
- `1` corresponds to an emergency stop state
- `2` corresponds to a normal safety state
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Operational State**

**Description**

Returns the operational state of the MachineMotion.

**Format**

`getOperationalState `

**Usage**

`getOperationalState `

**Response**

The operational state of the MachineMotion can be one of those values:

- `1 ` corresponds to operational
- `0` corresponds to non-operational
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Enable Operation**

**Description**

Request the MachineMotion to change its operational state to be operational again.

**Format**

`operationEnable`

**Usage**

`operationEnable`

**Response**

- `1` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Disable Operation**

**Description**

Request the MachineMotion to change its operational state to not be operational.

**Format**

`operationDisable`

**Usage**

`operationDisable`

**Response**

- `1` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Move**

**Description**

Moves an axis immediately, to a given position, distance or speed.

**Format**

`move_&lt;Payload&gt;;*`

Where `&lt;Payload&gt;`> corresponds to a `TrapezoidalMove` or a `ContinuousMove` .

Note : `;*` means multiple can be input in the same request.

**A - Trapezoidal Move**

Moves an axis immediately to a given position or by a given distance.

Fields can be specified in any order.

| Field | Description | Is Mandatory |
| --- | --- | --- |
| `type:trapezoidal` | The move type | yes |
| `relative:[0,1]` | Is the motion relative or absolute | yes |
| `[port:&lt;int&gt;,index:&lt;int&gt;,target:&lt;float&gt;]` | The motor address (port and index) and its target position for absolute moves, or its target distance for relative moves. One move can have multiple of this field, in order to move multiple motors. | yes |
| `velocity:&lt;float&gt;` | Desired velocity, in mm/sec | yes |
| `acceleration:&lt;float&gt;` | Desired acceleration, in mm/sec2 | yes |
| `deceleration:&lt;float&gt;` | NOT USED (Desired deceleration) | no |
| `jerk:&lt;float&gt;` | NOT USED (Jerk value of the move) | no |
| `ignoreSync:[0,1]` | Ignore the synchronization configuration of parent and child motors | no |

**B - Continuous Move**

Moves a conveyor or rotary table axis continuously at a given speed and acceleration.

Fields can be specified in any order.

| Field | Description | Is Mandatory |
| --- | --- | --- |
| `type:continuous` | The move type | yes |
| `port:&lt;int&gt;` | The motor address (port) | yes |
| `index:&lt;int&gt;` | The motor address (index) | yes |
| `velocity:&lt;float&gt;` | Desired velocity, in mm/sec. Positive numbers correspond to moving in the positive direction of the axis. Negative numbers correspond to moving in the negative direction of the axis. | yes |
| `acceleration:&lt;float&gt;` | Desired acceleration, in mm/sec2 | yes |

**Usage**

`move_type:trapezoidal,[port:1,index:1,target:300],velocity:300,acceleration:100,relative:1` starts moving the first motor connected to port 1, by a distance of 300 mm, with a velocity of 300 mm/sec, and an acceleration of 100 mm/sec2.

`move_type:continuous,port:1,index:1,velocity:300,acceleration:100` starts moving the first motor connected to port 1, continuously at a velocity of 300 mm/sec, with an acceleration of 100 mm/sec2.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Add Move**

**Description**

Adds a move to list of moves, to be executed later, when the command `moveGo` will be sent.

It will enable moving an axis to a given position, distance or speed, later on.

**Format**

`moveAdd&lt;Payload&gt;;*`

Where `&lt;Payload&gt;` corresponds to a `TrapezoidalMove` or a `ContinuousMove` .

Note : `;*` means multiple can be input in the same request.

**A - Trapezoidal Move**

Moves an axis to a given position or by a given distance.

Fields can be specified in any order.

| Field | Description | Is Mandatory |
| --- | --- | --- |
| `type:trapezoidal` | The move type | yes |
| `relative:[0,1]` | Is the motion relative or absolute | yes |
| `[port:&lt;int&gt;,index:&lt;int&gt;,target:&lt;float&gt;]` | The motor address (port and index) and its target position for absolute moves, or its target distance for relative moves. One move can have multiple of this field, in order to move multiple motors. | yes |
| `velocity:&lt;float&gt;` | Desired velocity, in mm/sec | yes |
| `acceleration:&lt;float&gt;` | Desired acceleration, in mm/sec2 | yes |
| `deceleration:&lt;float&gt;` | NOT USED (Desired deceleration) | no |
| `jerk:&lt;float&gt;` | NOT USED (Jerk value of the move) | no |
| `ignoreSync:[0,1]` | Ignore the synchronization configuration of parent and child motors | no |

**B - Continuous Move**

Moves a conveyor or rotary table axis continuously at a given speed and acceleration.

Fields can be specified in any order.

| Field | Description | Is Mandatory |
| --- | --- | --- |
| `type:continuous` | The move type | yes |
| `port:&lt;int&gt;` | The motor address (port) | yes |
| `index:&lt;int&gt;` | The motor address (index) | yes |
| `velocity:&lt;float&gt;` | Desired velocity, in mm/sec | yes |
| `acceleration:&lt;float&gt;` | Desired acceleration, in mm/sec2 | yes |

**Usage**

`moveAdd_type:trapezoidal,[port:1,index:1,target:300],velocity:300,acceleration:100,relative:1` will queue up a motion that starts moving the first motor connected to port 1, by a distance of 300 mm, with a velocity of 300 mm/sec, and an acceleration of 100 mm/sec2.

`moveGo` will start executing the previously described move.

**Response**

- `1` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Go Move**

**Description**

Will start the execution of all the moves that have been queued up by the `moveAdd` command.

**Format**

`moveGo `

**Usage**

`moveAdd_type:trapezoidal,[port:1,index:1,target:300],velocity:300,acceleration:100,relative:1` will queue up a motion that starts moving the first motor connected to port 1, by a distance of 300 mm, with a velocity of 300 mm/sec, and an acceleration of 100 mm/sec2.

`moveGo` will start executing the previously described move.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Clear Move**

**Description**

Will clear all the moves that have been queued up by the `moveAdd` command, without executing them.

**Format**

`moveClear `

**Usage**

`moveAdd_type:trapezoidal,[port:1,index:1,target:300],velocity:300,acceleration:100,relative:1` will queue up a motion that starts moving the first motor connected to port 1, by a distance of 300 mm, with a velocity of 300 mm/sec, and an acceleration of 100 mm/sec2.

`moveClear` will start clear the previously described move. It will not be executed by any subsequent `moveGo` command.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Move Home**

**Description**

Moves an axis immediately, towards its home position, until the home sensor is triggered. This will reset the zero position of the axis.

**Format**

`moveHome_&lt;Payload&gt;;*`

Where `&lt;Payload&gt;`> corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

Note : `;*` means multiple can be input in the same request.

**Usage**

`moveHome_1,1` starts moving the first motor connected to port 1, towards its home sensor.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Add Move Home**

**Description**

Adds a homing move to list of homing moves, to be executed later, when the command `moveHomeGo` will be sent.

It will enable moving an axis towards its home position, until the home sensor is triggered. This will reset the zero position of the axis.

**Format**

`moveHomeAdd_&lt;Payload&gt;;*`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

Note : `;*` means multiple can be input in the same request.

**Usage**

`moveHomeAdd_1,1;2_1` will queue up a motion that will start moving the first motor connected to port 1, as well as the first motor connected to port 2, towards their home sensors.

`moveHomeGo` will start executing the previously described move.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Go Move Home**

**Description**

Will start the execution of all the moves that have been queued up by the `moveHomeAdd` command.

**Format**

`moveHomeGo `

**Usage**

`moveHomeAdd_1,1;2_1` will queue up a motion that will start moving the first motor connected to port 1, as well as the first motor connected to port 2, towards their home sensors.

`moveHomeGo` will start executing the previously described move.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Clear Move Home**

**Description**

Will clear all the moves that have been queued up by the `moveHomeAdd` command, without executing them.

**Format**

`moveHomeClear `

**Usage**

`moveHomeAdd_1,1;2_1` will queue up a motion that will start moving the first motor connected to port 1, as well as the first motor connected to port 2, towards their home sensors.

`moveHomeClear` will start clear the previously described move. It will not be executed by any subsequent `moveHomeGo` command.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Quick Stop**

**Description**

Immediately stops motion on the given axes.

**Format**

`quickStop_&lt;Payload&gt;;*`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

Note : `;*` means multiple can be input in the same request.

**Usage**

`quickStop_1,1;2,2` will immediate stop any motion on the first motor connected to port 1, and the second motor connected to port 2.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Set Position**

**Description**

Sets the current position of an axis to a new value. It does not move the axis.

**Format**

`setPosition_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;,&lt;position&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)
- `&lt;position&gt;` is the new position value, in mm.

**Usage**

`setPosition_1,1,1000` Sets the current position if the first motor connected to port 1 at position 1000 mm.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Set Ignore End Sensors**

**Description**

Sets whether or not the axis should ignore the status of its end of travel sensors during a move.

**Format**

`setIgnoreEndSensor_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;,&lt;[0,1]&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)
- `&lt;[0,1]&gt;` 1 corresponds to ignoring them, 0 corresponds to take them into account. By default, they won’t be ignored.

**Usage**

`setIgnoreEndSensor_1,1,0` Sets the the first motor connected to port 1 to not ignore its end of travel sensors.

**Response**

- `1 ` corresponds to a success
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Connected**

**Description**

Queries the connection status of a motor: whether or not it is currently detected as available hardware by the MachineMotion.

**Format**

`getConnected_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getConnected_1,2` returns whether or not there is a motor detected on port 1, in second position in the motor chain.

**Response**

- `1 ` corresponds to a motor being detected at the given address
- `0 ` corresponds to no motor being detected at the given address
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Position**

**Description**

Queries the current position of a motor.

**Format**

`getPosition_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getPosition_1,1` returns the position of the first motor connected to port 1.

**Response**

- A real number corresponding to the position of the axis, in millimetres. For example, `1237.222` .
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Velocity**

**Description**

Queries the current speed of a motor.

**Format**

`getVelocity_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getVelocity_1,1` returns the speed of the first motor connected to port 1.

**Response**

- A real number corresponding to the speed of the axis, in mm/sec. For example, `400.12` . Positive numbers correspond to moving in the positive direction of the axis. Negative numbers correspond to moving in the negative direction of the axis.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Target Reached**

**Description**

Queries whether or not a motor has yet reached its target.

A motor is considered to have reached its target if any of these are satisfied:

- it has reached its specified position or velocity for trapezoidal and continuous moves respectively
- it has triggered one of its end of travel sensors
- it has been interrupted by a quick stop command.

**Format**

`getTargetReached_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getTargetReached_1,1` returns whether the first motor connected to port 1 has reached its target or not.

**Response**

- `0` corresponds to the target not yet being reached.
- `1` corresponds to the target having been reached.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Motion Allowed**

**Description**

Queries whether or not a motor is ready to accept new motion commands.

Generally, motion is allowed when target is reached or when operation is disabled.

**Format**

`getMotionAllowed_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getMotionAllowed_1,1` returns whether the first motor connected to port 1 is ready to accept new motion commands or not.

**Response**

- `0` corresponds to the motor not being ready to accept new motion commands.
- `1` corresponds to the motor being ready to accept new motion commands.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Brake Status**

**Description**

Queries whether or not the brake is locked on a given motor.

**Format**

`getBrakeStatus_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getBrakeStatus_1,1` returns whether the first motor connected to port 1 has its brake locked or not.

**Response**

- `0` corresponds to the brake being unlocked.
- `1` corresponds to the brake being locked.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Home Sensor**

**Description**

Queries whether or not the home sensor of a given motor is triggered.

Note: the conveyor motor does not have home nor end sensors. See “**Get Sensor A**” and “**Get Sensor B**” instead. See [MachineMotion AI Actuator Configuration End-of-travel sensors](/technicaldocumentation/docs/machinemotion-ai-actuator-configuration#endoftravel-sensors) for more information on endstop sensors.

**Format**

`getHomeSensor_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getHomeSensor_2,2` returns whether the second motor connected to port 2 has its home sensor triggered or not.

**Response**

- `0` corresponds to the home sensor not being triggered.
- `1` corresponds to the home sensor being triggered.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get End Sensor**

**Description**

Queries whether or not the endstop sensor of a given motor is triggered.

Note: the conveyor motor does not have home nor end sensors. See “**Get Sensor A**” and “**Get Sensor B**” instead. See [MachineMotion AI Actuator Configuration End-of-travel sensors](/technicaldocumentation/docs/machinemotion-ai-actuator-configuration#endoftravel-sensors) for more information on endstop sensors.

**Format**

`getEndSensor_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getEndSensor_2,1` returns whether the first motor connected to port 2 has its endstop sensor triggered or not.

**Response**

- `0` corresponds to the endstop sensor not being triggered.
- `1` corresponds to the endstop sensor being triggered.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Sensor A**

> [!NOTE]
> Compatibility
> 
> This command is available on MachineMotion software releases v3.4.0 and newer.

**Description**

Queries whether or not the sensor plugged into the port “A” of a given motor is triggered.

Note: This is especially useful for querying the state of conveyor motor sensors. For the step-servo motors, we recommend using rather “**Get Home Sensor**” and “**Get End Sensor**”. See [MachineMotion AI Actuator Configuration End-of-travel sensors](/technicaldocumentation/docs/machinemotion-ai-actuator-configuration#endoftravel-sensors) for more information on endstop sensors.

**Format**

`getSensorA_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getSensorA_2,1` returns whether the first motor connected to port 2 has the sensor plugged into port “A” triggered or not.

**Response**

- `0` corresponds to the sensor not being triggered.
- `1` corresponds to the sensor being triggered.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Sensor B**

> [!NOTE]
> Compatibility
> 
> This command is available on MachineMotion software releases v3.4.0 and newer.

**Description**

Queries whether or not the sensor plugged into the port “B” of a given motor is triggered.

Note: This is especially useful for querying the state of conveyor motor sensors. For the step-servo motors, we recommend using rather “**Get Home Sensor**” and “**Get End Sensor**”. See [MachineMotion AI Actuator Configuration End-of-travel sensors](/technicaldocumentation/docs/machinemotion-ai-actuator-configuration#endoftravel-sensors) for more information on endstop sensors.

**Format**

`getSensorB_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;index&gt;` :

- `&lt;port&gt;` is the motor address (port)
- `&lt;index&gt;` is the motor address (index)

**Usage**

`getSensorB_2,1` returns whether the first motor connected to port 2 has the sensor plugged into port “A” triggered or not.

**Response**

- `0` corresponds to the sensor not being triggered.
- `1` corresponds to the sensor being triggered.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Digital Input**

**Description**

Reads a digital input from a Digital IO Module or a Push Button Module.

**Format**

`getDigitalInput_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;module&gt;` :

- `&lt;port&gt;` is the module’s address (port it is connected to)
- `&lt;module&gt;` is the module’s address (device ID)
- `&lt;input&gt;` is the input pin number to read on the module. This is an optional parameter.

**Usage**

`getDigitalInput_1,2,0` returns the current value of the input pin 0 from the module having the device ID 2, connected to the Control port 1.

`getDigitalInput_1,2` returns the current value of all the input pins of the module having the device ID 2, connected to the Control port 1.

**Response**

- A pin can have a value of `0` or `1` .
- The value of all the pins of the module will be represented as a byte. For example, `15` corresponds to `0b1111` , meaning that all 4 input pins of the module currently have a value of `1` .
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get Digital Output**

**Description**

Reads a digital output from a Digital IO Module or a Power Switch Module.

**Format**

`getDigitalOutput_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;module&gt;` :

- `&lt;port&gt;` is the module’s address (port it is connected to)
- `&lt;module&gt;` is the module’s address (device ID)
- `&lt;output&gt;` is the output pin number to read on the module. This is an optional parameter.

**Usage**

`getDigitalOutput_1,2,0` returns the current value of the output pin 0 from the module having the device ID 2, connected to the Control port 1.

`getDigitalOutput_1,2` returns the current value of all the output pins of the module having the device ID 2, connected to the Control port 1.

**Response**

- A pin can have a value of `0` or `1` .
- The value of all the pins of the module will be represented as a byte. For example, `15` corresponds to `0b1111` , meaning that all 4 output pins of the module currently have a value of `1` .
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Set Digital Output**

**Description**

Writes a digital output from a Digital IO Module or a Power Switch Module.

**Format**

`setDigitalOutput_&lt;Payload&gt;`

Where `&lt;Payload&gt;` corresponds to `&lt;port&gt;, &lt;module&gt;` :

- `&lt;port&gt;` is the module’s address (port it is connected to)
- `&lt;module&gt;` is the module’s address (device ID)
- `&lt;output&gt;` is the output pin number to write on the module
- `&lt;value&gt;` is the value to write to the pin

**Usage**

`setDigitalOutput_1,2,0,1` writes the value `1` to the output pin 0 of the module having the device ID 2, connected to the Control port 1.

**Response**

- `1` corresponds to a success
- `0` corresponds to a failure
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get User Input**

**Description**

Reads a the value of a retained mqtt topic on the MachineMotion corresponding to a custom user input.

**Format**

`getUserInput_&lt;inputName&gt;`

Where `&lt;inputName&gt;` corresponds to the mqtt topic name.

**Usage**

`getUserInput_CUSTOMINPUT` returns the retained message of the mqtt topic `tsapi/userInput/CUSTOMINPUT` .

**Response**

- A String corresponding to retained message on the given mqtt topic.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Get User Output**

**Description**

Reads a the value of a retained mqtt topic on the MachineMotion corresponding to a custom user output.

**Format**

`getUserOutput_&lt;outputName&gt;`

Where `&lt;outputName&gt;` corresponds to the mqtt topic name.

**Usage**

`getUserOutput_CUSTOMOUTPUT` returns the retained message of the mqtt topic `tsapi/userOutput/CUSTOMOUTPUT` .

**Response**

- A String corresponding to retained message on the given mqtt topic.
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

#### **Set User Output**

**Description**

Writes a the value of a retained mqtt topic on the MachineMotion corresponding to a custom user output.

**Format**

`setUserOutput_&lt;outputName&gt;,&lt;outputValue&gt;`

Where:

- `&lt;outputName&gt;` corresponds to the mqtt topic name
- `&lt;outputValue&gt;` corresponds to the mqtt message

**Usage**

`setUserOutput_CUSTOMOUTPUT,CUSTOMMESSAGE` writes the retained message `CUSTOMMESSAGE` on the mqtt topic `tsapi/userOutput/CUSTOMOUTPUT` .

**Response**

- `1` corresponds to a success
- `0` corresponds to a failure
- `ERROR &lt;#&gt;` corresponds to a failure, where `&lt;#&gt;` will be the number corresponding to the error.

### List of error numbers

| Error Number | Error Description |
| --- | --- |
| 2 | Motion server not found |
| 3 | Bad request |
| 4 | Cannot read value |
| 5 | Bad input value |
| 6 | Input value is out of range |
| 7 | Motor not connected |
| 8 | Missing input value |
| 98 | Endpoint not found |
| 99 | Unknown error |

## Documentation for Previous Releases

****TCP Socket API for MachineMotion AI****

**MachineMotion AI v3.0.0** : not supported

**MachineMotion AI v3.1.0** :

- Initial release.

**MachineMotion AI v3.2.0 and newer**:

- Introduced a breaking change by adding an end of line character to every command.
- Introduced the heartbeat mechanism as well.

****Low-Level Socket API for MachineMotion V2****

[Application Programming Interface: Low-Level Sockets for MachineMotion V2 SW V2.0](https://cdn.document360.io/3eee4d14-5ca0-4ea6-b426-1c19393e6a5e/Images/Documentation/application-programming-interface-low-level-sockets-v2.pdf)

[Application Programming Interface: Low-Level Sockets for MachineMotion V2 SW V2.3](https://cdn.document360.io/3eee4d14-5ca0-4ea6-b426-1c19393e6a5e/Images/Documentation/Application%20Programming%20Interface%20LowLevel%20Sockets%20for%20MachineMotion.pdf)

****Low-Level Socket API for MachineMotion V1****

[Application Programming Interface: Low-Level Sockets V1 User Manual](https://cdn.document360.io/3eee4d14-5ca0-4ea6-b426-1c19393e6a5e/Images/Documentation/Application-Programming-Interface-Low-Level-Sockets-User-manual.pdf)
