Skip to content

Repository files navigation

FlashForge Printer Emulator

A comprehensive dual-protocol network emulator for FlashForge 3D printers

Test FlashForge client applications without physical hardware

Full support for both legacy TCP protocol and modern HTTP API

Protocol Support

ProtocolPortStatusDescription
UDP Discovery48899Full SupportAutomatic printer detection on network
TCP Commands8899Full SupportLegacy G-code protocol for all FlashForge printers
HTTP API8898Full SupportModern REST API for Adventurer 5M/Pro/5X series
Dual-ModeAllFull SupportRun both protocols simultaneously

Printer Mode Emulation

Printer ModelEmulation StatusCamera SupportMaterial StationFiltration System
Adventurer 5MFullNoNoNo
Adventurer 5M ProFullYesNoYes
Adventurer 5XFullYesYes (4-slot IFS)Yes
Legacy Models (3/4)FullNoNoNo

Features

Core Capabilities

FeatureDescription
Dual Protocol OperationRun TCP and HTTP servers simultaneously or independently
Complete Protocol ImplementationFully emulates both FlashForge network protocols
Discovery ProtocolUDP broadcast for automatic printer detection
Material Station Emulation4-slot IFS support for AD5X multi-color printing
Enhanced File ManagementFile metadata, thumbnails, and upload support
Persistent ConfigurationJSON-based auto-save/load configuration system
Cumulative StatisticsTrack lifetime print time and filament usage
Real-time SimulationDynamic temperature changes and print progress
Multi-platformWindows, macOS, and Linux support

HTTP API Endpoints

EndpointMethodDescription
/productPOSTGet printer control states and capabilities
/detailPOSTGet comprehensive printer status and metrics
/controlPOSTSend control commands (temperature, LED, fans, etc)
/gcodeListPOSTGet list of recent and local files
/gcodeThumbPOSTGet base64 thumbnail for file preview
/uploadGcodePOSTUpload new G-code files to printer
/printGcodePOSTStart printing a file from storage

Advanced Features

FeatureDescription
HTTP Monitoring UIReal-time inspection of all API requests and responses
Network SimulationSimulate latency, packet loss, and connection failures
Print Status State MachineMultiple states: ready, busy, printing, paused, completed, cancelled, error
Temperature SimulationRealistic heating and cooling curves
Material Station ControlManage filament slots, colors, and material types for multi-color prints
File Metadata ManagementTrack print time, filament usage, layer counts, and tool configurations
Configuration Auto-saveAutomatic persistence with restart scheduling

Setup

StepCommand
Clone the repositorygit clone https://github.com/Parallel-7/FlashForgeEmulator.git
Navigate to directorycd FlashForgeEmulator
Install dependenciespip install -r requirements.txt

Usage

StepCommand / Description
Start the emulatorpython main.py
GUI ApplicationModern ttkbootstrap interface with tabbed controls
UDP DiscoveryAutomatically broadcasts on port 48899
TCP ServerListens on port 8899 for legacy G-code commands
HTTP ServerListens on port 8898 for REST API requests
Protocol ModeChoose TCP-only, HTTP-only, or Dual-mode operation

Configuration

Printer Identity

SettingDescription
Printer NameCustomize the name displayed to client applications
Serial NumberSet a unique identifier for the emulated printer
Machine TypeSet printer model (5M, 5M Pro, 5X, etc)
Firmware VersionSet the reported firmware version
MAC AddressRequired for HTTP API clients
Check CodeAuthentication code for HTTP API

Protocol Configuration

ModeTCP ServerHTTP ServerUse Case
TCP OnlyRunningStoppedTest legacy clients and older printers
HTTP OnlyStoppedRunningTest modern API clients (5M/Pro/5X)
Dual ModeRunningRunningTest comprehensive client compatibility

Printer Mode Selection

ModeModel EmulatedCameraFiltrationMaterial Station
5MAdventurer 5MNoNoNo
5M ProAdventurer 5M ProYesYesNo
AD5XAdventurer 5XYesYesYes (4-slot IFS)

Material Station (AD5X Mode)

SettingDescription
Slot CountNumber of filament slots (default: 4)
Current SlotActive slot being used for printing
Slot ConfigurationConfigure material type, color, and presence per slot
Material MappingsDefine tool-to-slot mappings for multi-color prints
Loading StateSimulate filament loading and unloading operations

Print Simulation

SettingDescription
Print StatusSet to ready, busy, printing, paused, completed, cancelled, or error
Print ProgressAdjust the reported progress percentage (0-100)
Current FileSet the filename of the currently printing model
Layer ProgressAutomatically calculated based on print progress
Print DurationElapsed time for current print job
Remaining TimeEstimated time remaining for print completion
Filament EstimatesSet total filament length and weight for current job

Temperature Control

SettingDescription
Hotend TemperatureSet current and target temperatures for the hotend
Bed TemperatureSet current and target temperatures for the heated bed
Chamber TemperatureSet chamber temperature (Pro/5X models)
Simulation ModeRealistic heating and cooling curves with configurable rates
Idle TemperaturesDefault temperatures when not printing

Network Simulation

SettingDescription
Network InterfaceSelect which network interface to use for discovery
Latency SimulationAdd artificial delay to responses (testing robustness)
Packet LossSimulate random connection failures
Connection FailuresTest client retry and error handling

