Skip to content

Commit

Permalink
bump dropshot and friends (#109)
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz authored Oct 1, 2024
1 parent 6bc0569 commit 6e9762c
Show file tree
Hide file tree
Showing 36 changed files with 128 additions and 85 deletions.
27 changes: 14 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ clap = { version = "4.5.18", features = ["cargo", "derive", "env", "unicode"] }
console-subscriber = { version = "0", optional = true }
dashmap = "6.1.0"
delouse = { version = "0.1", optional = true }
dropshot = "0.11"
dropshot = "0.12"
futures = "0.3.28"
futures-util = "0.3.30"
http = "1"
hyper = "1"
libmdns = "0.9.1"
multer = { version = "3.1.0", features = ["json"] }
moonraker = { path = "moonraker", optional = true }
multer = { version = "3.1.0", features = ["json"] }
opentelemetry = "0.24.0"
opentelemetry-otlp = "0.17.0"
opentelemetry_sdk = { version = "0.24.1", features = ["rt-tokio"] }
Expand All @@ -50,15 +52,13 @@ slog-json = "2.6.1"
slog-term = "2.9.1"
thiserror = "1.0.64"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time", "net"] }
tokio-serial = { version = "5", optional = true, features = ["tokio-util", "libudev"] }
toml = "0.8.19"
tracing = "0.1"
tracing-opentelemetry = "0.25.0"
tracing-slog = "0.3.0"
tracing-subscriber = { version = "0.3.18", features = ["registry", "std", "fmt", "smallvec", "ansi", "tracing-log", "json", "env-filter"] }
uuid = "1.10.0"
tokio-serial = { version = "5", optional = true, features = ["tokio-util", "libudev"] }
tracing-slog = "0.3.0"
http = "0.2.9"
hyper = "0.14"

[dev-dependencies]
async-trait = "0.1"
Expand Down
3 changes: 2 additions & 1 deletion src/any_machine.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{Control as ControlTrait, MachineInfo, MachineMakeModel, MachineType, Volume};
use anyhow::Result;

use crate::{Control as ControlTrait, MachineInfo, MachineMakeModel, MachineType, Volume};

/// AnyMachine is any supported machine.
#[non_exhaustive]
pub enum AnyMachine {
Expand Down
5 changes: 3 additions & 2 deletions src/bambu/control.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use anyhow::Result;
use bambulabs::{client::Client, command::Command};

use super::{PrinterInfo, X1Carbon};
use crate::{
Control as ControlTrait, MachineInfo as MachineInfoTrait, MachineMakeModel, MachineType,
SuspendControl as SuspendControlTrait, ThreeMfControl as ThreeMfControlTrait, ThreeMfTemporaryFile, Volume,
};
use anyhow::Result;
use bambulabs::{client::Client, command::Command};

impl X1Carbon {
/// Return a borrow of the underlying Client.
Expand Down
10 changes: 6 additions & 4 deletions src/bambu/discover.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use super::{PrinterInfo, X1Carbon};
use crate::{slicer, Discover as DiscoverTrait, Machine, MachineMakeModel};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
net::{IpAddr, Ipv4Addr},
sync::Arc,
};

use anyhow::Result;
use serde::{Deserialize, Serialize};
use tokio::{net::UdpSocket, sync::RwLock};

use super::{PrinterInfo, X1Carbon};
use crate::{slicer, Discover as DiscoverTrait, Machine, MachineMakeModel};

/// Specific make/model of Bambu device.
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
#[non_exhaustive]
Expand Down
5 changes: 3 additions & 2 deletions src/bambu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
mod control;
mod discover;

use std::{net::IpAddr, sync::Arc};

use bambulabs::client::Client;
pub use discover::{BambuVariant, Config, X1CarbonDiscover};

use crate::MachineMakeModel;
use bambulabs::client::Client;
use std::{net::IpAddr, sync::Arc};

/// Control channel handle to a Bambu Labs X1 Carbon.
#[derive(Clone)]
Expand Down
6 changes: 4 additions & 2 deletions src/bin/machine-api/cmd_serve.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::{Cli, Config};
use std::{collections::HashMap, net::SocketAddr, sync::Arc};

use anyhow::Result;
use machine_api::server;
use std::{collections::HashMap, net::SocketAddr, sync::Arc};
use tokio::sync::RwLock;

use super::{Cli, Config};

pub async fn main(_cli: &Cli, cfg: &Config, bind: &str) -> Result<()> {
let machines = Arc::new(RwLock::new(HashMap::new()));

Expand Down
6 changes: 4 additions & 2 deletions src/bin/machine-api/config/bambu.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::{Config, MachineConfig};
use std::{collections::HashMap, sync::Arc};

use anyhow::Result;
use machine_api::{bambu, Discover, Machine};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;

use super::{Config, MachineConfig};

impl Config {
pub async fn spawn_discover_bambu(&self, machines: Arc<RwLock<HashMap<String, RwLock<Machine>>>>) -> Result<()> {
let discovery = bambu::X1CarbonDiscover::new(
Expand Down
3 changes: 2 additions & 1 deletion src/bin/machine-api/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use machine_api::{bambu as crate_bambu, moonraker as crate_moonraker, usb as crate_usb};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

mod bambu;
mod moonraker;
Expand Down
6 changes: 4 additions & 2 deletions src/bin/machine-api/config/moonraker.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::{Config, MachineConfig};
use std::{collections::HashMap, sync::Arc};

use anyhow::Result;
use machine_api::{moonraker, Machine, MachineMakeModel};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;

use super::{Config, MachineConfig};

impl Config {
pub async fn create_moonraker(&self, machines: Arc<RwLock<HashMap<String, RwLock<Machine>>>>) -> Result<()> {
for (key, config) in self
Expand Down
6 changes: 4 additions & 2 deletions src/bin/machine-api/config/noop.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::{Config, MachineConfig};
use std::{collections::HashMap, sync::Arc};

use anyhow::Result;
use machine_api::{noop, slicer, Machine, MachineMakeModel, MachineType, Volume};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;

use super::{Config, MachineConfig};

impl Config {
pub async fn create_noop(&self, machines: Arc<RwLock<HashMap<String, RwLock<Machine>>>>) -> Result<()> {
for (key, _config) in self
Expand Down
6 changes: 4 additions & 2 deletions src/bin/machine-api/config/usb.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use super::{Config, MachineConfig};
use std::{collections::HashMap, sync::Arc};

use anyhow::Result;
use machine_api::{usb, Discover, Machine};
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;

use super::{Config, MachineConfig};

impl Config {
pub async fn spawn_discover_usb(&self, machines: Arc<RwLock<HashMap<String, RwLock<Machine>>>>) -> Result<()> {
let discovery = usb::UsbDiscovery::new(
Expand Down
4 changes: 3 additions & 1 deletion src/discover.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::Machine;
use std::{collections::HashMap, future::Future, sync::Arc};

use tokio::sync::RwLock;

use crate::Machine;

/// Discover trait implemented by backends in order to add or remove
/// configured machines.
pub trait Discover {
Expand Down
3 changes: 2 additions & 1 deletion src/file.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use std::path::{Path, PathBuf};

use anyhow::Result;
use tokio::fs::File;

/// A TemporaryFile wraps a normal [tokio::fs::File]`, but will attempt to
Expand Down
3 changes: 2 additions & 1 deletion src/gcode/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! This module contains support for printing to gcode based 3D printers
//! over some [AsyncRead]/[AsyncWrite] traited object.

use anyhow::Result;
use std::{
pin::Pin,
task::{Context as TaskContext, Poll},
};

use anyhow::Result;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, ReadBuf};

/// Create a handle to some [tokio::io::AsyncWrite]
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ mod traits;
#[cfg(feature = "serial")]
pub mod usb;

use std::path::PathBuf;

pub use any_machine::{AnyMachine, AnyMachineInfo};
pub use discover::Discover;
pub use file::TemporaryFile;
pub use machine::Machine;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
pub use slicer::AnySlicer;
pub use sync::SharedMachine;
pub use traits::{
Control, GcodeControl, GcodeSlicer, GcodeTemporaryFile, MachineInfo, MachineMakeModel, MachineType, SuspendControl,
ThreeMfControl, ThreeMfSlicer, ThreeMfTemporaryFile,
};

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

/// A specific file containing a design to be manufactured.
#[non_exhaustive]
pub enum DesignFile {
Expand Down
3 changes: 2 additions & 1 deletion src/machine.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{AnyMachine, AnySlicer, DesignFile, GcodeControl, GcodeSlicer, ThreeMfControl, ThreeMfSlicer};
use anyhow::Result;

use crate::{AnyMachine, AnySlicer, DesignFile, GcodeControl, GcodeSlicer, ThreeMfControl, ThreeMfSlicer};

/// Create a handle to a specific Machine which is capable of producing a 3D
/// object in the real world from a specific [crate::DesignFile].
pub struct Machine {
Expand Down
8 changes: 5 additions & 3 deletions src/moonraker/control.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use std::path::PathBuf;

use anyhow::Result;
use moonraker::InfoResponse;

use super::Client;
use crate::{
Control as ControlTrait, GcodeControl as GcodeControlTrait, GcodeTemporaryFile, MachineInfo as MachineInfoTrait,
MachineMakeModel, MachineType, SuspendControl as SuspendControlTrait, Volume,
};
use anyhow::Result;
use moonraker::InfoResponse;
use std::path::PathBuf;

/// Information about the connected Moonraker-based printer.
#[derive(Debug, Clone, PartialEq)]
Expand Down
6 changes: 3 additions & 3 deletions src/moonraker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
mod control;
mod variants;

use anyhow::Result;
pub use control::MachineInfo;
use moonraker::Client as MoonrakerClient;
use serde::{Deserialize, Serialize};
pub use variants::MoonrakerVariant;

use crate::{slicer, MachineMakeModel, Volume};
use anyhow::Result;
use moonraker::Client as MoonrakerClient;
use serde::{Deserialize, Serialize};

/// Configuration information for a Moonraker-based endpoint.
#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion src/moonraker/variants.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{MachineType, Volume};
use serde::{Deserialize, Serialize};

use crate::{MachineType, Volume};

macro_rules! moonraker_devices {
($(
$name:ident(
Expand Down
3 changes: 2 additions & 1 deletion src/noop.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! `noop` implements a no-op Machine, one that will accept Control commands
//! and do exactly nothing with it.

use anyhow::Result;

use crate::{
Control as ControlTrait, GcodeControl as GcodeControlTrait, GcodeTemporaryFile, MachineInfo as MachineInfoTrait,
MachineMakeModel, MachineType, SuspendControl as SuspendControlTrait, ThreeMfControl as ThreeMfControlTrait,
ThreeMfTemporaryFile, Volume,
};
use anyhow::Result;

/// Noop-machine will no-op, well, everything.
pub struct Noop {
Expand Down
4 changes: 3 additions & 1 deletion src/server/context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::Machine;
use std::{collections::HashMap, sync::Arc};

use tokio::sync::RwLock;

use crate::Machine;

/// Context for a given server -- this contains all the informatio required
/// to serve a Machine-API request.
pub struct Context {
Expand Down
3 changes: 1 addition & 2 deletions src/server/cors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use dropshot::{HttpCodedResponse, HttpError};
use dropshot::{Body, HttpCodedResponse, HttpError};
use http::{Response, StatusCode};
use hyper::Body;
use schemars::JsonSchema;
use serde::Serialize;

Expand Down
Loading

0 comments on commit 6e9762c

Please sign in to comment.