Skip to main content

Adapting TCP Devices

This example shows how to use the dobot-plus skill in an AI Agent to adapt external devices that communicate over TCP/IP. Unlike Modbus protocols, TCP devices typically use custom messages (strings or binary frames). The Skill generates plugin scaffolding from message formats and function descriptions in Requirements.md—you only need to prepare the document and invoke /dobot-plus in the IDE.

Example Workflow​

Environment Setup​

Confirm the following before development. See Development Environment for more detail.

DependencyVersion / Notes
Node.jsv20 or later
IDESupports Agent Skills (e.g. Cursor)
@dobot-plus/cliGlobal install; provides the dpt command
@dobot-plus/skillGlobal install; provides the /dobot-plus skill

Install:

npm install -g @dobot-plus/cli @dobot-plus/skill@latest

Verify:

node -v    # Should print v20.x or later
dpt -v # Confirm CLI works

After install, the Skill is deployed to ~/.agents/skills/dobot-plus. Enable Agent Skills in your IDE settings to use it.

Provide a Developer Manual​

Collect the device developer manual yourself and place the PDF in the user_manual folder at the project root.

user_manual

The developer manual should include the following:

CategoryDescription
Communication protocolProtocol type TCP, connection role (client / server)
IP addressDevice or host IP, e.g. 192.168.5.1
Port numberTCP port, e.g. 123
Message formatSend templates, response format, delimiters, terminators (e.g. \n)
Function semanticsEach atomic operation exposed externally (send command / read response / status query)
Operation flowTypical interaction sequence (connect → send → wait for response → disconnect or keep alive)

A user manual can contain multiple PDF files. The Agent Skill reads the contents of user_manual, consolidates the functions into a Requirements.md product requirements document, and then develops the plugin from that document. If the manual is missing required communication protocol or function descriptions, the Agent Skill stops.

Run the Skill​

Select Agent mode.

Agents

Invoke the /dobot-plus skill.

Requirements.md

Device Examples​

The example below controls an external lift column over TCP/IP: send position commands and read responses. Run dpt create first, then write Requirements.md.

Lift column TCP control​

Create project:

dpt create

Example prompts:

$ dpt create
? Please input plugin name: lift
? Please input plugin description: A plugin demo for lift control via TCP
? Please input plugin version: 1-0-0-test
? Please input device IP: 192.168.5.1

Then:

cd lift
Full lift TCP Requirements.md example
# Lift Column TCP Control

> Send position commands to an external lift column over TCP/IP and read device responses.

## 1. Device overview

This plugin controls an external lift column using custom TCP messages—no Modbus or I/O communication.

## 2. Communication protocol

| Item | Description |
| ---------------- | -------------------------------------- |
| Protocol | TCP |
| Connection role | Robot acts as **TCP client** |
| IP address | 192.168.5.1 |
| Port | 123 |
| Message encoding | ASCII string, terminated with `\n` |

## 3. Message protocol

### 3.1 Move to absolute position

- **Send format:** `moveTo_absolutePosition,<position>\n`
- **Parameter:** `position` is an integer (mm or device-specific unit)
- **Response:** Device returns a confirmation string (mark as TBD if unknown)

**Examples:**

| Action | Send message |
| ----------- | ------------------------------- |
| Move to 100 | `moveTo_absolutePosition,100\n` |
| Move to 50 | `moveTo_absolutePosition,50\n` |

## 4. Functions

### 4.1 MoveTo — move to specified position

- Action: call `sendRequest("moveTo_absolutePosition," .. position .. "\n")`
- Parameter: position (number, target position)
- UI: input + button

### 4.2 MoveUp — move up

- Action: add a fixed offset (e.g. +50) to current position, send `moveTo_absolutePosition,<newPosition>\n`
- UI: button

### 4.3 MoveDown — move down

- Action: subtract a fixed offset (e.g. -50) from current position, send `moveTo_absolutePosition,<newPosition>\n`
- UI: button

## 5. Operation flow

1. Establish TCP connection on plugin load (IP + port from `function.json` protocol config)
2. User clicks "Move up" or "Move down"; send the corresponding position command
3. Wait for device response (`sendRequest` reads automatically)
4. Update UI state based on response

## 6. Safety notes

- Confirm IP and port match the device manual before operation
- Position commands must stay within the device travel range
- If there is no response for a long time, check network connectivity and device status

After generation, verify:

  • IP and port in Requirements.md match on-site settings
  • Message format matches the device protocol document
  • Each function describes a single operation

Using the Agent Skill​

Open the plugin project and run this slash command in IDE Chat:

/dobot-plus

skill demo

Import and Use​

  1. Open DobotStudio Pro → Dobot+ plugin manager
  2. Uninstall any same-name plugin first
  3. Import the zip from output/
  4. Use the plugin from the nav bar (UI, blocks, scripts)

Package name pattern:

<plugin-name>_v<major>-<minor>-<patch>-<status>.zip

See Quick Start — Build & Use for screenshots and details.

FAQ​

How to view communication messages​

Create a TCP client using a network debugging tool.

  1. Use the PC as the TCP client
  2. Ensure the network link between the PC, controller, and end device is working properly
  3. Set the TCP client IP and port based on the actual TCP server; in most cases, check the end device's TCP server configuration
  4. Choose HEX or ASCII for the message format based on the actual message content.
  5. Avoid using ports 502, 8080, and 60000 for the TCP server.
  6. When debugging with a virtual controller, the IP address used when creating the TCP client must match the virtual controller's actual IP. You can view the virtual controller IP on the DobotStudio Pro home page under IP Address.

Once connected, you can view bidirectional messages between the plugin and the end device.

Common TCP debugging tools include:

Manual build when Agent packaging fails​

When development and debugging are complete, run from the project root:

dpt build

Outputs:

  • dist/ — built plugin sources for inspection
  • output/ — zip package named <plugin-name>-<version>.zip for import

Skill reports missing Requirements.md​

Ensure Requirements.md is in the project root with IP, port, message format, and function definitions. The Skill will not create it for you.

TCP communication fails​

  • Confirm device IP and port match Requirements.md; controller and device must be reachable on the network
  • Confirm message format (delimiters, terminators) matches the device protocol
  • Verify IP in dpt.json when using dpt dev with a real device
  • See TCP commands for connection and read/write troubleshooting

Poor Agent results​

  • Clarify message format and response parsing in Requirements.md
  • Ensure functions are split into atomic operations (one action per function)
  • Check the Agent model: use GPT-5.4 or newer in VS Code Copilot; Auto mode in Cursor generally works well