diff --git a/Cargo.lock b/Cargo.lock index bc8da06..39e6521 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "bumpalo" -version = "3.19.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" [[package]] name = "byteorder" @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ "once_cell", "wasm-bindgen", @@ -538,9 +538,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", "once_cell", @@ -551,9 +551,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -561,9 +561,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ "bumpalo", "proc-macro2", @@ -574,9 +574,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index c1a5342..869f044 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,25 +5,28 @@ version = "0.11.0" edition = "2024" readme = "README.md" keywords = ["acn", "sacn", "dmx", "e131", "ansi"] -authors = ["Lukas Schmierer ", "Paul Lancaster "] +authors = [ + "Lukas Schmierer ", + "Paul Lancaster ", +] documentation = "https://github.com/RustLight/sacn" repository = "https://github.com/RustLight/sacn" license = "MIT OR Apache-2.0" homepage = "https://github.com/RustLight/sacn" exclude = [ - "documentation/*", - "further testing/*", - ".github/*", - ".travis.yml", - ".gitignore", + "documentation/*", + "further testing/*", + ".github/*", + ".travis.yml", + ".gitignore", ] [dependencies] -byteorder = { version = "1.5.0", features = [] } +byteorder = { version = "1.5.0", default-features = false } libc = { version = "0.2.171" } -socket2 = { version = "0.6.1", features = ["all"] } -thiserror = "2.0.0" -uuid = { version = "1.12", features = ["v4"] } +socket2 = { version = "0.6.1", features = ["all"], optional = true } +thiserror = { version = "2.0.0", default-features = false } +uuid = { version = "1.12", features = ["v4"], default-features = false } [dev-dependencies] crossterm = "0.29.0" @@ -31,7 +34,7 @@ serial_test = { version = "3.2.0", features = ["file_locks"] } [features] default = ["std"] -std = [] +std = ["dep:socket2", "uuid/std"] [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)'] } diff --git a/examples/stm32f7/.cargo/config.toml b/examples/stm32f7/.cargo/config.toml new file mode 100644 index 0000000..36051ea --- /dev/null +++ b/examples/stm32f7/.cargo/config.toml @@ -0,0 +1,9 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +rustflags = ['--cfg', 'getrandom_backend="custom"'] +# replace STM32G071C8Rx with your chip as listed in `probe-rs chip list` +runner = "probe-rs run --chip STM32F746NGHx --connect-under-reset --speed 4600" +[build] +target = "thumbv7em-none-eabi" # <-change for your platform + +[env] +DEFMT_LOG = "debug" # <- can change to info, warn, or error diff --git a/examples/stm32f7/Cargo.lock b/examples/stm32f7/Cargo.lock new file mode 100644 index 0000000..73bd0c4 --- /dev/null +++ b/examples/stm32f7/Cargo.lock @@ -0,0 +1,1292 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "aligned" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee4508988c62edf04abd8d92897fca0c2995d907ce1dfeaf369dac3716a40685" +dependencies = [ + "as-slice", +] + +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "bare-metal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bit_field" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" + +[[package]] +name = "bitfield" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" + +[[package]] +name = "block-device-driver" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c051592f59fe68053524b4c4935249b806f72c1f544cfb7abe4f57c3be258e" +dependencies = [ + "aligned", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.2.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f50d563227a1c37cc0a263f64eca3334388c01c5e4c4861a9def205c614383c" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "const-default" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b396d1f76d455557e1218ec8066ae14bba60b4b36ecd55577ba979f5db7ecaa" + +[[package]] +name = "cordyceps" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "688d7fbb8092b8de775ef2536f36c8c31f2bc4006ece2e8d8ad2d17d00ce0a2a" +dependencies = [ + "loom", + "tracing", +] + +[[package]] +name = "cortex-m" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" +dependencies = [ + "bare-metal", + "bitfield", + "critical-section", + "embedded-hal 0.2.7", + "volatile-register", +] + +[[package]] +name = "cortex-m-rt" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "801d4dec46b34c299ccf6b036717ae0fce602faa4f4fe816d9013b9a7c9f5ba6" +dependencies = [ + "cortex-m-rt-macros", +] + +[[package]] +name = "cortex-m-rt-macros" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37549a379a9e0e6e576fd208ee60394ccb8be963889eebba3ffe0980364f472" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.111", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "defmt" +version = "0.3.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0963443817029b2024136fc4dd07a5107eb8f977eaf18fcd1fdeb11306b64ad" +dependencies = [ + "defmt 1.0.1", +] + +[[package]] +name = "defmt" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "548d977b6da32fa1d1fda2876453da1e7df63ad0304c8b3dae4dbe7b96f39b78" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d4fc12a85bcf441cfe44344c4b72d58493178ce635338a3f3b78943aceb258e" +dependencies = [ + "defmt-parser", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "defmt-parser" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" +dependencies = [ + "thiserror", +] + +[[package]] +name = "defmt-rtt" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d5a25c99d89c40f5676bec8cefe0614f17f0f40e916f98e345dae941807f9e" +dependencies = [ + "critical-section", + "defmt 1.0.1", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "embassy-embedded-hal" +version = "0.5.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "defmt 1.0.1", + "embassy-futures", + "embassy-hal-internal", + "embassy-sync", + "embassy-time", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "embedded-storage", + "embedded-storage-async", + "nb 1.1.0", +] + +[[package]] +name = "embassy-executor" +version = "0.9.1" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "cordyceps", + "cortex-m", + "critical-section", + "defmt 1.0.1", + "document-features", + "embassy-executor-macros", + "embassy-executor-timer-queue", +] + +[[package]] +name = "embassy-executor-macros" +version = "0.7.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "embassy-executor-timer-queue" +version = "0.1.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" + +[[package]] +name = "embassy-futures" +version = "0.1.2" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" + +[[package]] +name = "embassy-hal-internal" +version = "0.3.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "cortex-m", + "critical-section", + "defmt 1.0.1", + "num-traits", +] + +[[package]] +name = "embassy-net" +version = "0.7.1" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "defmt 1.0.1", + "document-features", + "embassy-net-driver", + "embassy-sync", + "embassy-time", + "embedded-io-async 0.7.0", + "embedded-nal-async", + "heapless 0.8.0", + "managed", + "smoltcp", +] + +[[package]] +name = "embassy-net-driver" +version = "0.2.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "defmt 1.0.1", +] + +[[package]] +name = "embassy-stm32" +version = "0.4.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "aligned", + "bit_field", + "bitflags 2.10.0", + "block-device-driver", + "cfg-if", + "cortex-m", + "cortex-m-rt", + "critical-section", + "defmt 1.0.1", + "document-features", + "embassy-embedded-hal", + "embassy-futures", + "embassy-hal-internal", + "embassy-net-driver", + "embassy-sync", + "embassy-time", + "embassy-time-driver", + "embassy-time-queue-utils", + "embassy-usb-driver", + "embassy-usb-synopsys-otg", + "embedded-can", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "embedded-hal-nb", + "embedded-io 0.7.1", + "embedded-io-async 0.7.0", + "embedded-storage", + "embedded-storage-async", + "futures-util", + "heapless 0.9.2", + "nb 1.1.0", + "proc-macro2", + "quote", + "rand_core 0.6.4", + "rand_core 0.9.3", + "sdio-host", + "static_assertions", + "stm32-fmc", + "stm32-metapac", + "trait-set", + "vcell", + "volatile-register", +] + +[[package]] +name = "embassy-sync" +version = "0.7.2" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "cfg-if", + "critical-section", + "defmt 1.0.1", + "embedded-io-async 0.7.0", + "futures-core", + "futures-sink", + "heapless 0.8.0", +] + +[[package]] +name = "embassy-time" +version = "0.5.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "cfg-if", + "critical-section", + "defmt 1.0.1", + "document-features", + "embassy-time-driver", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0", + "embedded-hal-async", + "futures-core", +] + +[[package]] +name = "embassy-time-driver" +version = "0.2.1" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "document-features", +] + +[[package]] +name = "embassy-time-queue-utils" +version = "0.3.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "embassy-executor-timer-queue", + "heapless 0.8.0", +] + +[[package]] +name = "embassy-usb-driver" +version = "0.2.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "defmt 1.0.1", + "embedded-io-async 0.6.1", +] + +[[package]] +name = "embassy-usb-synopsys-otg" +version = "0.3.1" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" +dependencies = [ + "critical-section", + "defmt 1.0.1", + "embassy-sync", + "embassy-usb-driver", +] + +[[package]] +name = "embedded-alloc" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f2de9133f68db0d4627ad69db767726c99ff8585272716708227008d3f1bddd" +dependencies = [ + "const-default", + "critical-section", + "linked_list_allocator", + "rlsf", +] + +[[package]] +name = "embedded-can" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" +dependencies = [ + "nb 1.1.0", +] + +[[package]] +name = "embedded-hal" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" +dependencies = [ + "nb 0.1.3", + "void", +] + +[[package]] +name = "embedded-hal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" + +[[package]] +name = "embedded-hal-async" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4c685bbef7fe13c3c6dd4da26841ed3980ef33e841cddfa15ce8a8fb3f1884" +dependencies = [ + "embedded-hal 1.0.0", +] + +[[package]] +name = "embedded-hal-nb" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba4268c14288c828995299e59b12babdbe170f6c6d73731af1b4648142e8605" +dependencies = [ + "embedded-hal 1.0.0", + "nb 1.1.0", +] + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] +name = "embedded-io" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eb1aa714776b75c7e67e1da744b81a129b3ff919c8712b5e1b32252c1f07cc7" +dependencies = [ + "defmt 1.0.1", +] + +[[package]] +name = "embedded-io-async" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" +dependencies = [ + "embedded-io 0.6.1", +] + +[[package]] +name = "embedded-io-async" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2564b9f813c544241430e147d8bc454815ef9ac998878d30cc3055449f7fd4c0" +dependencies = [ + "defmt 1.0.1", + "embedded-io 0.7.1", +] + +[[package]] +name = "embedded-nal" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56a28be191a992f28f178ec338a0bf02f63d7803244add736d026a471e6ed77" +dependencies = [ + "nb 1.1.0", +] + +[[package]] +name = "embedded-nal-async" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5a1bd585135d302f8f6d7de329310938093da6271b37a6c94b8798795c0c6d" +dependencies = [ + "embedded-io-async 0.7.0", + "embedded-nal", +] + +[[package]] +name = "embedded-storage" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21dea9854beb860f3062d10228ce9b976da520a73474aed3171ec276bc0c032" + +[[package]] +name = "embedded-storage-async" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1763775e2323b7d5f0aa6090657f5e21cfa02ede71f5dc40eead06d64dcd15cc" +dependencies = [ + "embedded-storage", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generator" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52f04ae4152da20c76fe800fa48659201d5cf627c5149ca0b707b69d7eef6cf9" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows-link", + "windows-result", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "defmt 0.3.100", + "hash32", + "stable_deref_trait", +] + +[[package]] +name = "heapless" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af2455f757db2b292a9b1768c4b70186d443bcb3b316252d6b540aec1cd89ed" +dependencies = [ + "hash32", + "stable_deref_trait", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.178" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" + +[[package]] +name = "linked_list_allocator" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" + +[[package]] +name = "litrs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "managed" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "nb" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" +dependencies = [ + "nb 1.1.0", +] + +[[package]] +name = "nb" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "panic-probe" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd402d00b0fb94c5aee000029204a46884b1262e0c443f166d86d2c0747e1a1a" +dependencies = [ + "cortex-m", + "defmt 1.0.1", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "portable-atomic" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f59e70c4aef1e55797c2e8fd94a4f2a973fc972cfde0e0b05f683667b0cd39dd" + +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "proc-macro2" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "rlsf" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222fb240c3286247ecdee6fa5341e7cdad0ffdf8e7e401d9937f2d58482a20bf" +dependencies = [ + "cfg-if", + "const-default", + "libc", + "svgbobdoc", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "sacn" +version = "0.11.0" +dependencies = [ + "byteorder", + "defmt 1.0.1", + "libc", + "thiserror", + "uuid", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "sdio-host" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b328e2cb950eeccd55b7f55c3a963691455dcd044cfb5354f0c5e68d2c2d6ee2" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "smoltcp" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad095989c1533c1c266d9b1e8d70a1329dd3723c3edac6d03bbd67e7bf6f4bb" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "cfg-if", + "defmt 0.3.100", + "heapless 0.8.0", + "managed", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "static_cell" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0530892bb4fa575ee0da4b86f86c667132a94b74bb72160f58ee5a4afec74c23" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "stm32-fmc" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72692594faa67f052e5e06dd34460951c21e83bc55de4feb8d2666e2f15480a2" +dependencies = [ + "embedded-hal 1.0.0", +] + +[[package]] +name = "stm32-metapac" +version = "18.0.0" +source = "git+https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-24369dbbc177b111de7d6a14403123a46fbc4bfb#d7f8c227284ca1f901d156073b450bc6d5d41f86" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "defmt 0.3.100", +] + +[[package]] +name = "stm32f7" +version = "0.1.0" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "critical-section", + "defmt 1.0.1", + "defmt-rtt", + "embassy-executor", + "embassy-net", + "embassy-stm32", + "embassy-time", + "embedded-alloc", + "panic-probe", + "sacn", + "smoltcp", + "static_cell", + "stm32-fmc", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "svgbobdoc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2c04b93fc15d79b39c63218f15e3fdffaa4c227830686e3b7c5f41244eb3e50" +dependencies = [ + "base64", + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-width", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "trait-set" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79e2e9c9ab44c6d7c20d5976961b47e8f49ac199154daa514b77cd1ab536625" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "uuid" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" +dependencies = [ + "getrandom", +] + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "vcell" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "volatile-register" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" +dependencies = [ + "vcell", +] + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[patch.unused]] +name = "embassy-usb" +version = "0.5.1" +source = "git+https://github.com/embassy-rs/embassy/?rev=96483e86b8c7b99748dd5f3b9b6b6852ccf61f35#96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml new file mode 100644 index 0000000..95304d0 --- /dev/null +++ b/examples/stm32f7/Cargo.toml @@ -0,0 +1,72 @@ +[package] +name = "stm32f7" +version = "0.1.0" +edition = "2024" + +[[bin]] +name = "stm32f7" +path = "src/main.rs" +test = false +bench = false + +[dependencies] +sacn = { path = "../../", default-features = false, features = ["defmt"] } +embassy-stm32 = { version = "0.4.0", features = [ + "defmt", + "stm32f746ng", + "memory-x", + "unstable-pac", + "time-driver-tim5", + "exti", + "time", +] } +smoltcp = { version = "0.12.0", default-features = false, features = [ + "iface-max-multicast-group-count-32", +] } +embassy-executor = { version = "0.9.1", features = [ + "arch-cortex-m", + "executor-thread", + "defmt", +] } +embassy-time = { version = "0.5.0", features = [ + "defmt", + "defmt-timestamp-uptime", + "tick-hz-32_768", +] } +embassy-net = { version = "0.7.1", features = [ + "defmt", + "tcp", + "raw", + "udp", + "dhcpv4", + "medium-ethernet", + "multicast", + +] } +defmt-rtt = "1.0.0" +defmt = "1.0.1" + +cortex-m = { version = "0.7.6", features = [ + "inline-asm", + "critical-section-single-core", +] } +cortex-m-rt = "0.7.0" +panic-probe = { version = "1.0.0", features = ["print-defmt"] } +critical-section = "1.1.2" +stm32-fmc = "0.4.0" +embedded-alloc = { version = "0.6.0" } +static_cell = "2.1.1" + +[patch.crates-io] +embassy-sync = { git = "https://github.com/embassy-rs/embassy/", rev = "96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" } +embassy-executor = { git = "https://github.com/embassy-rs/embassy/", rev = "96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" } +embassy-net = { git = "https://github.com/embassy-rs/embassy/", rev = "96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" } +embassy-time = { git = "https://github.com/embassy-rs/embassy/", rev = "96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" } +embassy-stm32 = { git = "https://github.com/embassy-rs/embassy/", rev = "96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" } +embassy-usb = { git = "https://github.com/embassy-rs/embassy/", rev = "96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" } +embassy-futures = { git = "https://github.com/embassy-rs/embassy/", rev = "96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" } +embassy-embedded-hal = { git = "https://github.com/embassy-rs/embassy/", rev = "96483e86b8c7b99748dd5f3b9b6b6852ccf61f35" } + +[profile.release] +debug = 2 +lto = "fat" diff --git a/examples/stm32f7/README.md b/examples/stm32f7/README.md new file mode 100644 index 0000000..0a1611f --- /dev/null +++ b/examples/stm32f7/README.md @@ -0,0 +1,25 @@ +# STM32F746G-DISC Demo in Rust + +This is an example sACN receiver that runs on an STM32F746G-DISCO development board. +It awaits a discovery packet and then joins the multicast groups for the discovered +universes. It was based on [this demo crate](https://github.com/ProfFan/f7disco-rust-demo) + +This example uses Embassy [`embassy-rs`](https://embassy.dev/) as the async +framework and network stack and [`probe-rs`](https://probe.rs/) as runner. +Please refer to their respective documentation for instructions on how to install +the necessary tools. + +## Building + +Change your working directory to the example's root directory. + +```sh +cd examples/stm32f7/ +``` + +Build or run using cargo. + +```sh +cargo build -r +cargo run -r +``` diff --git a/examples/stm32f7/build.rs b/examples/stm32f7/build.rs new file mode 100644 index 0000000..8cd32d7 --- /dev/null +++ b/examples/stm32f7/build.rs @@ -0,0 +1,5 @@ +fn main() { + println!("cargo:rustc-link-arg-bins=--nmagic"); + println!("cargo:rustc-link-arg-bins=-Tlink.x"); + println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); +} diff --git a/examples/stm32f7/rust-toolchain.toml b/examples/stm32f7/rust-toolchain.toml new file mode 100644 index 0000000..0e80dca --- /dev/null +++ b/examples/stm32f7/rust-toolchain.toml @@ -0,0 +1,6 @@ +[toolchain] +channel = "nightly" +components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ] +targets = [ + "thumbv7em-none-eabi", +] diff --git a/examples/stm32f7/src/main.rs b/examples/stm32f7/src/main.rs new file mode 100644 index 0000000..3258b0a --- /dev/null +++ b/examples/stm32f7/src/main.rs @@ -0,0 +1,262 @@ +#![no_std] +#![no_main] + +mod sdram_drv; + +use defmt::*; + +use embassy_executor::Spawner; +use embassy_net::udp::{PacketMetadata, UdpSocket}; +use embassy_net::{IpListenEndpoint, Stack, StackResources}; +use embassy_stm32::bind_interrupts; +use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue, Sma}; +use embassy_stm32::fmc::Fmc; +use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_stm32::peripherals::{ETH, ETH_SMA}; +use embassy_stm32::rng::Rng; +use embassy_stm32::time::mhz; +use embassy_time::{Duration, Timer}; + +extern crate alloc; +use embedded_alloc::TlsfHeap as Heap; + +use sacn::packet::{ + AcnRootLayerProtocol, SynchronizationPacketFramingLayer, UniverseDiscoveryPacketFramingLayer, + UniverseDiscoveryPacketUniverseDiscoveryLayer, universe_to_ipv4_multicast_addr, +}; +use static_cell::StaticCell; + +#[global_allocator] +static HEAP: Heap = Heap::empty(); + +use {defmt_rtt as _, panic_probe as _}; + +bind_interrupts!(struct Irqs { + ETH => embassy_stm32::eth::InterruptHandler; + RNG => embassy_stm32::rng::InterruptHandler; +}); + +type Device = Ethernet<'static, ETH, GenericPhy>>; +#[embassy_executor::task] +async fn net_task(mut runner: embassy_net::Runner<'static, Device>) { + runner.run().await; +} + +fn join_multicast_group(stack: &mut Stack<'static>, universe: u16) { + match universe_to_ipv4_multicast_addr(universe) { + Ok(addr) => { + let r = stack.join_multicast_group(*addr.ip()); + if let Err(e) = r { + error!("Multicast error: {}", e); + } + } + Err(e) => { + error!( + "Error joining multicast group {}: {}", + universe, + Debug2Format(&e) + ) + } + } +} + +#[embassy_executor::task] +async fn sacn_listener(mut stack: Stack<'static>) { + let mut rx_buffer = [0; 4096]; + let mut tx_buffer = [0; 4096]; + let mut rx_meta = [PacketMetadata::EMPTY; 16]; + let mut tx_meta = [PacketMetadata::EMPTY; 16]; + + let mut buf = [0u8; 1024]; + + let mut socket = UdpSocket::new( + stack, + &mut rx_meta, + &mut rx_buffer, + &mut tx_meta, + &mut tx_buffer, + ); + socket + .bind(IpListenEndpoint { + addr: None, + port: sacn::packet::ACN_SDT_MULTICAST_PORT, + }) + .unwrap(); + + join_multicast_group(&mut stack, sacn::packet::E131_DISCOVERY_UNIVERSE); + + loop { + socket.recv_from(&mut buf).await.unwrap(); + match sacn::packet::AcnRootLayerProtocol::parse(&buf) { + Ok(acn) => { + info!("[acn]: {}", acn); + let pdu = acn.pdu; + let data = pdu.data; + match data { + sacn::packet::E131RootLayerData::DataPacket(data) => { + info!("[data]: {}", data,); + } + sacn::packet::E131RootLayerData::SynchronizationPacket(sync) => { + info!("[sync]: {}", sync); + } + sacn::packet::E131RootLayerData::UniverseDiscoveryPacket(disco) => { + info!("[disco]: {}", disco); + let UniverseDiscoveryPacketFramingLayer { source_name, data } = disco; + let UniverseDiscoveryPacketUniverseDiscoveryLayer { + page, + last_page, + universes, + } = data; + for universe in universes.iter() { + if let Ok(addr) = universe_to_ipv4_multicast_addr(*universe) + && !stack.has_multicast_group(*addr.ip()) + { + let r = stack.join_multicast_group(*addr.ip()); + if let Err(e) = r { + error!( + "Unable to join multicast group universe: {}, ip: {}, error: {}", + universe, + addr.ip(), + e + ); + } + } + } + } + } + } + Err(e) => { + error!("sACN error: {}", Debug2Format(&e)); + } + } + } +} + +#[embassy_executor::main] +async fn main(spawner: Spawner) { + // ------------------------------------------------------------------------ + // Configure clocks + use embassy_stm32::rcc::{ + AHBPrescaler, APBPrescaler, Hse, HseMode, Pll, PllMul, PllPDiv, PllPreDiv, PllQDiv, + PllSource, Sysclk, + }; + + let mut config = embassy_stm32::Config::default(); + config.rcc.sys = Sysclk::PLL1_P; + config.rcc.ahb_pre = AHBPrescaler::DIV1; + config.rcc.apb1_pre = APBPrescaler::DIV4; + config.rcc.apb2_pre = APBPrescaler::DIV2; + + // HSE is on and ready + config.rcc.hse = Some(Hse { + freq: mhz(25), + mode: HseMode::Oscillator, + }); + config.rcc.pll_src = PllSource::HSE; + + config.rcc.pll = Some(Pll { + prediv: PllPreDiv::DIV25, // PLLM + mul: PllMul::MUL400, // PLLN + divp: Some(PllPDiv::DIV2), // SYSCLK = 400/2 = 200 MHz + divq: Some(PllQDiv::DIV9), // PLLQ = 400/9 = 44.44 MHz + divr: None, + }); + let p = embassy_stm32::init(config); + + info!("Starting..."); + + // Config SDRAM and HEAP storage + // ---------------------------------------------------------- + // Configure MPU for external SDRAM (64 Mbit = 8 Mbyte) + // MPU is disabled by default + const SDRAM_SIZE: usize = 8 * 1024 * 1024; + + #[rustfmt::skip] + let mut sdram = Fmc::sdram_a12bits_d16bits_4banks_bank1( + p.FMC, + // A0-A11 + p.PF0, p.PF1, p.PF2, p.PF3, p.PF4, p.PF5, p.PF12, p.PF13, p.PF14, p.PF15, p.PG0, p.PG1, + // BA0-BA1 + p.PG4, p.PG5, + // D0-D15 + p.PD14, p.PD15, p.PD0, p.PD1, p.PE7, p.PE8, p.PE9, p.PE10, p.PE11, p.PE12, p.PE13, p.PE14, p.PE15, p.PD8, p.PD9, p.PD10, + // NBL0 - NBL1 + p.PE0, p.PE1, + p.PC3, // SDCKE0 + p.PG8, // SDCLK + p.PG15, // SDNCAS + p.PH3, // SDNE0 (!CS) + p.PF11, // SDRAS + p.PH5, // SDNWE + sdram_drv::mt48lc4m32b2_6::Mt48lc4m32b2 {}, + ); + + let mut delay = embassy_time::Delay; + + unsafe { + // Initialise controller and SDRAM + let ram_ptr: *mut u32 = sdram.init(&mut delay) as *mut _; + + info!("SDRAM Initialized at {:x}", ram_ptr as usize); + + // Convert raw pointer to slice and initialize the HEAP + HEAP.init(ram_ptr as usize, SDRAM_SIZE) + }; + + // Config RNG + // ---------------------------------------------------------- + let mut rng = Rng::new(p.RNG, Irqs); + let mut seed = [0; 8]; + rng.fill_bytes(&mut seed); + let seed = u64::from_le_bytes(seed); + + // Config Ethernet + // ---------------------------------------------------------- + // By default this is configured for DHCP + let config = embassy_net::Config::dhcpv4(Default::default()); + let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; + static PACKETS: StaticCell> = StaticCell::new(); + let device = Ethernet::new( + PACKETS.init(PacketQueue::<16, 16>::new()), + p.ETH, + Irqs, + p.PA1, + p.PA7, + p.PC4, + p.PC5, + p.PG13, + p.PG14, + p.PG11, + mac_addr, + p.ETH_SMA, + p.PA2, + p.PC1, + ); + + // Initialise network stack resources + // ---------------------------------------------------------- + static RESOURCES: StaticCell> = StaticCell::new(); + let (stack, runner) = + embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); + + // Spawn the network handler and wait for a valid configuration + // ---------------------------------------------------------- + spawner.spawn(net_task(runner).unwrap()); + stack.wait_link_up().await; + stack.wait_config_up().await; + info!("Network task initialized"); + + // Spawn the main sACN listener task + // ---------------------------------------------------------- + spawner.spawn(sacn_listener(stack).unwrap()); + + let mut led = Output::new(p.PI1, Level::High, Speed::Low); + + // Blink an LED, just in case + loop { + led.set_high(); + Timer::after(Duration::from_millis(100)).await; + led.set_low(); + Timer::after(Duration::from_millis(900)).await; + } +} diff --git a/examples/stm32f7/src/sdram_drv.rs b/examples/stm32f7/src/sdram_drv.rs new file mode 100644 index 0000000..289af74 --- /dev/null +++ b/examples/stm32f7/src/sdram_drv.rs @@ -0,0 +1,59 @@ +pub mod mt48lc4m32b2_6 { + use stm32_fmc::{SdramChip, SdramConfiguration, SdramTiming}; + + const BURST_LENGTH_1: u16 = 0x0000; + #[allow(dead_code)] + const BURST_LENGTH_2: u16 = 0x0001; + #[allow(dead_code)] + const BURST_LENGTH_4: u16 = 0x0002; + #[allow(dead_code)] + const BURST_LENGTH_8: u16 = 0x0004; + const BURST_TYPE_SEQUENTIAL: u16 = 0x0000; + #[allow(dead_code)] + const BURST_TYPE_INTERLEAVED: u16 = 0x0008; + #[allow(dead_code)] + const CAS_LATENCY_2: u16 = 0x0020; + const CAS_LATENCY_3: u16 = 0x0030; + const OPERATING_MODE_STANDARD: u16 = 0x0000; + #[allow(dead_code)] + const WRITEBURST_MODE_PROGRAMMED: u16 = 0x0000; + const WRITEBURST_MODE_SINGLE: u16 = 0x0200; + + /// MT48LC4M32B2B5-6A with Speed Grade 6, 16-bit data width + #[derive(Clone, Copy, Debug, PartialEq)] + pub struct Mt48lc4m32b2 {} + + impl SdramChip for Mt48lc4m32b2 { + /// Value of the mode register + const MODE_REGISTER: u16 = BURST_LENGTH_1 + | BURST_TYPE_SEQUENTIAL + | CAS_LATENCY_3 + | OPERATING_MODE_STANDARD + | WRITEBURST_MODE_SINGLE; + + /// Timing Parameters + const TIMING: SdramTiming = SdramTiming { + startup_delay_ns: 100_000, // 100 µs + max_sd_clock_hz: 100_000_000, // 100 MHz + refresh_period_ns: 15_625, // 64ms / (4096 rows) = 15625ns + mode_register_to_active: 2, // tMRD = 2 cycles + exit_self_refresh: 7, // tXSR = 70ns + active_to_precharge: 4, // tRAS = 42ns + row_cycle: 7, // tRC = 70ns + row_precharge: 2, // tRP = 18ns + row_to_column: 2, // tRCD = 18ns + }; + + /// SDRAM controller configuration + const CONFIG: SdramConfiguration = SdramConfiguration { + column_bits: 8, + row_bits: 12, + memory_data_width: 16, // 16-bit + internal_banks: 4, // 4 internal banks + cas_latency: 3, // CAS latency = 2 + write_protection: false, + read_burst: true, + read_pipe_delay_cycles: 0, + }; + } +} diff --git a/src/error.rs b/src/error.rs index 2756d33..c2bf011 100644 --- a/src/error.rs +++ b/src/error.rs @@ -22,6 +22,11 @@ //! SacnParsePackError(sacn_parse_pack_error::Error, sacn_parse_pack_error::ErrorKind) pub mod errors { + + // Import these at the crate level for no_std switching + extern crate alloc; + use alloc::string::String; + use crate::sacn_parse_pack_error::ParsePacketError; use thiserror::Error; use uuid::Uuid; @@ -30,19 +35,25 @@ pub mod errors { /// /// This type is used throughout the sACN crate for any operation which /// can produce an error. - pub type Result = std::result::Result; + pub type Result = core::result::Result; + impl From for SacnError { + fn from(source: uuid::Error) -> Self { + SacnError::Uuid(source) + } + } #[derive(Debug, Error)] pub enum SacnError { // Allow IO errors to be used with the error system. + #[cfg(feature = "std")] #[error("Io error occurred: {0}")] Io(#[from] std::io::Error), // Allow standard string library errors to be used with the error system. #[error("String error occurred: {0}")] - Str(#[from] std::str::Utf8Error), + Str(#[from] alloc::str::Utf8Error), // Allow UUID library to be used with error system. #[error("Uuid error occurred: {0}")] - Uuid(#[from] uuid::Error), + Uuid(uuid::Error), /// Returned to indicate that too many bytes were read to fit into supplied buffer. /// diff --git a/src/lib.rs b/src/lib.rs index acd6939..1829f13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,26 +182,51 @@ //! src.send(&[universe], &data, priority, dst_ip, sync_uni).unwrap(); //! ``` +#![no_std] #![doc(html_root_url = "https://docs.rs/sacn/")] // #![warn(missing_docs)] // Recursion limit for error_chain. #![recursion_limit = "1024"] +extern crate alloc; +#[cfg(feature = "std")] +extern crate std; + +//use core::{fmt, fmt::Display}; +#[cfg(not(feature = "std"))] +use alloc::{ + borrow::Cow, + format, + string::{String, ToString}, + vec::Vec, +}; +#[cfg(feature = "std")] +use std::{ + borrow::Cow, + format, println, + string::{String, ToString}, + vec, + vec::Vec, +}; + +/// The core crate is used for string processing during packet parsing/packing as well as to provide access to the Hash trait. +extern crate core; + /// The errors within the sACN crate related to parse/pack errors. /// Error-chain is used for errors within the library to allow chaining errors together to provide more informative backtraces. /// This completely replaces the old error system (sACN crate version 0.4.4) which relied on a simple Enum model without proper backtraces. +//#[cfg(feature = "std")] pub mod sacn_parse_pack_error; /// The errors used within the sACN crate, parse/pack errors are seperated out into sacn_parse_pack_error. +//#[cfg(feature = "std")] pub mod error; extern crate libc; /// The library is built on top of socket2 to provide the underlying UDP networking interface. +#[cfg(feature = "std")] extern crate socket2; -/// The core crate is used for string processing during packet parsing/packing as well as to provide access to the Hash trait. -extern crate core; - /// The byteorder crate is used for marshalling data on/off the network in Network Byte Order. extern crate byteorder; @@ -212,7 +237,9 @@ extern crate uuid; pub mod packet; /// The source module handles generation of sACN on the network. +#[cfg(feature = "std")] pub mod source; /// The receive module handles the receiving of sACN on the network. +#[cfg(feature = "std")] pub mod receive; diff --git a/src/packet.rs b/src/packet.rs index 4616184..99a2cda 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -52,6 +52,9 @@ //! # }} //! ``` +// Import these at the crate level for no_std switching +use crate::{Cow, String, ToString, Vec, format}; + /// Uses the sACN errors. use crate::error::errors::{Result, SacnError}; use crate::sacn_parse_pack_error::ParsePacketError; @@ -60,12 +63,8 @@ use crate::sacn_parse_pack_error::ParsePacketError; use core::hash::{self, Hash}; use core::str; -use std::borrow::Cow; -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; -use std::vec::Vec; -use std::{time, time::Duration}; - -use socket2::SockAddr; +use core::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}; +use core::{time, time::Duration}; /// The byteorder crate is used for marshalling data on/off the network in Network Byte Order. use byteorder::{ByteOrder, NetworkEndian}; @@ -329,18 +328,17 @@ pub const UNIVERSE_DISCOVERY_SOURCE_TIMEOUT: Duration = E131_NETWORK_DATA_LOSS_T /// # Errors /// IllegalUniverse: Returned if the given universe is outwith the allowed range of universes, /// see (is_universe_in_range)[fn.is_universe_in_range.packet]. -pub fn universe_to_ipv4_multicast_addr(universe: u16) -> Result { +pub fn universe_to_ipv4_multicast_addr(universe: u16) -> Result { is_universe_in_range(universe)?; let high_byte: u8 = ((universe >> 8) & 0xff) as u8; let low_byte: u8 = (universe & 0xff) as u8; // As per ANSI E1.31-2018 Section 9.3.1 Table 9-10. - Ok(SocketAddr::new( - IpAddr::V4(Ipv4Addr::new(239, 255, high_byte, low_byte)), + Ok(SocketAddrV4::new( + Ipv4Addr::new(239, 255, high_byte, low_byte), ACN_SDT_MULTICAST_PORT, - ) - .into()) + )) } /// Converts the given ANSI E1.31-2018 universe into an Ipv6 multicast address with the port set to the acn multicast port as defined @@ -353,15 +351,16 @@ pub fn universe_to_ipv4_multicast_addr(universe: u16) -> Result { /// # Errors /// IllegalUniverse: Returned if the given universe is outwith the allowed range of universes, /// see (is_universe_in_range)[fn.is_universe_in_range.packet]. -pub fn universe_to_ipv6_multicast_addr(universe: u16) -> Result { +pub fn universe_to_ipv6_multicast_addr(universe: u16) -> Result { is_universe_in_range(universe)?; // As per ANSI E1.31-2018 Section 9.3.2 Table 9-12. - Ok(SocketAddr::new( - IpAddr::V6(Ipv6Addr::new(0xFF18, 0, 0, 0, 0, 0, 0x8300, universe)), + Ok(SocketAddrV6::new( + Ipv6Addr::new(0xFF18, 0, 0, 0, 0, 0, 0x8300, universe), ACN_SDT_MULTICAST_PORT, - ) - .into()) + Default::default(), + Default::default(), + )) } /// Checks if the given universe is a valid universe to send on (within allowed range). @@ -558,7 +557,6 @@ fn pdu_info(buf: &[u8], vector_length: usize) -> Result { Ok(PduInfo { length, vector }) } - trait Pdu: Sized { fn parse(buf: &[u8]) -> Result; @@ -1498,7 +1496,7 @@ impl_universe_discovery_packet_universe_discovery_layer!(<'a>); #[cfg(test)] mod test { use super::*; - use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}; + use core::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}; /// The universe_to tests below check that the conversion from a universe to an IPv6 or IPv4 multicast address is done as /// per ANSI E1.31-2018 Section 9.3.1 Table 9-10 (IPv4) and ANSI E1.31-2018 Section 9.3.2 Table 9-11 + Table 9-12. @@ -1506,10 +1504,10 @@ mod test { fn test_universe_to_ipv4_lowest_byte_normal() { let val: u16 = 119; let res = universe_to_ipv4_multicast_addr(val).unwrap(); - assert!(res.as_socket_ipv4().unwrap().ip().is_multicast()); + assert!(res.ip().is_multicast()); assert_eq!( - res.as_socket_ipv4().unwrap(), + res, SocketAddrV4::new( Ipv4Addr::new(239, 255, (val / 256) as u8, (val % 256) as u8), ACN_SDT_MULTICAST_PORT @@ -1521,10 +1519,10 @@ mod test { fn test_universe_to_ip_ipv4_both_bytes_normal() { let val: u16 = 300; let res = universe_to_ipv4_multicast_addr(val).unwrap(); - assert!(res.as_socket_ipv4().unwrap().ip().is_multicast()); + assert!(res.ip().is_multicast()); assert_eq!( - res.as_socket_ipv4().unwrap(), + res, SocketAddrV4::new( Ipv4Addr::new(239, 255, (val / 256) as u8, (val % 256) as u8), ACN_SDT_MULTICAST_PORT @@ -1535,10 +1533,10 @@ mod test { #[test] fn test_universe_to_ip_ipv4_limit_high() { let res = universe_to_ipv4_multicast_addr(E131_MAX_MULTICAST_UNIVERSE).unwrap(); - assert!(res.as_socket_ipv4().unwrap().ip().is_multicast()); + assert!(res.ip().is_multicast()); assert_eq!( - res.as_socket_ipv4().unwrap(), + res, SocketAddrV4::new( Ipv4Addr::new( 239, @@ -1555,10 +1553,10 @@ mod test { fn test_universe_to_ip_ipv4_limit_low() { let res = universe_to_ipv4_multicast_addr(E131_MIN_MULTICAST_UNIVERSE).unwrap(); - assert!(res.as_socket_ipv4().unwrap().ip().is_multicast()); + assert!(res.ip().is_multicast()); assert_eq!( - res.as_socket_ipv4().unwrap(), + res, SocketAddrV4::new( Ipv4Addr::new( 239, @@ -1604,12 +1602,12 @@ mod test { let val: u16 = 119; let res = universe_to_ipv6_multicast_addr(val).unwrap(); - assert!(res.as_socket_ipv6().unwrap().ip().is_multicast()); + assert!(res.ip().is_multicast()); let low_16: u16 = (((val / 256) as u16) << 8) | ((val % 256) as u16); assert_eq!( - res.as_socket_ipv6().unwrap(), + res, SocketAddrV6::new( Ipv6Addr::new(0xFF18, 0, 0, 0, 0, 0, 0x8300, low_16), ACN_SDT_MULTICAST_PORT, @@ -1624,12 +1622,12 @@ mod test { let val: u16 = 300; let res = universe_to_ipv6_multicast_addr(val).unwrap(); - assert!(res.as_socket_ipv6().unwrap().ip().is_multicast()); + assert!(res.ip().is_multicast()); let low_16: u16 = (((val / 256) as u16) << 8) | ((val % 256) as u16); assert_eq!( - res.as_socket_ipv6().unwrap(), + res, SocketAddrV6::new( Ipv6Addr::new(0xFF18, 0, 0, 0, 0, 0, 0x8300, low_16), ACN_SDT_MULTICAST_PORT, @@ -1643,13 +1641,13 @@ mod test { fn test_universe_to_ip_ipv6_limit_high() { let res = universe_to_ipv6_multicast_addr(E131_MAX_MULTICAST_UNIVERSE).unwrap(); - assert!(res.as_socket_ipv6().unwrap().ip().is_multicast()); + assert!(res.ip().is_multicast()); let low_16: u16 = (((E131_MAX_MULTICAST_UNIVERSE / 256) as u16) << 8) | ((E131_MAX_MULTICAST_UNIVERSE % 256) as u16); assert_eq!( - res.as_socket_ipv6().unwrap(), + res, SocketAddrV6::new( Ipv6Addr::new(0xFF18, 0, 0, 0, 0, 0, 0x8300, low_16), ACN_SDT_MULTICAST_PORT, @@ -1663,13 +1661,13 @@ mod test { fn test_universe_to_ip_ipv6_limit_low() { let res = universe_to_ipv6_multicast_addr(E131_MIN_MULTICAST_UNIVERSE).unwrap(); - assert!(res.as_socket_ipv6().unwrap().ip().is_multicast()); + assert!(res.ip().is_multicast()); let low_16: u16 = (((E131_MIN_MULTICAST_UNIVERSE / 256) as u16) << 8) | ((E131_MIN_MULTICAST_UNIVERSE % 256) as u16); assert_eq!( - res.as_socket_ipv6().unwrap(), + res, SocketAddrV6::new( Ipv6Addr::new(0xFF18, 0, 0, 0, 0, 0, 0x8300, low_16), ACN_SDT_MULTICAST_PORT, diff --git a/src/receive.rs b/src/receive.rs index 3e15eee..8e9d644 100644 --- a/src/receive.rs +++ b/src/receive.rs @@ -17,6 +17,9 @@ // received, if a discovery packet is received but there are more pages the source won't be discovered until all the pages are received. // If a page is lost this therefore means the source update / discovery in its entirety will be lost - implementation detail. +// Import these at the crate level for no_std switching +use crate::{String, ToString, Vec, format, vec}; + /// Socket 2 used for the underlying UDP socket that sACN is sent over. use socket2::{Domain, Protocol, SockAddr, Socket, Type}; @@ -1210,13 +1213,13 @@ impl SacnNetworkReceiver { /// /// Will return an Io error if cannot join the universes corresponding multicast group address. fn listen_multicast_universe(&self, universe: u16) -> Result<()> { - let multicast_addr = if self.addr.is_ipv4() { - universe_to_ipv4_multicast_addr(universe)? // "Failed to convert universe to IPv4 multicast addr" + let multicast_addr: SocketAddr = if self.addr.is_ipv4() { + SocketAddr::V4(universe_to_ipv4_multicast_addr(universe)?) // "Failed to convert universe to IPv4 multicast addr" } else { - universe_to_ipv6_multicast_addr(universe)? // "Failed to convert universe to IPv6 multicast addr" + SocketAddr::V6(universe_to_ipv6_multicast_addr(universe)?) // "Failed to convert universe to IPv6 multicast addr" }; - join_unix_multicast(&self.socket, multicast_addr, self.addr.ip()) + join_unix_multicast(&self.socket, multicast_addr.into(), self.addr.ip()) } /// Removes this SacnNetworkReceiver from the multicast group which corresponds to the given universe. @@ -1225,13 +1228,13 @@ impl SacnNetworkReceiver { /// Will return an Error if the given universe cannot be converted to an Ipv4 or Ipv6 multicast_addr depending on if the Receiver is bound to an /// IPv4 or IPv6 address. See packet::universe_to_ipv4_multicast_addr and packet::universe_to_ipv6_multicast_addr. fn mute_multicast_universe(&mut self, universe: u16) -> Result<()> { - let multicast_addr = if self.addr.is_ipv4() { - universe_to_ipv4_multicast_addr(universe)? + let multicast_addr: SocketAddr = if self.addr.is_ipv4() { + SocketAddr::V4(universe_to_ipv4_multicast_addr(universe)?) } else { - universe_to_ipv6_multicast_addr(universe)? + SocketAddr::V6(universe_to_ipv6_multicast_addr(universe)?) }; - leave_unix_multicast(&self.socket, multicast_addr, self.addr.ip()) + leave_unix_multicast(&self.socket, multicast_addr.into(), self.addr.ip()) } /// Sets the value of the is_multicast_enabled flag to the given value. diff --git a/src/sacn_parse_pack_error.rs b/src/sacn_parse_pack_error.rs index 469649a..ddb5d8d 100644 --- a/src/sacn_parse_pack_error.rs +++ b/src/sacn_parse_pack_error.rs @@ -9,6 +9,7 @@ //! The errors used within the SacnLibrary specifically those related to parsing and packeting packets received/sent on the network. +use crate::String; use thiserror::Error; use uuid::Uuid; diff --git a/src/source.rs b/src/source.rs index 89a8166..aae3a2a 100644 --- a/src/source.rs +++ b/src/source.rs @@ -17,11 +17,14 @@ use crate::error::errors::*; use crate::packet::*; +// Import these at the crate level for no_std switching +use crate::{String, ToString, Vec, println, vec}; + +use core::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use std::cell::RefCell; use std::cmp; use std::cmp::min; use std::collections::HashMap; -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use std::sync::{Arc, Mutex, MutexGuard}; use std::thread; use std::thread::JoinHandle; @@ -856,14 +859,14 @@ impl SacnSourceInternal { std::io::Error::new(e.kind(), "Failed to send data unicast on socket") })?; } else { - let dst = if self.addr.is_ipv6() { - universe_to_ipv6_multicast_addr(universe)? + let dst: SocketAddr = if self.addr.is_ipv6() { + SocketAddr::V6(universe_to_ipv6_multicast_addr(universe)?) } else { - universe_to_ipv4_multicast_addr(universe)? + SocketAddr::V4(universe_to_ipv4_multicast_addr(universe)?) }; self.socket - .send_to(&packet.pack_alloc().unwrap(), &dst) + .send_to(&packet.pack_alloc().unwrap(), &dst.into()) .map_err(|e| { std::io::Error::new(e.kind(), "Failed to send data multicast on socket") })?; @@ -900,11 +903,11 @@ impl SacnSourceInternal { self.universe_allowed(&universe)?; let ip = if let Some(dst) = dst_ip { - dst.into() + dst } else if self.addr.is_ipv6() { - universe_to_ipv6_multicast_addr(universe)? + SocketAddr::V6(universe_to_ipv6_multicast_addr(universe)?) } else { - universe_to_ipv4_multicast_addr(universe)? + SocketAddr::V4(universe_to_ipv4_multicast_addr(universe)?) }; let mut sequence = match self.sync_sequences.borrow().get(&universe) { @@ -922,7 +925,7 @@ impl SacnSourceInternal { }, }; self.socket - .send_to(&packet.pack_alloc()?, &ip) + .send_to(&packet.pack_alloc()?, &ip.into()) .map_err(|e| std::io::Error::new(e.kind(), "Failed to send sync packet on socket"))?; if sequence == 255 { @@ -958,12 +961,12 @@ impl SacnSourceInternal { self.universe_allowed(&universe)?; let ip = match dst_ip { - Some(x) => x.into(), + Some(x) => x, None => { if self.addr.is_ipv6() { - universe_to_ipv6_multicast_addr(universe)? + SocketAddr::V6(universe_to_ipv6_multicast_addr(universe)?) } else { - universe_to_ipv4_multicast_addr(universe)? + SocketAddr::V4(universe_to_ipv4_multicast_addr(universe)?) } } }; @@ -993,7 +996,7 @@ impl SacnSourceInternal { }; let res = &packet.pack_alloc().unwrap(); - self.socket.send_to(res, &ip)?; + self.socket.send_to(res, &ip.into())?; if sequence == 255 { sequence = 0; @@ -1112,12 +1115,12 @@ impl SacnSourceInternal { }; let ip = if self.addr.is_ipv6() { - universe_to_ipv6_multicast_addr(E131_DISCOVERY_UNIVERSE)? + SocketAddr::V6(universe_to_ipv6_multicast_addr(E131_DISCOVERY_UNIVERSE)?) } else { - universe_to_ipv4_multicast_addr(E131_DISCOVERY_UNIVERSE)? + SocketAddr::V4(universe_to_ipv4_multicast_addr(E131_DISCOVERY_UNIVERSE)?) }; - self.socket.send_to(&packet.pack_alloc()?, &ip)?; + self.socket.send_to(&packet.pack_alloc()?, &ip.into())?; Ok(()) } diff --git a/tests/ipv4_tests.rs b/tests/ipv4_tests.rs index 0f6face..2be32d2 100644 --- a/tests/ipv4_tests.rs +++ b/tests/ipv4_tests.rs @@ -18,7 +18,7 @@ use std::thread::sleep; use std::sync::mpsc; use std::sync::mpsc::{Sender, SyncSender, Receiver, RecvTimeoutError}; use std::time::{Duration, Instant}; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use core::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::iter; use std::convert::TryInto; // Used for converting between u8 and u16 representations. use std::str; // Used for converting between bytes and strings. @@ -3521,10 +3521,10 @@ fn test_discovery_packet_transmit_format() { recv_socket.bind(&addr.into()).unwrap(); // Receiving on the discovery universe shows that the discovery universe is correctly used for discovery packets as per ANSI E1.31-2018 Section 6.2.7. - let address = universe_to_ipv4_multicast_addr(E131_DISCOVERY_UNIVERSE).unwrap().as_socket_ipv4(); + let address = universe_to_ipv4_multicast_addr(E131_DISCOVERY_UNIVERSE).unwrap(); recv_socket - .join_multicast_v4(&address.unwrap().ip(), &Ipv4Addr::new(0, 0, 0, 0)) + .join_multicast_v4(&address.ip(), &Ipv4Addr::new(0, 0, 0, 0)) .unwrap(); let mut recv_buf = [0; DISCOVERY_PACKET_LENGTH_EXPECTED]; @@ -3682,10 +3682,10 @@ fn test_track_data_packet_seq_numbers() { // Join the multicast groups for each of the universes. for u in UNIVERSES.iter() { - let address = universe_to_ipv4_multicast_addr(*u).unwrap().as_socket_ipv4(); + let address = universe_to_ipv4_multicast_addr(*u).unwrap(); recv_socket - .join_multicast_v4(&address.unwrap().ip(), &Ipv4Addr::new(0, 0, 0, 0)) + .join_multicast_v4(&address.ip(), &Ipv4Addr::new(0, 0, 0, 0)) .unwrap(); } @@ -3751,10 +3751,10 @@ fn test_track_sync_packet_seq_numbers() { // Join the multicast groups for each of the synchronisation addresses. for u in SYNC_ADDRESSES.iter() { - let address = universe_to_ipv4_multicast_addr(*u).unwrap().as_socket_ipv4(); + let address = universe_to_ipv4_multicast_addr(*u).unwrap(); recv_socket - .join_multicast_v4(&address.unwrap().ip(), &Ipv4Addr::new(0, 0, 0, 0)) + .join_multicast_v4(&address.ip(), &Ipv4Addr::new(0, 0, 0, 0)) .unwrap(); } @@ -3828,9 +3828,9 @@ fn test_sync_packet_multicast_address() { // Join only the multicast address corresponding to the synchronisation address. let multicast_addr = universe_to_ipv4_multicast_addr(*sync_addr).unwrap(); - recv_sockets[i].bind(&multicast_addr).unwrap(); + recv_sockets[i].bind(&multicast_addr.into()).unwrap(); recv_sockets[i] - .join_multicast_v4(&multicast_addr.as_socket_ipv4().unwrap().ip(), &TEST_NETWORK_INTERFACE_IPV4[i].parse().unwrap()) + .join_multicast_v4(multicast_addr.ip(), &TEST_NETWORK_INTERFACE_IPV4[i].parse().unwrap()) .unwrap(); i = i + 1; @@ -3923,4 +3923,4 @@ fn test_send_empty() { assert!(false, "Empty data accepted to send incorrectly"); } } -} \ No newline at end of file +} diff --git a/tests/ipv6_tests.rs b/tests/ipv6_tests.rs index ec310da..0c749c2 100644 --- a/tests/ipv6_tests.rs +++ b/tests/ipv6_tests.rs @@ -1651,16 +1651,10 @@ mod sacn_ipv6_multicast_test { ) .unwrap(); ipv4_recv - .join_multicast_v4( - &ipv4_multicast_addr.as_socket_ipv4().unwrap().ip(), - &Ipv4Addr::UNSPECIFIED, - ) + .join_multicast_v4(ipv4_multicast_addr.ip(), &Ipv4Addr::UNSPECIFIED) .unwrap(); ipv4_recv - .join_multicast_v4( - &ipv4_discovery_multicast_addr.as_socket_ipv4().unwrap().ip(), - &Ipv4Addr::UNSPECIFIED, - ) + .join_multicast_v4(ipv4_discovery_multicast_addr.ip(), &Ipv4Addr::UNSPECIFIED) .unwrap(); // Create and setup the ipv6 source. @@ -1690,13 +1684,10 @@ mod sacn_ipv6_multicast_test { ) .unwrap(); ipv6_recv - .join_multicast_v6(&ipv6_multicast_addr.as_socket_ipv6().unwrap().ip(), 0) + .join_multicast_v6(ipv6_multicast_addr.ip(), 0) .unwrap(); ipv6_recv - .join_multicast_v6( - &ipv6_discovery_multicast_addr.as_socket_ipv6().unwrap().ip(), - 0, - ) + .join_multicast_v6(ipv6_discovery_multicast_addr.ip(), 0) .unwrap(); // Send and receive the data packet over IPv4.