bambu-printer-mcp 1.1.91 → 1.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTORS.md +2 -0
- package/README.md +5 -3
- package/dist/bambu-native.js +1 -1
- package/dist/cad/contracts.js +16 -7
- package/dist/cad/examples.d.ts +2 -1
- package/dist/cad/examples.js +13 -10
- package/dist/cad/serial.d.ts +1 -1
- package/dist/cad/serial.js +4 -6
- package/dist/cad-engine.js +17 -12
- package/dist/index.js +39 -23
- package/dist/printers/bambu.d.ts +6 -0
- package/dist/printers/bambu.js +32 -6
- package/dist/safety/limits.d.ts +6 -0
- package/dist/safety/limits.js +8 -0
- package/dist/safety/print-file.js +2 -2
- package/dist/safety/printer-state.d.ts +4 -0
- package/dist/safety/printer-state.js +14 -1
- package/dist/studio-print-options.d.ts +9 -0
- package/dist/studio-print-options.js +34 -2
- package/package.json +1 -1
- package/src/bambu-native.ts +1 -1
- package/src/cad/contracts.ts +17 -7
- package/src/cad/examples/bag_clip.py +1 -0
- package/src/cad/examples/bistable_clicker.py +1 -0
- package/src/cad/examples/broom_grip.py +61 -0
- package/src/cad/examples/cable_clip.py +1 -0
- package/src/cad/examples/chainmail.py +1 -0
- package/src/cad/examples/desk_clamp_hook.py +91 -0
- package/src/cad/examples/desk_edge_cable_holder.py +55 -0
- package/src/cad/examples/drawer_divider.py +56 -0
- package/src/cad/examples/hinged_box.py +1 -0
- package/src/cad/examples/knurled_knob.py +1 -0
- package/src/cad/examples/loft_handle.py +1 -0
- package/src/cad/examples/organizer_tray.py +41 -0
- package/src/cad/examples/phone_stand.py +1 -0
- package/src/cad/examples/plant_pot.py +53 -0
- package/src/cad/examples/shelf_bracket.py +53 -0
- package/src/cad/examples/swept_hook.py +1 -0
- package/src/cad/examples/threaded_jar.py +1 -0
- package/src/cad/examples/trigger_capo.py +1 -0
- package/src/cad/examples/wall_hook.py +1 -0
- package/src/cad/examples.ts +13 -10
- package/src/cad/geometry.py +6 -0
- package/src/cad/serial.ts +4 -6
- package/src/cad-engine.ts +9 -3
- package/src/index.ts +36 -19
- package/src/printers/bambu.ts +30 -5
- package/src/safety/limits.ts +8 -0
- package/src/safety/print-file.ts +2 -2
- package/src/safety/printer-state.ts +13 -1
- package/src/studio-print-options.ts +33 -2
package/src/index.ts
CHANGED
|
@@ -76,7 +76,7 @@ import { resolveStudioPrintOptions, usedNozzleCount, type CallerPrintOptions } f
|
|
|
76
76
|
import { inspectPrintFile } from "./safety/print-file.js";
|
|
77
77
|
import { previewPrintFile } from "./safety/print-preview.js";
|
|
78
78
|
import { loadSafe3mfArchive } from "./safety/archive.js";
|
|
79
|
-
import { SERIAL_MODELS, externalStorageState, validatePrinterState } from "./safety/printer-state.js";
|
|
79
|
+
import { SERIAL_MODELS, internalPrintingSupported, externalStorageState, validatePrinterState } from "./safety/printer-state.js";
|
|
80
80
|
import { isDualNozzleModel } from "./safety/limits.js";
|
|
81
81
|
import { withPrinterOperation, withPrintSnapshot, uniquePrintName } from "./safety/artifact.js";
|
|
82
82
|
import { detectProfilesRoot } from "./slicer/profile-flatten.js";
|
|
@@ -184,17 +184,26 @@ function withEmergencyMqttTimeout<T>(send: (signal: AbortSignal) => Promise<T>):
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
|
-
* Whether
|
|
187
|
+
* Whether a native print stores its job on the SD card or USB stick
|
|
188
188
|
* (true) or internal storage (eMMC). An explicit try_emmc_print wins, then
|
|
189
189
|
* BAMBU_NATIVE_TRY_EMMC_PRINT read as the helper reads it; otherwise a ready
|
|
190
190
|
* card is used, as OrcaSlicer does, so the job can be reprinted from the
|
|
191
|
-
* printer and read over FTPS.
|
|
191
|
+
* printer and read over FTPS. X1C internal printing additionally requires
|
|
192
|
+
* the capability bit from fresh status, including at final dispatch.
|
|
192
193
|
*/
|
|
193
|
-
function nativeExternalStorage(tryEmmcPrint: boolean | undefined, raw: unknown): boolean {
|
|
194
|
-
if (tryEmmcPrint !== undefined) return !tryEmmcPrint;
|
|
194
|
+
function nativeExternalStorage(tryEmmcPrint: boolean | undefined, raw: unknown, model: string): boolean {
|
|
195
195
|
const configured = process.env.BAMBU_NATIVE_TRY_EMMC_PRINT?.trim();
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
const external = tryEmmcPrint !== undefined ? !tryEmmcPrint
|
|
197
|
+
: configured ? !["1", "true", "TRUE", "yes"].includes(configured)
|
|
198
|
+
: externalStorageState(raw) === "normal";
|
|
199
|
+
if (!external) assertNativeInternalStorage(model, raw);
|
|
200
|
+
return external;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function assertNativeInternalStorage(model: string, raw: unknown): void {
|
|
204
|
+
if (model === "x1c" && !internalPrintingSupported(raw)) {
|
|
205
|
+
throw new Error("X1C internal printing is not advertised in the fresh status. Use a ready SD card or USB stick; unsupported internal storage requests are refused.");
|
|
206
|
+
}
|
|
198
207
|
}
|
|
199
208
|
|
|
200
209
|
function requestedPrintNozzles(args: Record<string, any>): number[] | undefined {
|
|
@@ -248,6 +257,11 @@ type BambuModel = typeof VALID_BAMBU_MODELS[number];
|
|
|
248
257
|
// the dual-nozzle H2 path. Keep it in this gate so pre-sliced multi-filament
|
|
249
258
|
// jobs take the correct branch instead of the legacy 5-slot mapping.
|
|
250
259
|
const H2_BAMBU_MODELS = new Set<string>(["h2d", "h2dpro", "h2s", "h2c", "x2d"]);
|
|
260
|
+
// Models that may print and upload over connection_mode=bambu_native. X2D
|
|
261
|
+
// defaults to it. X1C opts in: firmware 01.12.00.00 was seen refusing every
|
|
262
|
+
// direct FTPS STOR with 553 while Bambu Studio's plug-in still printed.
|
|
263
|
+
const NATIVE_ROUTE_MODELS = new Set<string>(["x2d", "x1c"]);
|
|
264
|
+
const NATIVE_ROUTE_RESTRICTION = "connection_mode=bambu_native is restricted to X2D and X1C.";
|
|
251
265
|
|
|
252
266
|
const VALID_BED_TYPES = ["textured_plate", "cool_plate", "engineering_plate", "hot_plate", "supertack_plate"] as const;
|
|
253
267
|
const VALID_NOZZLE_TYPES = ["stainless_steel", "hardened_steel", "tungsten_carbide", "brass"] as const;
|
|
@@ -1829,7 +1843,7 @@ class BambuPrinterMCPServer {
|
|
|
1829
1843
|
printNozzle
|
|
1830
1844
|
);
|
|
1831
1845
|
if (native && args.use_ams !== false && !useAMS) {
|
|
1832
|
-
throw new Error("Native
|
|
1846
|
+
throw new Error("Native printing requires ams_mapping, ams_slots, auto_match_ams, or explicit use_ams: false for an external spool.");
|
|
1833
1847
|
}
|
|
1834
1848
|
const threeMfFilename = path.basename(threeMFPath);
|
|
1835
1849
|
const projectName = String(args?.project_name || args?.task_name || threeMfFilename.replace(/\.3mf$/i, ''));
|
|
@@ -1931,7 +1945,7 @@ class BambuPrinterMCPServer {
|
|
|
1931
1945
|
|
|
1932
1946
|
assertActive();
|
|
1933
1947
|
if (native) {
|
|
1934
|
-
const externalStorage = nativeExternalStorage(args?.try_emmc_print, confirmedStatus.raw);
|
|
1948
|
+
const externalStorage = nativeExternalStorage(args?.try_emmc_print, confirmedStatus.raw, printModel);
|
|
1935
1949
|
if (externalStorage && externalStorageState(confirmedStatus.raw) !== "normal") {
|
|
1936
1950
|
throw new Error("External storage was requested, but the printer reports no ready SD card or USB stick.");
|
|
1937
1951
|
}
|
|
@@ -1961,6 +1975,7 @@ class BambuPrinterMCPServer {
|
|
|
1961
1975
|
if (externalStorage && externalStorageState(dispatchStatus.raw) !== "normal") {
|
|
1962
1976
|
throw new Error("The printer's SD card or USB stick is no longer ready. Check it and start the print again.");
|
|
1963
1977
|
}
|
|
1978
|
+
if (!externalStorage) assertNativeInternalStorage(printModel, dispatchStatus.raw);
|
|
1964
1979
|
assertActive();
|
|
1965
1980
|
this.bambu.recordFlightDispatch(devIp,devId,remoteFileName,requirements,resumeFile);
|
|
1966
1981
|
markPrintCommandSent();
|
|
@@ -2085,7 +2100,7 @@ class BambuPrinterMCPServer {
|
|
|
2085
2100
|
): Promise<Record<string, unknown>> {
|
|
2086
2101
|
assertBambuNativeAvailable();
|
|
2087
2102
|
const model = await this.resolveBambuModel(args.bambu_model);
|
|
2088
|
-
if (model
|
|
2103
|
+
if (!NATIVE_ROUTE_MODELS.has(model)) throw new Error(NATIVE_ROUTE_RESTRICTION);
|
|
2089
2104
|
return this.print3mfViaBambuNetwork(
|
|
2090
2105
|
{ ...args, bambu_model: model, connection_type: "lan", bambu_network_method: "start_local_print" },
|
|
2091
2106
|
host, bambuSerial, bambuToken, { onUpdate, signal }
|
|
@@ -2098,9 +2113,9 @@ class BambuPrinterMCPServer {
|
|
|
2098
2113
|
): Promise<Record<string, unknown>> {
|
|
2099
2114
|
if (args.print) throw new Error("Native upload never starts printing; use print_3mf.");
|
|
2100
2115
|
// Resolve and enforce the model first, as the print path does, so a
|
|
2101
|
-
//
|
|
2116
|
+
// request for another model is never told to install the native helper.
|
|
2102
2117
|
const model = await this.resolveBambuModel(args.bambu_model);
|
|
2103
|
-
if (model
|
|
2118
|
+
if (!NATIVE_ROUTE_MODELS.has(model)) throw new Error(NATIVE_ROUTE_RESTRICTION);
|
|
2104
2119
|
assertBambuNativeAvailable();
|
|
2105
2120
|
const unsupported = ["use_ams", "ams_mapping", "ams_mapping2", "ams_mapping_info", "nozzle_mapping", "nozzles_info",
|
|
2106
2121
|
"bed_leveling", "flow_calibration", "vibration_calibration", "layer_inspect", "timelapse"];
|
|
@@ -2962,7 +2977,7 @@ class BambuPrinterMCPServer {
|
|
|
2962
2977
|
nozzle_mapping: { type: "string", description: "Raw JSON string for FULU PrintParams nozzle_mapping." },
|
|
2963
2978
|
nozzles_info: { type: "string", description: "Raw JSON string for FULU PrintParams nozzles_info." },
|
|
2964
2979
|
bed_leveling: { type: "boolean", description: "Auto bed leveling on or off. Omit to send what Bambu Studio's Send dialog would: the choice saved in BambuStudio.conf for this printer, else Studio's default." },
|
|
2965
|
-
flow_calibration: { type: "boolean", description: "Flow calibration
|
|
2980
|
+
flow_calibration: { type: "boolean", description: "Flow calibration task boolean. Omission resolves Studio settings (auto on P1/P1S); direct MQTT sends false for auto but does not transmit the integer auto mode. The result calibration report distinguishes resolved and transmitted options." },
|
|
2966
2981
|
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
2967
2982
|
layer_inspect: { type: "boolean", description: "First-layer inspection where supported (default true, as Bambu Studio sends)." },
|
|
2968
2983
|
timelapse: { type: "boolean", description: "Enable timelapse recording in FULU PrintParams (default: false)." },
|
|
@@ -3044,7 +3059,7 @@ class BambuPrinterMCPServer {
|
|
|
3044
3059
|
connection_mode: {
|
|
3045
3060
|
type: "string",
|
|
3046
3061
|
enum: ["lan_mqtt_ftps", "bambu_native"],
|
|
3047
|
-
description: "Upload transport; bambu_native uses the installed Bambu networking plug-in for X2D and never starts printing."
|
|
3062
|
+
description: "Upload transport; bambu_native uses the installed Bambu networking plug-in for X2D or X1C and never starts printing."
|
|
3048
3063
|
},
|
|
3049
3064
|
bambu_model: {
|
|
3050
3065
|
type: "string",
|
|
@@ -3353,9 +3368,9 @@ class BambuPrinterMCPServer {
|
|
|
3353
3368
|
connection_mode: {
|
|
3354
3369
|
type: "string",
|
|
3355
3370
|
enum: ["lan_mqtt_ftps", "bambu_network", "bambu_native", "bambu_connect"],
|
|
3356
|
-
description: "Print path: bambu_connect hands a printable file to the signed-in Bambu Connect app for cloud-mode review; X2D otherwise defaults to bambu_native (Bambu Studio's installed local networking plug-in, storing the job on a ready SD card or USB stick, otherwise internal eMMC); lan_mqtt_ftps is the legacy direct MQTT/FTPS path; bambu_network uses the FULU bridge."
|
|
3371
|
+
description: "Print path: bambu_connect hands a printable file to the signed-in Bambu Connect app for cloud-mode review; X2D otherwise defaults to bambu_native (Bambu Studio's installed local networking plug-in, storing the job on a ready SD card or USB stick, otherwise internal eMMC); X1C may opt in to bambu_native, for example when its firmware refuses FTPS uploads with 553; lan_mqtt_ftps is the legacy direct MQTT/FTPS path; bambu_network uses the FULU bridge."
|
|
3357
3372
|
},
|
|
3358
|
-
try_emmc_print: { type: "boolean", description: "X2D native printing: true stores the job on internal storage (eMMC), false on the SD card or USB stick (refused unless the printer reports one ready). Omit to use the card when ready, else eMMC; BAMBU_NATIVE_TRY_EMMC_PRINT sets a server default." },
|
|
3373
|
+
try_emmc_print: { type: "boolean", description: "X2D native printing: true stores the job on internal storage (eMMC), false on the SD card or USB stick (refused unless the printer reports one ready). Omit to use the card when ready, else eMMC; X1C requires fresh advertised internal-printing support before using eMMC. BAMBU_NATIVE_TRY_EMMC_PRINT sets a server default." },
|
|
3359
3374
|
connection_type: { type: "string", enum: ["cloud", "lan"], description: "BambuNetwork connection type when connection_mode is bambu_network; cloud uses restored internet printing, lan uses local bridge printing." },
|
|
3360
3375
|
bambu_network_method: { type: "string", enum: BAMBU_NETWORK_PRINT_METHODS, description: "FULU print method when connection_mode is bambu_network; defaults to start_local_print for lan, and for cloud to Bambu Studio's order: start_local_print_with_record, then start_print if that fails." },
|
|
3361
3376
|
dev_id: { type: "string", description: "Bambu device id for FULU BambuNetwork printing; defaults to BAMBU_DEV_ID or BAMBU_SERIAL." },
|
|
@@ -3405,7 +3420,7 @@ class BambuPrinterMCPServer {
|
|
|
3405
3420
|
description: "When true, match the sliced 3MF's tray_info_idx requirements against live AMS inventory and use the resulting ams_slots. Ignored when ams_mapping or ams_slots is provided."
|
|
3406
3421
|
},
|
|
3407
3422
|
bed_leveling: { type: "boolean", description: "Auto bed leveling on or off. Omit to send what Bambu Studio's Send dialog would: the choice saved in BambuStudio.conf for this printer, else Studio's default." },
|
|
3408
|
-
flow_calibration: { type: "boolean", description: "Flow calibration
|
|
3423
|
+
flow_calibration: { type: "boolean", description: "Flow calibration task boolean. Omission resolves Studio settings (auto on P1/P1S); direct MQTT sends false for auto but does not transmit the integer auto mode. The result calibration report distinguishes resolved and transmitted options." },
|
|
3409
3424
|
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
3410
3425
|
timelapse: { type: "boolean", description: "Enable timelapse recording (default: false)" },
|
|
3411
3426
|
slicer_profile: { type: "string", description: "Path to the slicer profile/config file for auto-slicing (optional)." },
|
|
@@ -3441,7 +3456,7 @@ class BambuPrinterMCPServer {
|
|
|
3441
3456
|
description: "Bed plate type currently installed (default: textured_plate)"
|
|
3442
3457
|
},
|
|
3443
3458
|
bed_leveling: { type: "boolean", description: "Auto bed leveling on or off. Omit to send what Bambu Studio's Send dialog would: the choice saved in BambuStudio.conf for this printer, else Studio's default." },
|
|
3444
|
-
flow_calibration: { type: "boolean", description: "Flow calibration
|
|
3459
|
+
flow_calibration: { type: "boolean", description: "Flow calibration task boolean. Omission resolves Studio settings (auto on P1/P1S); direct MQTT sends false for auto but does not transmit the integer auto mode. The result calibration report distinguishes resolved and transmitted options." },
|
|
3445
3460
|
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
3446
3461
|
timelapse: { type: "boolean", description: "Enable timelapse recording (default: false)" },
|
|
3447
3462
|
slicer_profile: { type: "string", description: "Path to the slicer profile/config file for auto-slicing (optional)." },
|
|
@@ -3816,7 +3831,9 @@ class BambuPrinterMCPServer {
|
|
|
3816
3831
|
? linuxEmergency(() => nativeCommand(), signal => this.bambu.sendStopOverMqtt(host, bambuSerial, bambuToken, signal))
|
|
3817
3832
|
: nativeCommand;
|
|
3818
3833
|
}
|
|
3819
|
-
|
|
3834
|
+
// Native controls are X2D-only. Another model printed natively (X1C)
|
|
3835
|
+
// is stopped, paused and resumed over direct MQTT, as its default route is.
|
|
3836
|
+
if (route.mode === "bambu_native" && x2dTarget) throw new Error(nativeUnavailableReason()!);
|
|
3820
3837
|
if (route.mode !== "bambu_network") return undefined;
|
|
3821
3838
|
return (assertActive?: () => void, beforeDispatch?: () => Promise<void>) => {
|
|
3822
3839
|
const options = { assertDispatchAllowed: () => { extra.signal.throwIfAborted(); assertActive?.(); } };
|
package/src/printers/bambu.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { bridgeAmsMapping2Entry, bridgeAmsMappingValue, externalTrayForNozzle, d
|
|
|
20
20
|
import { describeHmsKey, hiddenHmsKeys, hiddenHmsNotices, reportedHmsKey, unchippedNozzles, validatePrinterState, manualHeatingRequirements, type PrinterStateRequirements } from "../safety/printer-state.js";
|
|
21
21
|
import { withPrinterOperation, withPrintSnapshot, uniquePrintName, normalizedRemotePath, cancelPendingPrinterOperations } from "../safety/artifact.js";
|
|
22
22
|
import { RTSP_CAMERA_MODELS, TCP_CAMERA_MODELS } from "./camera-models.js";
|
|
23
|
-
import { resolveStudioPrintOptions, usedNozzleCount, type CallerPrintOptions } from "../studio-print-options.js";
|
|
23
|
+
import { directPrintOptionReport, resolveStudioPrintOptions, usedNozzleCount, type CallerPrintOptions } from "../studio-print-options.js";
|
|
24
24
|
import { Client as FTPClient } from "basic-ftp";
|
|
25
25
|
import { uploadBytes } from "./ftp-upload.js";
|
|
26
26
|
import * as mqtt from "mqtt";
|
|
@@ -157,6 +157,19 @@ const MODEL_ID_TO_NAME: Record<string, string> = {
|
|
|
157
157
|
|
|
158
158
|
const H2_MODEL_NAMES = new Set(["h2", "h2c", "h2d", "h2dpro", "h2d pro", "h2s", "x2d"]);
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* X1C firmware 01.12.00.00 was seen refusing every FTPS STOR with
|
|
162
|
+
* "553 Could not create file." (card ready and writable, Developer Mode on)
|
|
163
|
+
* while Bambu Studio's networking plug-in still printed. Name that route.
|
|
164
|
+
*/
|
|
165
|
+
export function ftpsRefusalHint(error: unknown, model: string | undefined): string {
|
|
166
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
167
|
+
if (normalizeModel(model) !== "x1c" || ((error as { code?: unknown })?.code !== 553 && !/^553\b/.test(message))) return "";
|
|
168
|
+
return ' X1C firmware 01.12.00.00 has been seen refusing every direct FTPS upload this way. ' +
|
|
169
|
+
'Retry with connection_mode: "bambu_native", which uploads through Bambu Studio\'s networking plug-in ' +
|
|
170
|
+
'(on macOS, first run npm run build:native in the package directory; on Linux, bambu-printer-mcp-native-setup).';
|
|
171
|
+
}
|
|
172
|
+
|
|
160
173
|
export function assertDirectPrintSupported(model: string | undefined, serial?: string): void {
|
|
161
174
|
if (model?.trim().toLowerCase() === "x2d" || serial?.trim().toUpperCase().startsWith("20P")) {
|
|
162
175
|
throw new Error(
|
|
@@ -1142,12 +1155,13 @@ export class BambuImplementation {
|
|
|
1142
1155
|
});
|
|
1143
1156
|
const resumeFile = await checkedFile(inspection, options.filePath);
|
|
1144
1157
|
// The options Bambu Studio's Send dialog would send; explicit ones win.
|
|
1145
|
-
const
|
|
1158
|
+
const caller: CallerPrintOptions = {
|
|
1146
1159
|
bedLeveling: options.bedLeveling, flowCalibration: options.flowCalibration,
|
|
1147
1160
|
vibrationCalibration: options.vibrationCalibration, layerInspect: options.layerInspect,
|
|
1148
1161
|
autoBedLeveling: options.autoBedLeveling, autoFlowCali: options.autoFlowCali,
|
|
1149
1162
|
autoOffsetCali: options.autoOffsetCali, extruderCaliManualMode: options.extruderCaliManualMode,
|
|
1150
|
-
}
|
|
1163
|
+
};
|
|
1164
|
+
const studio = resolveStudioPrintOptions(model, caller, { usedNozzles: usedNozzleCount(inspection) });
|
|
1151
1165
|
const projectMetadata = await this.resolveProjectFileMetadata(
|
|
1152
1166
|
options.filePath,
|
|
1153
1167
|
options.plateIndex,
|
|
@@ -1285,7 +1299,7 @@ export class BambuImplementation {
|
|
|
1285
1299
|
await this.ftpUpload(host, token, options.filePath, remoteUploadPath, options.onUploadProgress);
|
|
1286
1300
|
} catch (error) {
|
|
1287
1301
|
// Nothing has been sent to the printer but (part of) a file, so the print certainly did not start.
|
|
1288
|
-
throw new PrinterRefusal("printer-upload-failed", `The print file did not reach the printer (${error instanceof Error ? error.message : String(error)}). No print was started
|
|
1302
|
+
throw new PrinterRefusal("printer-upload-failed", `The print file did not reach the printer (${error instanceof Error ? error.message : String(error)}). No print was started.${ftpsRefusalHint(error, model)}`);
|
|
1289
1303
|
}
|
|
1290
1304
|
// Uploads can be long. Recheck current state before the command is dispatched.
|
|
1291
1305
|
const dispatchStatus = await this.getSafetyStatus(host, serial, token);
|
|
@@ -1303,6 +1317,7 @@ export class BambuImplementation {
|
|
|
1303
1317
|
const dispatch = await watcher.settled();
|
|
1304
1318
|
return {
|
|
1305
1319
|
status: "success", dispatch, remoteProjectPath,
|
|
1320
|
+
calibration: directPrintOptionReport(caller, studio, {}),
|
|
1306
1321
|
message: dispatch === "started"
|
|
1307
1322
|
? `The printer accepted and started the checked gcode.3mf print: ${options.projectName}`
|
|
1308
1323
|
: `Uploaded the checked gcode.3mf and sent the print command for ${options.projectName}; the printer has not reported starting yet. ` +
|
|
@@ -1378,6 +1393,7 @@ export class BambuImplementation {
|
|
|
1378
1393
|
};
|
|
1379
1394
|
}
|
|
1380
1395
|
|
|
1396
|
+
const calibration = directPrintOptionReport(caller, studio, projectFileCmd.print);
|
|
1381
1397
|
const watcher = this.watchDispatch(printer, host, serial, token, dispatchStatus, assertActive);
|
|
1382
1398
|
this.recordFlightDispatch(host,serial,remoteProjectPath,requirements,resumeFile);
|
|
1383
1399
|
markPrintCommandSent();
|
|
@@ -1388,6 +1404,7 @@ export class BambuImplementation {
|
|
|
1388
1404
|
|
|
1389
1405
|
return {
|
|
1390
1406
|
status: "success",
|
|
1407
|
+
calibration,
|
|
1391
1408
|
dispatch,
|
|
1392
1409
|
message: dispatch === "started"
|
|
1393
1410
|
? `The printer accepted and started the checked 3MF print: ${options.projectName}`
|
|
@@ -2007,7 +2024,15 @@ export class BambuImplementation {
|
|
|
2007
2024
|
assertActive();
|
|
2008
2025
|
const destination = path.posix.join(path.posix.dirname(remotePath), uniquePrintName(remotePath));
|
|
2009
2026
|
if (upload) await upload(snapshot, destination, assertActive);
|
|
2010
|
-
else
|
|
2027
|
+
else {
|
|
2028
|
+
try {
|
|
2029
|
+
await this.ftpUpload(host, token, snapshot, `/${destination}`);
|
|
2030
|
+
} catch (error) {
|
|
2031
|
+
const hint = ftpsRefusalHint(error, model);
|
|
2032
|
+
if (hint && error instanceof Error) error.message += hint;
|
|
2033
|
+
throw error;
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2011
2036
|
return { status: "success", uploaded: true, remotePath: destination, printRequested: false, inspected: printable };
|
|
2012
2037
|
}));
|
|
2013
2038
|
}
|
package/src/safety/limits.ts
CHANGED
|
@@ -40,6 +40,14 @@ export function isDualNozzleModel(model: unknown): boolean {
|
|
|
40
40
|
const normalized = normalizeModel(model);
|
|
41
41
|
return normalized !== undefined && DUAL_NOZZLE_MODELS.has(normalized);
|
|
42
42
|
}
|
|
43
|
+
/** File models a printer accepts besides its own, keyed by the printer's observed model.
|
|
44
|
+
* A P1P with the enclosure upgrade kit still reports itself as a P1P, while its jobs are sliced with the P1S
|
|
45
|
+
* preset. Bambu Studio sends those jobs: resources/printers/C11.json (P1P) lists C12 (P1S) in compatible_machine.
|
|
46
|
+
* The two models have identical MACHINE_LIMITS, and the file is still checked against the printer's own limits. */
|
|
47
|
+
export const ACCEPTED_FILE_MODELS: Readonly<Record<string, ReadonlySet<string>>> = {p1p: new Set(['p1s'])};
|
|
48
|
+
export function fileModelFitsPrinter(fileModel: string, printerModel: string): boolean {
|
|
49
|
+
return fileModel === printerModel || ACCEPTED_FILE_MODELS[printerModel]?.has(fileModel) === true;
|
|
50
|
+
}
|
|
43
51
|
export function normalizeModel(value: unknown): string | undefined {
|
|
44
52
|
if (typeof value !== 'string') return undefined;
|
|
45
53
|
let model = value.trim().toLowerCase().replace(/^bambu\s*(?:lab\s*)?/, '').replace(/[\s_-]/g, '');
|
package/src/safety/print-file.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { readBoundedPrintFile, loadSafe3mfArchive } from './archive.js';
|
|
3
3
|
import { projectFilaments, type ProjectFilament } from "../ams-mapping.js";
|
|
4
|
-
import { MACHINE_LIMITS, isDualNozzleModel, normalizeMaterial, normalizeModel, validateStartupPurgeTemperature, validateTemperature } from './limits.js';
|
|
4
|
+
import { MACHINE_LIMITS, fileModelFitsPrinter, isDualNozzleModel, normalizeMaterial, normalizeModel, validateStartupPurgeTemperature, validateTemperature } from './limits.js';
|
|
5
5
|
|
|
6
6
|
export interface PrintFileInspection {
|
|
7
7
|
model: string;
|
|
@@ -240,7 +240,7 @@ export async function inspectPrintFile(filePath: string, options: {model:string;
|
|
|
240
240
|
const metadata:Metadata[]=[project,...headers];
|
|
241
241
|
validateFffJob([...metadata,plate]);
|
|
242
242
|
const declaredModel=consistent(metadataValues(metadata,['printer_model']),normalizeModel,'printer model');
|
|
243
|
-
if(declaredModel
|
|
243
|
+
if(!fileModelFitsPrinter(declaredModel,model)) return fail(`file model ${declaredModel} contradicts requested model ${model}`);
|
|
244
244
|
const nozzleDiameters=consistent(metadataValues(metadata,['nozzle_diameter']),value=>{
|
|
245
245
|
const values=list(value);return values.length && values.every(v=>NUMBER.test(v) && [0.2,0.4,0.6,0.8].includes(Number(v)))?values.map(Number):undefined;
|
|
246
246
|
},'nozzle diameter');
|
|
@@ -366,13 +366,16 @@ function trayRange(value: unknown, label: string): number | undefined {
|
|
|
366
366
|
/** Dual-nozzle printers report one virtual external slot per nozzle, numbered as Bambu
|
|
367
367
|
* Studio does (VIRTUAL_TRAY_MAIN_ID 255 = right/main nozzle, VIRTUAL_TRAY_DEPUTY_ID 254 =
|
|
368
368
|
* left/deputy nozzle), so the requested tray selects its slot. Single-nozzle printers keep
|
|
369
|
-
* requiring exactly one slot
|
|
369
|
+
* requiring exactly one external slot report, then the legacy vt_tray field. */
|
|
370
370
|
function externalTray(raw: Record<string,any>, trayIndex: number, model: string): Record<string,any> | undefined {
|
|
371
371
|
const slots = raw.vir_slot;
|
|
372
372
|
const dualNozzle = isDualNozzleModel(model);
|
|
373
373
|
if (Array.isArray(slots)) {
|
|
374
374
|
const selected = slots.filter((slot:any) => Number(slot?.id) === trayIndex);
|
|
375
375
|
if (selected.length === 1 && (dualNozzle || slots.length === 1)) return selected[0];
|
|
376
|
+
// X1C firmware 01.12 reports its single external slot as id 255 (ams_id 255, slot 0) while
|
|
377
|
+
// tray_now is 254. One external slot on a single-nozzle printer is unambiguous.
|
|
378
|
+
if (!dualNozzle && slots.length === 1 && [254,255].includes(Number(slots[0]?.id)) && [254,255].includes(trayIndex)) return slots[0];
|
|
376
379
|
if (dualNozzle && selected.length === 0 && slots.length > 0) throw new Error(`External spool ${trayIndex} is not in the fresh per-nozzle report; cannot verify the selected material.`);
|
|
377
380
|
if (slots.length > 0) throw new Error("External spool report is ambiguous for this nozzle; cannot verify the selected material.");
|
|
378
381
|
}
|
|
@@ -526,3 +529,12 @@ export function externalStorageState(raw: unknown): ExternalStorageState {
|
|
|
526
529
|
}
|
|
527
530
|
return state;
|
|
528
531
|
}
|
|
532
|
+
|
|
533
|
+
/** Studio DeviceManager.cpp at 926a7192574b: fun2 bit 0 advertises eMMC printing.
|
|
534
|
+
* Use only a fresh raw report at the caller. Reject malformed flags rather than
|
|
535
|
+
* stripping arbitrary characters as Studio's general-purpose parser does. */
|
|
536
|
+
export function internalPrintingSupported(raw: unknown): boolean {
|
|
537
|
+
if (!object(raw) || typeof raw.fun2 !== "string") return false;
|
|
538
|
+
const flags = raw.fun2.trim().replace(/^0x/i, "");
|
|
539
|
+
return /^[0-9a-f]+$/i.test(flags) && (parseInt(flags.slice(-1), 16) & 1) === 1;
|
|
540
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The print options Bambu Studio's Send dialog sends, resolved the way it
|
|
3
|
-
* resolves them,
|
|
4
|
-
*
|
|
3
|
+
* resolves them, for the vendor SDK. Direct routes report which options their verified
|
|
4
|
+
* wire format can carry; this does not establish SDK packet equivalence. Source: Bambu Studio v02.08.02.61 (commit 926a7192574b), the version
|
|
5
5
|
* the hidden-HMS and stage tables are pinned to:
|
|
6
6
|
*
|
|
7
7
|
* - SelectMachine.cpp:3344-3356 `set_print_config(bed_type,
|
|
@@ -199,3 +199,34 @@ export function usedNozzleCount(inspection: { usedFilamentPositions: number[]; f
|
|
|
199
199
|
const nozzles = inspection.usedFilamentPositions.map(position => inspection.filamentNozzleIndices?.[position]).filter((value): value is number => Number.isInteger(value));
|
|
200
200
|
return nozzles.length === inspection.usedFilamentPositions.length && nozzles.length ? new Set(nozzles).size : undefined;
|
|
201
201
|
}
|
|
202
|
+
|
|
203
|
+
/** Report only verified direct-wire fields. A task boolean is not an SDK mode.
|
|
204
|
+
* null means this route does not transmit that option, not off/auto/unknown hardware state. */
|
|
205
|
+
export function directPrintOptionReport(caller: CallerPrintOptions, resolved: StudioPrintOptions, packet: Record<string, unknown>) {
|
|
206
|
+
const fields = {
|
|
207
|
+
bedLeveling: ["task_bed_leveling", "bed_leveling"],
|
|
208
|
+
flowCalibration: ["task_flow_cali", "flow_cali"],
|
|
209
|
+
vibrationCalibration: ["task_vibration_cali", "vibration_cali"],
|
|
210
|
+
layerInspect: ["task_layer_inspect", "layer_inspect"],
|
|
211
|
+
autoBedLeveling: ["auto_bed_leveling", "auto_bed_leveling"],
|
|
212
|
+
autoFlowCali: ["auto_flow_cali", "auto_flow_cali"],
|
|
213
|
+
autoOffsetCali: ["auto_offset_cali", "nozzle_offset_cali"],
|
|
214
|
+
extruderCaliManualMode: ["extruder_cali_manual_mode", "extrude_cali_manual_mode"],
|
|
215
|
+
} as const;
|
|
216
|
+
const requested: CallerPrintOptions = {};
|
|
217
|
+
const transmitted: Record<string, boolean | number | null> = {};
|
|
218
|
+
const unsupported: string[] = [];
|
|
219
|
+
for (const key of Object.keys(fields) as Array<keyof CallerPrintOptions>) {
|
|
220
|
+
const [sdk, wire] = fields[key];
|
|
221
|
+
if (caller[key] !== undefined) Object.assign(requested, { [key]: caller[key] });
|
|
222
|
+
const value = packet[wire];
|
|
223
|
+
transmitted[sdk] = typeof value === "boolean" || typeof value === "number" ? value : null;
|
|
224
|
+
if (caller[key] !== undefined && transmitted[sdk] === null) unsupported.push(key);
|
|
225
|
+
}
|
|
226
|
+
const omitted = Object.keys(transmitted).filter(key => transmitted[key] === null);
|
|
227
|
+
const warning = omitted.length
|
|
228
|
+
? `Direct print options not transmitted: ${omitted.join(", ")}. Task booleans are not equivalent to Studio integer modes.` +
|
|
229
|
+
(unsupported.length ? ` Requested overrides unsupported by this route: ${unsupported.join(", ")}. Use a vendor bridge/native route that supports these options if required.` : "")
|
|
230
|
+
: undefined;
|
|
231
|
+
return { requested, resolved, transmitted, unsupported, ...(warning ? { warning } : {}) };
|
|
232
|
+
}
|