Statistics Tracking

StatisticDescription
Cumulative Print TimeTotal lifetime print time in minutes
Cumulative FilamentTotal lifetime filament usage in meters
Job HistoryTrack completed prints and their metadata
Auto-persistenceStatistics saved automatically to configuration file

Supported Commands

TCP Protocol - Status Commands

CommandDescription
M115Get printer information and capabilities
M105Get current temperature readings
M119Get endstop and machine status
M27Get print status and progress
M114Get current position (X/Y/Z)

TCP Protocol - Control Commands

CommandDescription
M601/M602Login and logout authentication
M146Control LED on/off
M405/M406Control filament runout sensor
G28Home all axes
G1Move printer head to position
M24/M25/M26Resume, pause, and stop print
M104/M140Set extruder and bed temperature
M109/M190Set and wait for temperature targets
M661List files on printer storage
M662Get thumbnail image for a file

HTTP API - Control Commands

CommandParametersDescription
switchLightstatus: open/closeControl printer LED
setTargetTemperatureheaterIndex, temperatureSet target temperature for extruder or bed
setChamberTemperaturetemperatureSet chamber target temperature (Pro/5X)
setExternalFanstatus: open/closeControl external filtration fan (Pro/5X)
setInternalFanstatus: open/closeControl internal filtration fan (Pro/5X)
pause-Pause current print
resume-Resume paused print
cancel-Cancel current print

User Interface

TabDescription
MainBasic controls, server start/stop, protocol mode selection, status logging
ConfigurationPrinter identity, protocol mode, printer mode, virtual file management
Printer StateTemperature controls, print status, progress simulation, filament estimates
Material Station4-slot IFS configuration for multi-color printing (AD5X mode)
HTTP MonitorReal-time inspection of all HTTP API requests and responses
NetworkInterface selection, network simulation settings
Printer DetailsHardware specifications and dimensions
FilesystemVirtual file system and metadata management
LogsApplication logging and debugging output

Protocol Details

UDP Discovery Protocol

PropertyValue
ProtocolUDP Broadcast
Port48899
Response FormatBinary format with printer name and serial number
PurposeAutomatic printer detection by FlashForge clients
CompatibilityAll FlashForge printers and client software

TCP Command Protocol

PropertyValue
ProtocolTCP
Port8899
Command Format~GCODE [parameters]
Response FormatCMD GCODE Received.[newline][response data][newline]ok
Use CaseLegacy protocol for Adventurer 3/4 and older models
Client CompatibilityFlashPrint, OrcaSlicer (legacy mode), custom clients

HTTP REST API

PropertyValue
ProtocolHTTP/1.1
Port8898
FormatJSON request/response bodies
AuthenticationSerial number and check code validation
Use CaseModern protocol for Adventurer 5M/Pro/5X series
Client CompatibilityFlashForgeUI, OrcaSlicer (new API mode), custom clients

File Management

FeatureDescription
Virtual FilesPre-configured test files with metadata
File UploadSimulate file uploads via HTTP API
Thumbnail StorageBase64-encoded preview images
File MetadataTrack print time, filament usage, layer counts
Multi-color FilesSupport for Material Station tool mappings
Recent FilesReturn last 10 files for client display
Local FilesFull file list with detailed metadata (mode-dependent)

File Metadata Fields

FieldDescription
gcodeFileNameName of the G-code file
printingTimeEstimated print duration in seconds
uploadTimeISO timestamp of file upload
fileSizeFile size in bytes
totalFilamentWeightTotal filament weight in grams
useMatlStationWhether file uses Material Station (multi-color)
gcodeToolCntNumber of tools/extruders used
gcodeToolDatasArray of tool configurations with slot mappings

Testing Coverage

Client SoftwareProtocolTesting StatusNotes
FlashForgeUIHTTP APIFully TestedAll printer modes supported
OrcaSlicerTCP + HTTPFully TestedBoth legacy and new API modes
Orca-FlashForgeTCPFully TestedLegacy protocol support
FlashPrintTCPFully TestedOfficial FlashForge software
Custom ClientsBothSupportedFull protocol documentation available

Development

ToolPurpose
Claude Code IntegrationCLAUDE.md file provides AI assistant context
Configuration PersistenceJSON auto-save prevents data loss
Hot ReloadConfiguration changes applied without restart where possible
HTTP MonitoringBuilt-in request/response inspection for debugging
Network SimulationTest client robustness under adverse conditions

Architecture

ComponentFileDescription
Core Emulatoremulator/printer.pyCentral state management and coordination
TCP Serveremulator/server.pyLegacy protocol server
HTTP Serveremulator/http_server_async.pyAsync HTTP API server using aiohttp
Command Processingemulator/commands.pyG-code command parser and dispatcher
HTTP Responsesemulator/http_responses.pyJSON response generation for REST API
File Manageremulator/file_manager.pyEnhanced file and metadata management
Printer Modesemulator/printer_modes.pyMode-specific features and Material Station
Configurationconfig.pyCentralized configuration and defaults

Dependencies

PackagePurpose
ttkbootstrapModern GUI theming and widgets
PillowThumbnail image processing
aiohttpAsync HTTP server implementation
Standard Libraryasyncio, threading, json, socket, struct

About

FlashForge 3D Printer API Emulator

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages