-
Notifications
You must be signed in to change notification settings - Fork 3
TCP Protocol
The FlashForge TCP protocol is the primary control interface for legacy printers (Adventurer 3 / 4 Pro). For modern printers (5M / AD5X), it serves as a low-level fallback. It operates on port 8899.
| Property | Value |
|---|---|
| Port | 8899 |
| Protocol | Raw TCP (text-based) |
| Concurrency | Multi-threaded server (up to 10 concurrent connections) |
| Authentication | None (local network only) |
| Keep-Alive | Recommended; connections may timeout after inactivity |
-
Establish Connection: Connect to the printer's TCP socket on port 8899.
-
Request Control (M601): Send the
M601 S1command to request control of the printer.Successful Response:
CMD M601 Received. Control Success V2.1. okFailure Response: If you receive "Control Failed", a previous TCP connection is still open, or another application is connected. Close the previous connection with
M602. -
Release Control (M602): Before disconnecting, send the
M602command to release control.Response:
CMD M602 Received. Control Release. ok
The printer closes an idle connection after about 30 seconds (5M series). To maintain the connection, send a command at least every 20 seconds. The M27 (Print Status) command is suitable for this purpose.
All commands MUST be prefixed with a tilde ~.
| Component | Format | Example |
|---|---|---|
| Prefix | ~ |
~M115 |
| Command | G or M code | ~G28 |
| Parameters | Space-separated | ~G1 X10 Y10 F3000 |
| Terminator | \r\n |
(implicit) |
Examples:
~M115
~G28
~G1 X10 Y10 Z0.3 F3000
~M104 S210
Responses are text-based and typically end with ok or an error message.
| Type | Format |
|---|---|
| Success | CMD <Command> Received.\r\n...data...\r\nok\r\n |
| Ack | ack: ok\r\n |
| Error | Error: <reason>\r\n |
| Feature | Legacy (A3 / A4) | Modern (5M / AD5X) |
|---|---|---|
| Primary Use | Full Control (Motion, File, Status) | Fallback / Raw Motion |
| M27 Status | Returns text SD printing byte...
|
Returns text (parsed for state) |
| File Upload | Binary M28/M29 sequence | HTTP POST preferred |
| Authentication | None | None |
Returns detailed information about the printer.
Command: ~M115
Response Example:
CMD M115 Received.
Machine Type: Flashforge Adventurer 5M Pro
Machine Name: Adventurer 5M Pro
Firmware: v3.1.5
SN: SNXXXXXXX1234
X: 220 Y: 220 Z: 220
Tool Count: 1
Mac Address:XX:XX:XX:XX:XX:XX
ok
Returns basic information about the current print job's progress.
Command: ~M27
Response Example:
CMD M27 Received.
SD printing byte 0/100
Layer: 0/0
ok
Returns current and target temperatures for the extruder(s) and heated bed.
Command: ~M105
Response (New Format):
CMD M105 Received.
T0:17.9/0.0 T1:0.0/0.0 B:18.5/0.0
ok
Response (Old Format):
CMD M105 Received.
T0:22 /0 B:11/0
ok
| Field | Description |
|---|---|
| T0 | Primary extruder (Current/Target) |
| T1 | Secondary extruder (Current/Target) |
| B | Heated bed (Current/Target) |
Returns endstop states, machine status, movement mode, LED status, and current filename.
Command: ~M119
Response Example:
CMD M119 Received.
Endstop: X-max: 110 Y-max: 110 Z-min: 0
MachineStatus: READY
MoveMode: READY
Status: S:1 L:0 J:0 F:0
LED: 1
CurrentFile:
ok
| Field | Description |
|---|---|
| Endstop | X, Y, Z endstop states |
| MachineStatus | Overall printer state (see table below) |
| MoveMode | Movement state (MOVING, PAUSED, READY, WAIT_ON_TOOL, HOMING) |
| Status | Condensed status (S: System, L: LED, J: Job, F: Fan) |
| LED | LED status (1 = ON, 0 = OFF) |
| CurrentFile | Name of file being printed |
MachineStatus Values:
| Status | Description |
|---|---|
| READY | Printer idle and ready |
| BUILDING_FROM_SD | Printing from storage |
| BUILDING_COMPLETED | Print finished |
| PAUSED | Print paused |
| BUSY | Performing non-printing operation |
Returns the current X, Y, Z coordinates and extruder positions.
Command: ~M114
Response Example:
CMD M114 Received.
X:110.050 Y:110.050 Z:200.000 A:0.000 B:0
ok
Returns a list of all files stored on the printer's local storage.
Command: ~M661
Important: The primary data is sent after the initial ok confirmation.
Response Example:
CMD M661 Received.
ok
D::/data/File1.3mf::/data/File2.gcode::/data/File3.gx
The data following ok contains file paths delimited by special characters.
Returns a PNG thumbnail image for the specified file.
Command: ~M662 <file_path>
Example: ~M662 /data/MyModel.gcode
Important: The binary PNG data is sent after the initial ok confirmation.
Response Example:
CMD M662 Received.
ok
[Raw PNG binary data...]
Initiates the homing sequence for specified axes.
Command: ~G28 [X] [Y] [Z]
| Parameter | Description |
|---|---|
| (none) | Home all axes (X, Y, Z) |
| X Y | Home X and Y only |
| Z | Home Z only |
Response:
CMD G28 Received.
ok
Move the print head to specified coordinates.
Command: ~G1 [X<pos>] [Y<pos>] [Z<pos>] [E<pos>] [F<feedrate>]
| Parameter | Description |
|---|---|
| X | Target X position (mm) |
| Y | Target Y position (mm) |
| Z | Target Z position (mm) |
| E | Extruder position (mm) |
| F | Feedrate (mm/min) |
Implementation Quirk: If the E parameter is included, the firmware automatically injects a G92 E0 command before the move to prevent extruder position accumulation errors.
Blocking: Motion commands are ignored if a print job is active.
Response:
CMD G1 Received.
ok
Set all axes to use absolute coordinates.
Command: ~G90
Set all axes to use relative coordinates.
Command: ~G91
Reset the coordinate system without moving.
Command: ~G92 [X<pos>] [Y<pos>] [Z<pos>] [E<pos>]
Starts printing a specified file from local storage.
Command: ~M23 0:<file_path>
Example: ~M23 0:/user/Benchy.gcode
Path Formats:
/user/file_name.gcode/data/model.3mf
Response:
CMD M23 Received.
ok
Resumes a paused print job.
Command: ~M24
Pauses the current print job.
Command: ~M25
Stops the current print job immediately.
Command: ~M26
Important: After you stop a job over TCP, you cannot control the printer. Clear the cancelled job dialog from the screen to restore control.
Sets the target temperature for the primary extruder (asynchronous).
Command: ~M104 S<temperature>
| Value | Description |
|---|---|
| S0 | Disable extruder heating |
| S210 | Set to 210C |
Examples:
~M104 S210
~M104 S0
Sets the target temperature for the heated bed (asynchronous).
Command: ~M140 S<temperature>
| Value | Description |
|---|---|
| S0 | Disable bed heating |
| S60 | Set to 60C |
Examples:
~M140 S60
~M140 S0
Controls the printer's internal LED lights.
Command: ~M146 r<red> g<green> b<blue> F0
| Parameter | Range | Description |
|---|---|---|
| r | 0-255 | Red intensity |
| g | 0-255 | Green intensity |
| b | 0-255 | Blue intensity |
| F | 0 | Control flag (typically 0) |
Examples:
~M146 r255 g255 b255 F0 (White, ON)
~M146 r0 g0 b0 F0 (OFF)
Note: Use M146 instead of M144/M145 to avoid EEPROM wear.
Turns the cooling fan on.
Command: ~M106 [S<speed>]
| Model | Speed Support |
|---|---|
| Adventurer 3 | On/Off only |
| 5M Series | Variable speed (S0-255) |
Turns the cooling fan off.
Command: ~M107
Immediately halts all printer activity.
Command: ~M112
Warning: This command causes an immediate halt. On some printers, axes are homed and heaters are turned off. The print job cannot be recovered after M112.
5M series: M112 returns an echo reply and performs no action. Stop a print with M26 or the HTTP jobCtl_cmd cancel action instead.
The commands below return a normal reply but perform no action on 5M-series firmware:
| Command | Reply |
|---|---|
| M108 | Echo only |
| M144 | Echo only |
| M145 | Echo only |
| M611 | Echo only |
| M612 | Echo only |
| M653 | Echo only |
| M654 | Echo only |
| Command | Purpose | Notes |
|---|---|---|
~M610 <name> |
Rename the printer | Same action as HTTP reName_cmd
|
~M650 |
Read XY offset | Returns fixed placeholder values X: 1.0 Y: 0.5
|
~M651 |
Chamber fan on | Sets the chamber fan to full speed |
~M652 |
Chamber fan off | Stops the chamber fan |
~M663 S<pct> |
Set print speed percentage | Applies to the active print |
Requests control of the printer. Send this command before most other commands.
Command: ~M601 S1
Releases control of the printer. Send this command before you disconnect.
Command: ~M602
Renames the printer.
Command: ~M610 <new_name>
Warning: Triggers a network service restart, which may briefly drop the connection.
For Adventurer 3/4 Pro printers, files can be uploaded via TCP using the M28/M29 sequence. Modern printers (5M/AD5X) should use HTTP /uploadGcode instead.
Command: ~M28 <filesize> 0:/user/<filename>
Requirements:
- Path MUST start with
0:/user/ - Filesize must match the exact byte count
Response:
CMD M28 Received.
ok
Error: Error: Not enough space
After receiving ok, send the raw binary file content:
- Do NOT prefix with
~ - Do NOT escape characters
- Send exactly
<filesize>bytes
Command: ~M29
Behavior:
- If bytes match expected size: Saves file, returns
ack: "ok" - If mismatch: Deletes temp file, returns
File Is Not Aviable(the spelling error is in the firmware)
-
Path validation: The firmware validates the M28 path argument against the pattern
^\s*(\d+)\s+(0:/user/([^\n]+)). Paths not matching this regex are rejected. - Timeout behavior: The upload timeout resets on every chunk received. There is no fixed overall timeout for the entire transfer, only an inactivity timeout between chunks.