Make the filament source explicit, and print from the AMS
`start_uploaded_file` hardcoded `use_ams: false` / `ams_mapping: ""`, which silently overrode whatever the slicer had chosen. On a P1P with an AMS and a project sliced for it, that is not a missing feature - it points the print at the external spool. Confirmed on 2026-10-11: the print started, heated to 250C, reached 1%, then the printer paused itself with `print_error: 50364420` and `tray_now: 255`. Nothing in the command's reply said so; `result` was `success`, because the command had been accepted. So `FilamentSource` is now a required argument with no default, because there is no safe default - picking wrong draws the wrong filament or none. The `ExternalSpool` variant sends the empty *string* the schema's trailing `oneOf` demands, and `ams` takes slots per project filament index and pads to every tray the printer has, per the padding rule in `schemas/bambulab/v1/common/ams/ams_mapping.schema.json`. It refuses an empty mapping (padding `[]` would mean `use_ams: true` with nothing mapped), one longer than the printer has trays, and any negative that is not -1. Confirmed live with the real mapping: `ams_mapping: [3,-1,-1,-1,-1]`, `use_ams: true` took the printer to RUNNING, `tray_now` became 3 - the slot the project was sliced for - and it ran past 1% to 13% with `print_error: 0`, where the external-spool attempt had paused. Finding the mapping needed reading the project back off the card, so FTPS gains `download`/`download_file` and the probe a `fetch` step. The archive's `Metadata/slice_info.config` lists each plate's filaments with `tray_info_idx` and colour - here one PETG GFG99 at `#2850E0`, matching AMS slot 3's `2850E0FF` - and `Metadata/plate_1.gcode` is present, which also confirms the hardcoded `param`. `upload_project_file` is left on the external spool and is the one remaining place that can pick wrong, because it is vendor-generic and an AMS mapping is a Bambu concept. It is unreachable - there is no start-print command on the uplink - and the fix is for it to derive the mapping from the `.3mf` it already holds, which needs a zip reader and so a dependency decision.
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use continuum_proxy::fleet;
|
||||
use continuum_proxy::printer::{GenericPrinter, PrintControl, PrinterHandle};
|
||||
use continuum_proxy::printer::{FilamentSource, GenericPrinter, PrintControl, PrinterHandle};
|
||||
|
||||
const CONNECT_TIMEOUT: Duration = Duration::from_secs(20);
|
||||
const STATUS_TIMEOUT: Duration = Duration::from_secs(15);
|
||||
@@ -44,6 +44,10 @@ const WATCH: Duration = Duration::from_secs(20);
|
||||
/// A file name that cannot exist in `cache/`, for `probe-missing`.
|
||||
const MISSING_FILE: &str = "continuum-probe-no-such-file.gcode";
|
||||
|
||||
/// Every tray a P1P with one AMS has: 4 AMS slots plus the external spool.
|
||||
/// `ams_mapping` has to be padded to this length - see the schema.
|
||||
const P1P_TRAY_COUNT: usize = 5;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
// Without this there is no subscriber, so the `trace!` of every raw
|
||||
@@ -108,7 +112,10 @@ async fn main() -> anyhow::Result<()> {
|
||||
// whether the command shape is understood.
|
||||
println!("\n sending print.gcode_file for a file that does not exist:");
|
||||
println!(" param -> /cache/{MISSING_FILE}");
|
||||
match bambu.start_uploaded_file(MISSING_FILE).await {
|
||||
match bambu
|
||||
.start_uploaded_file(MISSING_FILE, &FilamentSource::ExternalSpool)
|
||||
.await
|
||||
{
|
||||
Ok(()) => println!(" the printer ACCEPTED it (result: success)"),
|
||||
Err(err) => anyhow::bail!("the printer answered: {err}"),
|
||||
}
|
||||
@@ -139,8 +146,32 @@ async fn main() -> anyhow::Result<()> {
|
||||
This commits the machine to physical work. Be at the printer."
|
||||
);
|
||||
}
|
||||
println!("\n starting print of '{file}' ...");
|
||||
match bambu.start_uploaded_file(&file).await {
|
||||
// `--ams=3` or `--ams=3,-1,0` picks AMS slots per project
|
||||
// filament index; without it, the external spool. There is no
|
||||
// default that is safe for both, so the flag has to be explicit.
|
||||
let filament = match args.iter().find_map(|a| a.strip_prefix("--ams=")) {
|
||||
Some(list) => {
|
||||
let slots = list
|
||||
.split(',')
|
||||
.map(|slot| slot.trim().parse::<i32>())
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(|err| anyhow::anyhow!("--ams needs a comma-separated list of slot numbers: {err}"))?;
|
||||
// 4 AMS slots + 1 external spool on a P1P with one AMS.
|
||||
// See the padding rule in the ams_mapping schema.
|
||||
FilamentSource::ams(slots, P1P_TRAY_COUNT)
|
||||
.map_err(|err| anyhow::anyhow!("{err}"))?
|
||||
}
|
||||
None => FilamentSource::ExternalSpool,
|
||||
};
|
||||
match &filament {
|
||||
FilamentSource::ExternalSpool => {
|
||||
println!("\n starting print of '{file}' from the EXTERNAL SPOOL ...")
|
||||
}
|
||||
FilamentSource::Ams(slots) => {
|
||||
println!("\n starting print of '{file}' with ams_mapping {slots:?} ...")
|
||||
}
|
||||
}
|
||||
match bambu.start_uploaded_file(&file, &filament).await {
|
||||
Ok(()) => println!(" accepted"),
|
||||
Err(err) => anyhow::bail!("the printer answered: {err}"),
|
||||
}
|
||||
@@ -175,6 +206,20 @@ async fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
// `fetch <path> <dest>` copies one file off the card. Read-only.
|
||||
"fetch" => {
|
||||
let (Some(path), Some(dest)) = (args.get(3), args.get(4)) else {
|
||||
anyhow::bail!("`fetch` needs a path on the printer and a local destination");
|
||||
};
|
||||
match bambu.download_file(path).await {
|
||||
Ok(bytes) => {
|
||||
std::fs::write(dest, &bytes)?;
|
||||
println!(" {} bytes -> {dest}", bytes.len());
|
||||
}
|
||||
Err(err) => anyhow::bail!("fetch failed: {err}"),
|
||||
}
|
||||
}
|
||||
|
||||
other => anyhow::bail!("unknown step '{other}'"),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user