From 2ad852ee08e21ee681950f1d6058499248baf88e Mon Sep 17 00:00:00 2001 From: baoshiwei <baoshiwei@shlanbao.cn> Date: 星期五, 18 七月 2025 15:04:22 +0800 Subject: [PATCH] 完成串口读取数据和处理 --- src/components/ForceChart.vue | 18 src-tauri/tauri.conf.json | 2 src/components/ThreeDDisplay.vue | 17 src-tauri/Cargo.lock | 1341 ++++++++++++++++++++++-------------- src-tauri/src/serial_port.rs | 151 ++++ src/components/GaugeDisplay.vue | 13 src/main.ts | 21 /dev/null | 46 - src/store/serialPort.ts | 20 package.json | 7 src/components/TableDisplay.vue | 14 src/utils/dataFetcher.ts | 170 ++- src-tauri/src/lib.rs | 75 + src/components/SerialPortConfig.vue | 157 ++++ src/App.vue | 116 ++- src-tauri/Cargo.toml | 6 16 files changed, 1,417 insertions(+), 757 deletions(-) diff --git a/package.json b/package.json index 18786bf..b3b2b0e 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,15 @@ "tauri": "tauri" }, "dependencies": { - "@tauri-apps/api": "^2", + "@tauri-apps/api": "^2.5.0", "@tauri-apps/plugin-opener": "^2", "echarts": "^5.6.0", + "pinia": "^3.0.3", "three": "^0.176.0", - "vue": "^3.5.13" + "vue": "^3.5.13", + "mathjs": "^12.4.1" }, + "devDependencies": { "@tauri-apps/cli": "^2", "@types/echarts": "^5.0.0", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 8790506..45e0ce2 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -13,9 +13,9 @@ [[package]] name = "adler2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aho-corasick" @@ -76,9 +76,9 @@ [[package]] name = "async-channel" -version = "2.3.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" dependencies = [ "concurrent-queue", "event-listener-strategy", @@ -102,9 +102,9 @@ [[package]] name = "async-io" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" +checksum = "1237c0ae75a0f3765f58910ff9cdd0a12eeb39ab2f4c7de23262f337f0aacbb3" dependencies = [ "async-lock", "cfg-if", @@ -113,7 +113,7 @@ "futures-lite", "parking", "polling", - "rustix 0.38.44", + "rustix", "slab", "tracing", "windows-sys 0.59.0", @@ -132,9 +132,9 @@ [[package]] name = "async-process" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb" +checksum = "cde3f4e40e6021d7acffc90095cbd6dc54cb593903d1de5832f435eb274b85dc" dependencies = [ "async-channel", "async-io", @@ -145,7 +145,7 @@ "cfg-if", "event-listener", "futures-lite", - "rustix 0.38.44", + "rustix", "tracing", ] @@ -157,14 +157,14 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] name = "async-signal" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" +checksum = "d7605a4e50d4b06df3898d5a70bf5fde51ed9059b0434b73105193bc27acce0d" dependencies = [ "async-io", "async-lock", @@ -172,7 +172,7 @@ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.44", + "rustix", "signal-hook-registry", "slab", "windows-sys 0.59.0", @@ -192,7 +192,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -226,9 +226,9 @@ [[package]] name = "autocfg" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "backtrace" @@ -301,9 +301,9 @@ [[package]] name = "blocking" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" +checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" dependencies = [ "async-channel", "async-task", @@ -314,9 +314,9 @@ [[package]] name = "brotli" -version = "7.0.0" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" +checksum = "9991eea70ea4f293524138648e41ee89b0b2b12ddef3b255effa43c8056e0e0d" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -325,9 +325,9 @@ [[package]] name = "brotli-decompressor" -version = "4.0.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a334ef7c9e23abf0ce748e8cd309037da93e606ad52eb372e4ce327a0dcfbdfd" +checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -335,15 +335,15 @@ [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bytemuck" -version = "1.23.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" [[package]] name = "byteorder" @@ -387,9 +387,9 @@ [[package]] name = "camino" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +checksum = "0da45bc31171d8d6960122e222a67740df867c1dd53b4d51caa297084c185cab" dependencies = [ "serde", ] @@ -424,14 +424,14 @@ checksum = "02260d489095346e5cafd04dea8e8cb54d1d74fcd759022a9b72986ebe9a1257" dependencies = [ "serde", - "toml", + "toml 0.8.23", ] [[package]] name = "cc" -version = "1.2.22" +version = "1.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32db95edf998450acc7881c932f94cd9b05c87b4b2599e8bab064753da4acfd1" +checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362" dependencies = [ "shlex", ] @@ -465,9 +465,9 @@ [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "cfg_aliases" @@ -483,8 +483,10 @@ dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-link", ] @@ -525,9 +527,19 @@ [[package]] name = "core-foundation" -version = "0.10.0" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" dependencies = [ "core-foundation-sys", "libc", @@ -546,9 +558,9 @@ checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ "bitflags 2.9.1", - "core-foundation", + "core-foundation 0.10.1", "core-graphics-types", - "foreign-types", + "foreign-types 0.5.0", "libc", ] @@ -559,7 +571,7 @@ checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ "bitflags 2.9.1", - "core-foundation", + "core-foundation 0.10.1", "libc", ] @@ -574,9 +586,9 @@ [[package]] name = "crc32fast" -version = "1.4.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" dependencies = [ "cfg-if", ] @@ -608,15 +620,15 @@ [[package]] name = "cssparser" -version = "0.27.2" +version = "0.29.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a" +checksum = "f93d03419cb5950ccfd3daf3ff1c7a36ace64609a1a8746d493df1ca0afde0fa" dependencies = [ "cssparser-macros", "dtoa-short", - "itoa 0.4.8", + "itoa", "matches", - "phf 0.8.0", + "phf 0.10.1", "proc-macro2", "quote", "smallvec", @@ -630,7 +642,7 @@ checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -640,7 +652,7 @@ checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" dependencies = [ "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -664,7 +676,7 @@ "proc-macro2", "quote", "strsim", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -675,8 +687,14 @@ dependencies = [ "darling_core", "quote", - "syn 2.0.101", + "syn 2.0.104", ] + +[[package]] +name = "data-encoding" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" [[package]] name = "deranged" @@ -698,7 +716,7 @@ "proc-macro2", "quote", "rustc_version", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -729,7 +747,7 @@ "libc", "option-ext", "redox_users", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -756,7 +774,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -773,13 +791,13 @@ [[package]] name = "dlopen2_derive" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" +checksum = "788160fb30de9cdd857af31c6a2675904b16ece8fc2737b2c7127ba368c9d0f4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -820,14 +838,14 @@ [[package]] name = "embed-resource" -version = "3.0.2" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fbc6e0d8e0c03a655b53ca813f0463d2c956bc4db8138dbc89f120b066551e3" +checksum = "4c6d81016d6c977deefb2ef8d8290da019e27cc26167e102185da528e6c0ab38" dependencies = [ "cc", "memchr", "rustc_version", - "toml", + "toml 0.9.2", "vswhom", "winreg", ] @@ -846,9 +864,9 @@ [[package]] name = "enumflags2" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" dependencies = [ "enumflags2_derive", "serde", @@ -856,13 +874,13 @@ [[package]] name = "enumflags2_derive" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -883,12 +901,12 @@ [[package]] name = "errno" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -939,9 +957,9 @@ [[package]] name = "flate2" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", "miniz_oxide", @@ -955,12 +973,21 @@ [[package]] name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared 0.1.1", +] + +[[package]] +name = "foreign-types" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared", + "foreign-types-shared 0.3.1", ] [[package]] @@ -971,8 +998,14 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "foreign-types-shared" @@ -1052,7 +1085,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -1221,7 +1254,7 @@ dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", ] [[package]] @@ -1308,7 +1341,7 @@ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -1387,7 +1420,7 @@ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -1398,9 +1431,9 @@ [[package]] name = "hashbrown" -version = "0.15.3" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" [[package]] name = "heck" @@ -1416,9 +1449,9 @@ [[package]] name = "hermit-abi" -version = "0.4.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hex" @@ -1428,16 +1461,14 @@ [[package]] name = "html5ever" -version = "0.26.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" +checksum = "3b7410cae13cbc75623c98ac4cbfd1f0bedddf3227afc24f370cf0f50a44a11c" dependencies = [ "log", "mac", "markup5ever", - "proc-macro2", - "quote", - "syn 1.0.109", + "match_token", ] [[package]] @@ -1448,7 +1479,7 @@ dependencies = [ "bytes", "fnv", - "itoa 1.0.15", + "itoa", ] [[package]] @@ -1492,7 +1523,7 @@ "http", "http-body", "httparse", - "itoa 1.0.15", + "itoa", "pin-project-lite", "smallvec", "tokio", @@ -1500,18 +1531,38 @@ ] [[package]] -name = "hyper-util" -version = "0.1.11" +name = "hyper-tls" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df" +dependencies = [ + "base64 0.22.1", + "bytes", "futures-channel", + "futures-core", "futures-util", "http", "http-body", "hyper", + "ipnet", "libc", + "percent-encoding", "pin-project-lite", "socket2", "tokio", @@ -1531,7 +1582,7 @@ "js-sys", "log", "wasm-bindgen", - "windows-core 0.61.1", + "windows-core", ] [[package]] @@ -1602,9 +1653,9 @@ [[package]] name = "icu_properties" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2549ca8c7241c82f59c80ba2a6f415d931c5b58d24fb8412caa1a1f02c49139a" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" dependencies = [ "displaydoc", "icu_collections", @@ -1618,9 +1669,9 @@ [[package]] name = "icu_properties_data" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8197e866e47b68f8f7d95249e172903bec06004b18b2937f1095d40a0c57de04" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" [[package]] name = "icu_provider" @@ -1679,12 +1730,12 @@ [[package]] name = "indexmap" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "equivalent", - "hashbrown 0.15.3", + "hashbrown 0.15.4", "serde", ] @@ -1698,10 +1749,41 @@ ] [[package]] +name = "io-kit-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" +dependencies = [ + "core-foundation-sys", + "mach2", +] + +[[package]] +name = "io-uring" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "libc", +] + +[[package]] name = "ipnet" version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] [[package]] name = "is-docker" @@ -1721,12 +1803,6 @@ "is-docker", "once_cell", ] - -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" @@ -1824,14 +1900,13 @@ [[package]] name = "kuchikiki" -version = "0.8.2" +version = "0.8.8-speedreader" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e4755b7b995046f510a7520c42b2fed58b77bd94d5a87a8eb43d2fd126da8" +checksum = "02cb977175687f33fa4afa0c95c112b987ea1443e5a51c8f8ff27dc618270cc2" dependencies = [ "cssparser", "html5ever", - "indexmap 1.9.3", - "matches", + "indexmap 2.10.0", "selectors", ] @@ -1867,9 +1942,9 @@ [[package]] name = "libc" -version = "0.2.172" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "libloading" @@ -1883,19 +1958,33 @@ [[package]] name = "libredox" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" dependencies = [ "bitflags 2.9.1", "libc", ] [[package]] -name = "linux-raw-sys" -version = "0.4.15" +name = "libudev" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "78b324152da65df7bb95acfcaab55e3097ceaab02fb19b228a9eb74d55f135e0" +dependencies = [ + "libc", + "libudev-sys", +] + +[[package]] +name = "libudev-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" +dependencies = [ + "libc", + "pkg-config", +] [[package]] name = "linux-raw-sys" @@ -1911,9 +2000,9 @@ [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -1932,17 +2021,37 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] -name = "markup5ever" -version = "0.11.0" +name = "mach2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + +[[package]] +name = "markup5ever" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7a7213d12e1864c0f002f52c2923d4556935a43dec5e71355c2760e0f6e7a18" dependencies = [ "log", - "phf 0.10.1", - "phf_codegen 0.10.0", + "phf 0.11.3", + "phf_codegen 0.11.3", "string_cache", "string_cache_codegen", "tendril", +] + +[[package]] +name = "match_token" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a9689d8d44bf9964484516275f5cd4c9b59457a6940c1d5d0ecbb94510a36b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", ] [[package]] @@ -1953,9 +2062,9 @@ [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "memoffset" @@ -1974,9 +2083,9 @@ [[package]] name = "miniz_oxide" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", "simd-adler32", @@ -1984,20 +2093,20 @@ [[package]] name = "mio" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", ] [[package]] name = "muda" -version = "0.16.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de14a9b5d569ca68d7c891d613b390cf5ab4f851c77aaa2f9e435555d3d9492" +checksum = "58b89bf91c19bf036347f1ab85a81c560f08c0667c8601bece664d860a600988" dependencies = [ "crossbeam-channel", "dpi", @@ -2012,6 +2121,23 @@ "serde", "thiserror 2.0.12", "windows-sys 0.59.0", +] + +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", ] [[package]] @@ -2052,6 +2178,17 @@ [[package]] name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + +[[package]] +name = "nix" version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" @@ -2086,23 +2223,24 @@ [[package]] name = "num_enum" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" +checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" dependencies = [ "num_enum_derive", + "rustversion", ] [[package]] name = "num_enum_derive" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" +checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" dependencies = [ "proc-macro-crate 3.3.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -2347,6 +2485,60 @@ ] [[package]] +name = "openssl" +version = "0.10.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "foreign-types 0.3.2", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-src" +version = "300.5.1+3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735230c832b28c000e3bc117119e6466a663ec73506bc0a9907ea4187508e42a" +dependencies = [ + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +dependencies = [ + "cc", + "libc", + "openssl-src", + "pkg-config", + "vcpkg", +] + +[[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2395,9 +2587,9 @@ [[package]] name = "parking_lot" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" dependencies = [ "lock_api", "parking_lot_core", @@ -2405,9 +2597,9 @@ [[package]] name = "parking_lot_core" -version = "0.9.10" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if", "libc", @@ -2434,9 +2626,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ - "phf_macros 0.8.0", "phf_shared 0.8.0", - "proc-macro-hack", ] [[package]] @@ -2445,7 +2635,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" dependencies = [ + "phf_macros 0.10.0", "phf_shared 0.10.0", + "proc-macro-hack", ] [[package]] @@ -2470,12 +2662,12 @@ [[package]] name = "phf_codegen" -version = "0.10.0" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", + "phf_generator 0.11.3", + "phf_shared 0.11.3", ] [[package]] @@ -2510,12 +2702,12 @@ [[package]] name = "phf_macros" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" dependencies = [ - "phf_generator 0.8.0", - "phf_shared 0.8.0", + "phf_generator 0.10.0", + "phf_shared 0.10.0", "proc-macro-hack", "proc-macro2", "quote", @@ -2532,7 +2724,7 @@ "phf_shared 0.11.3", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -2593,12 +2785,12 @@ [[package]] name = "plist" -version = "1.7.1" +version = "1.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac26e981c03a6e53e0aee43c113e3202f5581d5360dae7bd2c70e800dd0451d" +checksum = "3af6b589e163c5a788fab00ce0c0366f6efbb9959c2f9874b224936af7fce7e1" dependencies = [ "base64 0.22.1", - "indexmap 2.9.0", + "indexmap 2.10.0", "quick-xml", "serde", "time", @@ -2619,15 +2811,15 @@ [[package]] name = "polling" -version = "3.7.4" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" +checksum = "b53a684391ad002dd6a596ceb6c74fd004fdce75f4be2e3f615068abbea5fd50" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix 0.38.44", + "rustix", "tracing", "windows-sys 0.59.0", ] @@ -2687,7 +2879,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ - "toml_edit 0.22.26", + "toml_edit 0.22.27", ] [[package]] @@ -2731,9 +2923,9 @@ [[package]] name = "quick-xml" -version = "0.32.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" +checksum = "8927b0664f5c5a98265138b7e3f90aa19a6b21353182469ace36d4ac527b7b1b" dependencies = [ "memchr", ] @@ -2749,9 +2941,9 @@ [[package]] name = "r-efi" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" @@ -2842,9 +3034,9 @@ [[package]] name = "redox_syscall" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" +checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" dependencies = [ "bitflags 2.9.1", ] @@ -2858,6 +3050,26 @@ "getrandom 0.2.16", "libredox", "thiserror 2.0.12", +] + +[[package]] +name = "ref-cast" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", ] [[package]] @@ -2891,9 +3103,9 @@ [[package]] name = "reqwest" -version = "0.12.15" +version = "0.12.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" +checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531" dependencies = [ "base64 0.22.1", "bytes", @@ -2903,35 +3115,36 @@ "http-body", "http-body-util", "hyper", + "hyper-tls", "hyper-util", - "ipnet", "js-sys", "log", - "mime", - "once_cell", + "native-tls", "percent-encoding", "pin-project-lite", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", "tokio", + "tokio-native-tls", "tokio-util", "tower", + "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "wasm-streams", "web-sys", - "windows-registry", ] [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustc_version" @@ -2944,35 +3157,31 @@ [[package]] name = "rustix" -version = "0.38.44" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ "bitflags 2.9.1", "errno", "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", + "linux-raw-sys", + "windows-sys 0.60.2", ] [[package]] -name = "rustix" -version = "1.0.7" +name = "rustls-pki-types" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" dependencies = [ - "bitflags 2.9.1", - "errno", - "libc", - "linux-raw-sys 0.9.4", - "windows-sys 0.59.0", + "zeroize", ] [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" [[package]] name = "ryu" @@ -2987,6 +3196,15 @@ checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", ] [[package]] @@ -3005,6 +3223,30 @@ ] [[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] name = "schemars_derive" version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3013,7 +3255,7 @@ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3023,23 +3265,44 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "selectors" -version = "0.22.0" +name = "security-framework" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.9.1", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "selectors" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c37578180969d00692904465fb7f6b3d50b9a2b952b87c23d0e2e5cb5013416" dependencies = [ "bitflags 1.3.2", "cssparser", "derive_more", "fxhash", "log", - "matches", "phf 0.8.0", "phf_codegen 0.8.0", "precomputed-hash", "servo_arc", "smallvec", - "thin-slice", ] [[package]] @@ -3079,7 +3342,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3090,7 +3353,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3099,7 +3362,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ - "itoa 1.0.15", + "itoa", "memchr", "ryu", "serde", @@ -3113,14 +3376,23 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] name = "serde_spanned" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_spanned" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83" dependencies = [ "serde", ] @@ -3132,22 +3404,24 @@ checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.15", + "itoa", "ryu", "serde", ] [[package]] name = "serde_with" -version = "3.12.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" +checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.9.0", + "indexmap 2.10.0", + "schemars 0.9.0", + "schemars 1.0.4", "serde", "serde_derive", "serde_json", @@ -3157,14 +3431,14 @@ [[package]] name = "serde_with_macros" -version = "3.12.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" +checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3190,13 +3464,43 @@ ] [[package]] -name = "servo_arc" -version = "0.1.1" +name = "serialport" +version = "4.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" +checksum = "cdb0bc984f6af6ef8bab54e6cf2071579ee75b9286aa9f2319a0d220c28b0a2b" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "core-foundation 0.10.1", + "core-foundation-sys", + "io-kit-sys", + "libudev", + "mach2", + "nix 0.26.4", + "scopeguard", + "unescaper", + "winapi", +] + +[[package]] +name = "servo_arc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52aa42f8fdf0fed91e5ce7f23d8138441002fa31dca008acf47e6fd4721f741" dependencies = [ "nodrop", "stable_deref_trait", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", ] [[package]] @@ -3247,35 +3551,39 @@ name = "six-axis-force" version = "0.1.0" dependencies = [ + "anyhow", + "chrono", + "futures-util", + "once_cell", "rand 0.8.5", "serde", "serde_json", + "serialport", "tauri", "tauri-build", "tauri-plugin-opener", "tokio", + "tokio-tungstenite", + "tungstenite", ] [[package]] name = "slab" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" [[package]] name = "smallvec" -version = "1.15.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" dependencies = [ "libc", "windows-sys 0.52.0", @@ -3290,7 +3598,7 @@ "bytemuck", "cfg_aliases", "core-graphics", - "foreign-types", + "foreign-types 0.5.0", "js-sys", "log", "objc2 0.5.2", @@ -3396,9 +3704,9 @@ [[package]] name = "syn" -version = "2.0.101" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -3422,7 +3730,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3434,18 +3742,18 @@ "cfg-expr", "heck 0.5.0", "pkg-config", - "toml", + "toml 0.8.23", "version-compare", ] [[package]] name = "tao" -version = "0.33.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e59c1f38e657351a2e822eadf40d6a2ad4627b9c25557bc1180ec1b3295ef82" +checksum = "49c380ca75a231b87b6c9dd86948f035012e7171d1a7c40a9c2890489a7ffd8a" dependencies = [ "bitflags 2.9.1", - "core-foundation", + "core-foundation 0.10.1", "core-graphics", "crossbeam-channel", "dispatch", @@ -3471,8 +3779,8 @@ "tao-macros", "unicode-segmentation", "url", - "windows 0.61.1", - "windows-core 0.61.1", + "windows", + "windows-core", "windows-version", "x11-dl", ] @@ -3485,7 +3793,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3496,17 +3804,16 @@ [[package]] name = "tauri" -version = "2.5.1" +version = "2.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7b0bc1aec81bda6bc455ea98fcaed26b3c98c1648c627ad6ff1c704e8bf8cbc" +checksum = "124e129c9c0faa6bec792c5948c89e86c90094133b0b9044df0ce5f0a8efaa0d" dependencies = [ "anyhow", "bytes", "dirs", "dunce", "embed_plist", - "futures-util", - "getrandom 0.2.16", + "getrandom 0.3.3", "glob", "gtk", "heck 0.5.0", @@ -3542,14 +3849,14 @@ "webkit2gtk", "webview2-com", "window-vibrancy", - "windows 0.61.1", + "windows", ] [[package]] name = "tauri-build" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a0350f0df1db385ca5c02888a83e0e66655c245b7443db8b78a70da7d7f8fc" +checksum = "12f025c389d3adb83114bec704da973142e82fc6ec799c7c750c5e21cefaec83" dependencies = [ "anyhow", "cargo_toml", @@ -3557,21 +3864,21 @@ "glob", "heck 0.5.0", "json-patch", - "schemars", + "schemars 0.8.22", "semver", "serde", "serde_json", "tauri-utils", "tauri-winres", - "toml", + "toml 0.8.23", "walkdir", ] [[package]] name = "tauri-codegen" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93f035551bf7b11b3f51ad9bc231ebbe5e085565527991c16cf326aa38cdf47" +checksum = "f5df493a1075a241065bc865ed5ef8d0fbc1e76c7afdc0bf0eccfaa7d4f0e406" dependencies = [ "base64 0.22.1", "brotli", @@ -3585,7 +3892,7 @@ "serde", "serde_json", "sha2", - "syn 2.0.101", + "syn 2.0.104", "tauri-utils", "thiserror 2.0.12", "time", @@ -3596,62 +3903,62 @@ [[package]] name = "tauri-macros" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8db4df25e2d9d45de0c4c910da61cd5500190da14ae4830749fee3466dddd112" +checksum = "f237fbea5866fa5f2a60a21bea807a2d6e0379db070d89c3a10ac0f2d4649bbc" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "tauri-codegen", "tauri-utils", ] [[package]] name = "tauri-plugin" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37a5ebe6a610d1b78a94650896e6f7c9796323f408800cef436e0fa0539de601" +checksum = "1d9a0bd00bf1930ad1a604d08b0eb6b2a9c1822686d65d7f4731a7723b8901d3" dependencies = [ "anyhow", "glob", "plist", - "schemars", + "schemars 0.8.22", "serde", "serde_json", "tauri-utils", - "toml", + "toml 0.8.23", "walkdir", ] [[package]] name = "tauri-plugin-opener" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fdc6cb608e04b7d2b6d1f21e9444ad49245f6d03465ba53323d692d1ceb1a30" +checksum = "ecee219f11cdac713ab32959db5d0cceec4810ba4f4458da992292ecf9660321" dependencies = [ "dunce", "glob", "objc2-app-kit", "objc2-foundation 0.3.1", "open", - "schemars", + "schemars 0.8.22", "serde", "serde_json", "tauri", "tauri-plugin", "thiserror 2.0.12", "url", - "windows 0.60.0", + "windows", "zbus", ] [[package]] name = "tauri-runtime" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f004905d549854069e6774533d742b03cacfd6f03deb08940a8677586cbe39" +checksum = "9e7bb73d1bceac06c20b3f755b2c8a2cb13b20b50083084a8cf3700daf397ba4" dependencies = [ "cookie", "dpi", @@ -3666,14 +3973,14 @@ "tauri-utils", "thiserror 2.0.12", "url", - "windows 0.61.1", + "windows", ] [[package]] name = "tauri-runtime-wry" -version = "2.6.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f85d056f4d4b014fe874814034f3416d57114b617a493a4fe552580851a3f3a2" +checksum = "902b5aa9035e16f342eb64f8bf06ccdc2808e411a2525ed1d07672fa4e780bad" dependencies = [ "gtk", "http", @@ -3692,15 +3999,15 @@ "url", "webkit2gtk", "webview2-com", - "windows 0.61.1", + "windows", "wry", ] [[package]] name = "tauri-utils" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2900399c239a471bcff7f15c4399eb1a8c4fe511ba2853e07c996d771a5e0a4" +checksum = "41743bbbeb96c3a100d234e5a0b60a46d5aa068f266160862c7afdbf828ca02e" dependencies = [ "anyhow", "brotli", @@ -3719,7 +4026,7 @@ "proc-macro2", "quote", "regex", - "schemars", + "schemars 0.8.22", "semver", "serde", "serde-untagged", @@ -3727,7 +4034,7 @@ "serde_with", "swift-rs", "thiserror 2.0.12", - "toml", + "toml 0.8.23", "url", "urlpattern", "uuid", @@ -3741,8 +4048,8 @@ checksum = "e8d321dbc6f998d825ab3f0d62673e810c861aac2d0de2cc2c395328f1d113b4" dependencies = [ "embed-resource", - "indexmap 2.9.0", - "toml", + "indexmap 2.10.0", + "toml 0.8.23", ] [[package]] @@ -3754,7 +4061,7 @@ "fastrand", "getrandom 0.3.3", "once_cell", - "rustix 1.0.7", + "rustix", "windows-sys 0.59.0", ] @@ -3768,12 +4075,6 @@ "mac", "utf-8", ] - -[[package]] -name = "thin-slice" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] name = "thiserror" @@ -3801,7 +4102,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3812,7 +4113,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3822,7 +4123,7 @@ checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", - "itoa 1.0.15", + "itoa", "num-conv", "powerfmt", "serde", @@ -3858,17 +4159,53 @@ [[package]] name = "tokio" -version = "1.45.0" +version = "1.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" +checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" dependencies = [ "backtrace", "bytes", + "io-uring", "libc", "mio", "pin-project-lite", + "slab", "socket2", + "tokio-macros", "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", ] [[package]] @@ -3886,21 +4223,45 @@ [[package]] name = "toml" -version = "0.8.22" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.22.26", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", + "toml_edit 0.22.27", +] + +[[package]] +name = "toml" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed0aee96c12fa71097902e0bb061a5e1ebd766a6636bb605ba401c45c1650eac" +dependencies = [ + "indexmap 2.10.0", + "serde", + "serde_spanned 1.0.0", + "toml_datetime 0.7.0", + "toml_parser", + "toml_writer", + "winnow 0.7.12", ] [[package]] name = "toml_datetime" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3" dependencies = [ "serde", ] @@ -3911,8 +4272,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.9.0", - "toml_datetime", + "indexmap 2.10.0", + "toml_datetime 0.6.11", "winnow 0.5.40", ] @@ -3922,30 +4283,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap 2.9.0", - "toml_datetime", + "indexmap 2.10.0", + "toml_datetime 0.6.11", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.26" +version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.9.0", + "indexmap 2.10.0", "serde", - "serde_spanned", - "toml_datetime", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", "toml_write", - "winnow 0.7.10", + "winnow 0.7.12", +] + +[[package]] +name = "toml_parser" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97200572db069e74c512a14117b296ba0a80a30123fbbb5aa1f4a348f639ca30" +dependencies = [ + "winnow 0.7.12", ] [[package]] name = "toml_write" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "toml_writer" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" [[package]] name = "tower" @@ -3958,6 +4334,24 @@ "pin-project-lite", "sync_wrapper", "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +dependencies = [ + "bitflags 2.9.1", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", "tower-layer", "tower-service", ] @@ -3987,29 +4381,29 @@ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", ] [[package]] name = "tray-icon" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7eee98ec5c90daf179d55c20a49d8c0d043054ce7c26336c09a24d31f14fa0" +checksum = "2da75ec677957aa21f6e0b361df0daab972f13a5bee3606de0638fd4ee1c666a" dependencies = [ "crossbeam-channel", "dirs", @@ -4034,6 +4428,25 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.8.5", + "sha1", + "thiserror 1.0.69", + "url", + "utf-8", +] + +[[package]] name = "typeid" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4054,6 +4467,15 @@ "memoffset", "tempfile", "winapi", +] + +[[package]] +name = "unescaper" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c01d12e3a56a4432a8b436f293c25f4808bdf9e9f9f98f9260bba1f1bc5a1f26" +dependencies = [ + "thiserror 2.0.12", ] [[package]] @@ -4147,13 +4569,21 @@ [[package]] name = "uuid" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" +checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" dependencies = [ "getrandom 0.3.3", + "js-sys", "serde", + "wasm-bindgen", ] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version-compare" @@ -4214,9 +4644,9 @@ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" @@ -4249,7 +4679,7 @@ "log", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "wasm-bindgen-shared", ] @@ -4284,7 +4714,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4367,15 +4797,15 @@ [[package]] name = "webview2-com" -version = "0.37.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b542b5cfbd9618c46c2784e4d41ba218c336ac70d44c55e47b251033e7d85601" +checksum = "d4ba622a989277ef3886dd5afb3e280e3dd6d974b766118950a08f8f678ad6a4" dependencies = [ "webview2-com-macros", "webview2-com-sys", - "windows 0.61.1", - "windows-core 0.61.1", - "windows-implement 0.60.0", + "windows", + "windows-core", + "windows-implement", "windows-interface", ] @@ -4387,18 +4817,18 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] name = "webview2-com-sys" -version = "0.37.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae2d11c4a686e4409659d7891791254cf9286d3cfe0eef54df1523533d22295" +checksum = "36695906a1b53a3bf5c4289621efedac12b73eeb0b89e7e1a89b517302d5d75c" dependencies = [ "thiserror 2.0.12", - "windows 0.61.1", - "windows-core 0.61.1", + "windows", + "windows-core", ] [[package]] @@ -4449,37 +4879,15 @@ [[package]] name = "windows" -version = "0.60.0" +version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf874e74c7a99773e62b1c671427abf01a425e77c3d3fb9fb1e4883ea934529" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ - "windows-collections 0.1.1", - "windows-core 0.60.1", - "windows-future 0.1.1", + "windows-collections", + "windows-core", + "windows-future", "windows-link", - "windows-numerics 0.1.1", -] - -[[package]] -name = "windows" -version = "0.61.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5ee8f3d025738cb02bad7868bbb5f8a6327501e870bf51f1b455b0a2454a419" -dependencies = [ - "windows-collections 0.2.0", - "windows-core 0.61.1", - "windows-future 0.2.1", - "windows-link", - "windows-numerics 0.2.0", -] - -[[package]] -name = "windows-collections" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5467f79cc1ba3f52ebb2ed41dbb459b8e7db636cc3429458d9a852e15bc24dec" -dependencies = [ - "windows-core 0.60.1", + "windows-numerics", ] [[package]] @@ -4488,43 +4896,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "windows-core 0.61.1", + "windows-core", ] [[package]] name = "windows-core" -version = "0.60.1" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca21a92a9cae9bf4ccae5cf8368dce0837100ddf6e6d57936749e85f152f6247" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-implement 0.59.0", + "windows-implement", "windows-interface", "windows-link", "windows-result", - "windows-strings 0.3.1", -] - -[[package]] -name = "windows-core" -version = "0.61.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46ec44dc15085cea82cf9c78f85a9114c463a369786585ad2882d1ff0b0acf40" -dependencies = [ - "windows-implement 0.60.0", - "windows-interface", - "windows-link", - "windows-result", - "windows-strings 0.4.1", -] - -[[package]] -name = "windows-future" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a787db4595e7eb80239b74ce8babfb1363d8e343ab072f2ffe901400c03349f0" -dependencies = [ - "windows-core 0.60.1", - "windows-link", + "windows-strings", ] [[package]] @@ -4533,20 +4918,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "windows-core 0.61.1", + "windows-core", "windows-link", "windows-threading", -] - -[[package]] -name = "windows-implement" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", ] [[package]] @@ -4557,7 +4931,7 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -4568,24 +4942,14 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] name = "windows-link" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" - -[[package]] -name = "windows-numerics" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005dea54e2f6499f2cee279b8f703b3cf3b5734a2d8d21867c8f44003182eeed" -dependencies = [ - "windows-core 0.60.1", - "windows-link", -] +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" [[package]] name = "windows-numerics" @@ -4593,44 +4957,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "windows-core 0.61.1", + "windows-core", "windows-link", -] - -[[package]] -name = "windows-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" -dependencies = [ - "windows-result", - "windows-strings 0.3.1", - "windows-targets 0.53.0", ] [[package]] name = "windows-result" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b895b5356fc36103d0f64dd1e94dfa7ac5633f1c9dd6e80fe9ec4adef69e09d" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" -version = "0.3.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-strings" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a7ab927b2637c19b3dbe0965e75d8f2d30bdd697a1516191cad2ec4df8fb28a" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ "windows-link", ] @@ -4642,15 +4986,6 @@ checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", ] [[package]] @@ -4672,6 +5007,15 @@ ] [[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.2", +] + +[[package]] name = "windows-targets" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4684,21 +5028,6 @@ "windows_x86_64_gnu 0.42.2", "windows_x86_64_gnullvm 0.42.2", "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -4719,9 +5048,9 @@ [[package]] name = "windows-targets" -version = "0.53.0" +version = "0.53.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" dependencies = [ "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", @@ -4759,12 +5088,6 @@ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" @@ -4783,12 +5106,6 @@ [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" @@ -4804,12 +5121,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" @@ -4843,12 +5154,6 @@ [[package]] name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" @@ -4864,12 +5169,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" @@ -4891,12 +5190,6 @@ [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" @@ -4912,12 +5205,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" @@ -4942,21 +5229,21 @@ [[package]] name = "winnow" -version = "0.7.10" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec" +checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.52.0" +version = "0.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +checksum = "cb5a765337c50e9ec252c2069be9bf91c7df47afb103b642ba3a53bf8101be97" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -4976,9 +5263,9 @@ [[package]] name = "wry" -version = "0.51.2" +version = "0.52.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c886a0a9d2a94fd90cfa1d929629b79cfefb1546e2c7430c63a47f0664c0e4e2" +checksum = "12a714d9ba7075aae04a6e50229d6109e3d584774b99a6a8c60de1698ca111b9" dependencies = [ "base64 0.22.1", "block2 0.6.1", @@ -5012,8 +5299,8 @@ "webkit2gtk", "webkit2gtk-sys", "webview2-com", - "windows 0.61.1", - "windows-core 0.61.1", + "windows", + "windows-core", "windows-version", "x11-dl", ] @@ -5059,15 +5346,15 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "synstructure", ] [[package]] name = "zbus" -version = "5.7.0" +version = "5.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88232b74ba057a0c85472ec1bae8a17569960be17da2d5e5ad30d5efe7ea6719" +checksum = "4bb4f9a464286d42851d18a605f7193b8febaf5b0919d71c6399b7b26e5b0aad" dependencies = [ "async-broadcast", "async-executor", @@ -5083,14 +5370,14 @@ "futures-core", "futures-lite", "hex", - "nix", + "nix 0.30.1", "ordered-stream", "serde", "serde_repr", "tracing", "uds_windows", "windows-sys 0.59.0", - "winnow 0.7.10", + "winnow 0.7.12", "zbus_macros", "zbus_names", "zvariant", @@ -5098,14 +5385,14 @@ [[package]] name = "zbus_macros" -version = "5.7.0" +version = "5.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6969c06899233334676e60da1675740539cf034ee472a6c5b5c54e50a0a554c9" +checksum = "ef9859f68ee0c4ee2e8cde84737c78e3f4c54f946f2a38645d0d4c7a95327659" dependencies = [ "proc-macro-crate 3.3.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "zbus_names", "zvariant", "zvariant_utils", @@ -5119,28 +5406,28 @@ dependencies = [ "serde", "static_assertions", - "winnow 0.7.10", + "winnow 0.7.12", "zvariant", ] [[package]] name = "zerocopy" -version = "0.8.25" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.25" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -5160,9 +5447,15 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "synstructure", ] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" [[package]] name = "zerotrie" @@ -5194,33 +5487,33 @@ dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] name = "zvariant" -version = "5.5.3" +version = "5.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d30786f75e393ee63a21de4f9074d4c038d52c5b1bb4471f955db249f9dffb1" +checksum = "d91b3680bb339216abd84714172b5138a4edac677e641ef17e1d8cb1b3ca6e6f" dependencies = [ "endi", "enumflags2", "serde", - "winnow 0.7.10", + "winnow 0.7.12", "zvariant_derive", "zvariant_utils", ] [[package]] name = "zvariant_derive" -version = "5.5.3" +version = "5.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75fda702cd42d735ccd48117b1630432219c0e9616bf6cb0f8350844ee4d9580" +checksum = "3a8c68501be459a8dbfffbe5d792acdd23b4959940fc87785fb013b32edbc208" dependencies = [ "proc-macro-crate 3.3.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "zvariant_utils", ] @@ -5234,6 +5527,6 @@ "quote", "serde", "static_assertions", - "syn 2.0.101", - "winnow 0.7.10", + "syn 2.0.104", + "winnow 0.7.12", ] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 7cea56c..85f3dc1 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -18,11 +18,12 @@ tauri-build = { version = "2", features = [] } [dependencies] -tauri = { version = "2", features = [] } +tauri = { version = "2", features = [ "tray-icon", "devtools", "native-tls-vendored" ] } +chrono = "0.4" tauri-plugin-opener = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" -tokio = { version = "1.45.0", features = ["rt", "net", "time"] } +tokio = { version = "1.45.0", features = ["rt", "net", "time", "macros"] } rand = "0.8.5" once_cell = "1.19" @@ -30,4 +31,5 @@ futures-util = "0.3" tungstenite = "0.21" anyhow = "1.0" +serialport = "4.3.0" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 8e0934c..7d430c2 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,50 +1,57 @@ mod tokio_utils; -mod pipe_server; -mod ws_client; -use crate::ws_client::LATEST_WS_DATA; +mod serial_port; use std::sync::Mutex; use tauri::async_runtime::spawn; -use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use tauri::Manager; use tokio_utils::{set_complete,setup,SetupState}; +use std::fs::OpenOptions; +use std::io::Write; +use chrono::Local; + // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ -use crate::pipe_server::start_pipe_server; -#[tauri::command] -fn get_latest_ws_data() -> Option<String> { - LATEST_WS_DATA.lock().unwrap().clone() -} + + #[tauri::command] fn greet(name: &str) -> String { format!("Hello, {}! You've been greeted from Rust!", name) } #[tauri::command] -async fn start_pipe_server_command(pipe_name: String) -> Result<(), String> { - start_pipe_server(&pipe_name) - .await - .map_err(|e| e.to_string()) +fn log_data(app_handle: tauri::AppHandle, data: String) -> Result<(), String> { + let app_data_path = app_handle.path().app_data_dir() + .or_else(|_| Err("Could not get app data directory".to_string()))?; + + let log_dir = app_data_path.join("logs"); + if !log_dir.exists() { + std::fs::create_dir_all(&log_dir) + .map_err(|e| format!("Failed to create log directory: {}", e))?; + } + + let current_date = Local::now().format("%Y-%m-%d").to_string(); + let log_file_path = log_dir.join(format!("log_{}.txt", current_date)); + + println!("log_file_path: {:?}", log_file_path); + let mut file = OpenOptions::new() + .create(true) + .append(true) + .open(&log_file_path) + .map_err(|e| format!("Failed to open log file: {}", e))?; + + let timestamp = Local::now().format("[%Y-%m-%d %H:%M:%S]").to_string(); + writeln!(file, "{} {}", timestamp, data) + .map_err(|e| format!("Failed to write to log file: {}", e))?; + + Ok(()) } -#[tauri::command] -async fn send_pipe_message(pipe_name: String, message: String) -> Result<String, String> { - let pipe_path: String = format!(r"\\.\pipe\{}", pipe_name); - - let mut client = tokio::net::windows::named_pipe::ClientOptions::new() - .open(&pipe_path) - .map_err(|e| e.to_string())?; - client.write_all(message.as_bytes()).await.map_err(|e| e.to_string())?; - - let mut buf = [0u8; 1024]; - let n = client.read(&mut buf).await.map_err(|e| e.to_string())?; - - String::from_utf8(buf[..n].to_vec()) - .map_err(|e| e.to_string()) -} + + @@ -70,12 +77,18 @@ backend_task: false, })) // Add a command we can use to check - .invoke_handler(tauri::generate_handler![greet, set_complete, start_pipe_server_command, send_pipe_message, get_latest_ws_data]) + .invoke_handler(tauri::generate_handler![ + greet, + set_complete, + serial_port::open_serial_port, + serial_port::close_serial_port, + serial_port::write_serial_data, + serial_port::list_serial_ports, + log_data + ]) // Use the setup hook to execute setup related tasks // Runs before the main loop, so no windows are yet created .setup(|app| { - // 鍚姩 WebSocket 瀹㈡埛绔紙寮傛浠诲姟锛� - ws_client::start_ws_client(); // Spawn setup as a non-blocking task so the windows can be // created and ran while it executes spawn(setup(app.handle().clone())); diff --git a/src-tauri/src/pipe_server.rs b/src-tauri/src/pipe_server.rs deleted file mode 100644 index 90445a7..0000000 --- a/src-tauri/src/pipe_server.rs +++ /dev/null @@ -1,97 +0,0 @@ -use tokio::net::windows::named_pipe::{ServerOptions}; -use tokio::io::{AsyncReadExt, AsyncWriteExt}; -use rand::Rng; - -// 鐢熸垚妯℃嫙鐨勫叚杞村姏鏁版嵁 -fn generate_force_data() -> String { - let mut rng = rand::thread_rng(); - let force_data = [ - rng.gen_range(-100.0..100.0), // Fx - rng.gen_range(-100.0..100.0), // Fy - rng.gen_range(-100.0..100.0), // Fz - rng.gen_range(-10.0..10.0), // Mx - rng.gen_range(-10.0..10.0), // My - rng.gen_range(-10.0..10.0), // Mz - ]; - - serde_json::to_string(&force_data).unwrap_or_else(|_| "[0,0,0,0,0,0]".to_string()) -} - -// 澶勭悊瀹㈡埛绔姹� -fn process_request(request: &str) -> String { - match request { - "GET_FORCE_DATA" => generate_force_data(), - _ => request.to_string(), // 瀵逛簬鍏朵粬璇锋眰锛岀畝鍗曞湴鍥炴樉 - } -} - -pub async fn start_pipe_server(pipe_name: &str) -> Result<(), Box<dyn std::error::Error>> { - let full_pipe_name = format!(r"\\.\pipe\{}", pipe_name); - let pipe_name_clone = pipe_name.to_string(); - - // 鍦ㄥ崟鐙殑绾跨▼涓繍琛岀閬撴湇鍔″櫒锛岃繖鏍峰嚱鏁板彲浠ョ珛鍗宠繑鍥� - tokio::spawn(async move { - loop { - // 姣忔寰幆鍒涘缓鏂扮殑绠¢亾瀹炰緥锛岀‘淇濅箣鍓嶇殑杩炴帴宸插畬鍏ㄥ叧闂� - let server = match ServerOptions::new() - .first_pipe_instance(false) // 鍏佽澶氫釜瀹炰緥锛岄伩鍏嶉敊璇�231 - .create(&full_pipe_name) { - Ok(s) => s, - Err(e) => { - eprintln!("Error creating pipe server: {}", e); - // 濡傛灉鍒涘缓澶辫触锛岀瓑寰呬竴娈垫椂闂村悗閲嶈瘯 - tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; - continue; - } - }; - - println!("Pipe server listening on {}", full_pipe_name); - - // 绛夊緟瀹㈡埛绔繛鎺� - if let Err(e) = server.connect().await { - eprintln!("Error connecting to pipe: {}", e); - // 杩炴帴澶辫触鍚庣瓑寰呬竴娈垫椂闂村啀閲嶈瘯 - tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; - continue; - } - - // 澶勭悊瀹㈡埛绔姹� - let mut buf = [0u8; 1024]; - let mut server = server; // 绉诲姩鎵�鏈夋潈鍒板綋鍓嶄綔鐢ㄥ煙 - - loop { - // 璇诲彇瀹㈡埛绔姹� - let n = match server.read(&mut buf).await { - Ok(n) => n, - Err(e) => { - eprintln!("Error reading from pipe: {}", e); - break; // 璇诲彇閿欒锛岄��鍑哄唴灞傚惊鐜紝鍒涘缓鏂扮殑绠¢亾瀹炰緥 - } - }; - - if n == 0 { break; } // 瀹㈡埛绔柇寮�杩炴帴 - - let msg = String::from_utf8_lossy(&buf[..n]); - println!("Received: {}", msg); - - // 澶勭悊璇锋眰骞惰繑鍥炲搷搴� - let response = process_request(&msg); - - if let Err(e) = server.write_all(response.as_bytes()).await { - eprintln!("Error writing to pipe: {}", e); - break; // 鍐欏叆閿欒锛岄��鍑哄唴灞傚惊鐜紝鍒涘缓鏂扮殑绠¢亾瀹炰緥 - } - } - - // 瀹㈡埛绔柇寮�杩炴帴鍚庯紝鏄惧紡鍏抽棴褰撳墠绠¢亾瀹炰緥 - // 杩欓噷server浼氬湪浣滅敤鍩熺粨鏉熸椂鑷姩鍏抽棴锛屼絾鎴戜滑鍙互娣诲姞鏃ュ織 - println!("Client disconnected, creating new pipe instance"); - // 鐭殏寤惰繜锛岀‘淇濊祫婧愬畬鍏ㄩ噴鏀� - tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; - } - }); - - // 绔嬪嵆杩斿洖锛屼笉闃诲璋冪敤鑰� - println!("Pipe server started for {}", pipe_name_clone); - Ok(()) -} diff --git a/src-tauri/src/serial_port.rs b/src-tauri/src/serial_port.rs new file mode 100644 index 0000000..66e4ded --- /dev/null +++ b/src-tauri/src/serial_port.rs @@ -0,0 +1,151 @@ +use std::io::{Write, ErrorKind}; +use tauri::Emitter; +use std::time::Duration; +use serialport::{self, SerialPort}; + +use once_cell::sync::Lazy; +use tokio::sync::{Mutex, broadcast}; + + +// 鐢ㄤ簬鍙戦�佸仠姝俊鍙风殑閫氶亾 +static STOP_SIGNAL_SENDER: Lazy<Mutex<Option<broadcast::Sender<()>>>> = Lazy::new(|| Mutex::new(None)); + +// 浣跨敤Lazy鍜孧utex鏉ュ畨鍏ㄥ湴鍏变韩涓插彛瀹炰緥 +static SERIAL_PORT: Lazy<Mutex<Option<Box<dyn SerialPort>>>> = Lazy::new(|| Mutex::new(None)); + +#[tauri::command] +pub async fn open_serial_port(app_handle: tauri::AppHandle, port_name: String, baud_rate: u32) -> Result<String, String> { + // 杈撳嚭 涓插彛鍚嶇О + println!("鎵撳紑涓插彛: {}", port_name); + // 杈撳嚭 娉㈢壒鐜� + println!("娉㈢壒鐜�: {}", baud_rate); + let mut serial_port_guard = SERIAL_PORT.lock().await; + if serial_port_guard.is_some() { + return Err("涓插彛宸叉墦寮�".into()); + } + + match serialport::new(&port_name, baud_rate) + .timeout(Duration::from_millis(10)) + .open() + { + Ok(port) => { + *serial_port_guard = Some(port); + + // 鍒涘缓鍋滄淇″彿閫氶亾 + let (tx, _rx) = broadcast::channel(1); + *STOP_SIGNAL_SENDER.lock().await = Some(tx.clone()); + + let app_handle_clone = app_handle.clone(); + let mut rx_stop = tx.subscribe(); + + tokio::spawn(async move { + let mut buffer: Vec<u8> = vec![0; 1024]; + let mut data_buffer: Vec<u8> = Vec::new(); // Buffer to accumulate incoming data + loop { + tokio::select! { + _ = rx_stop.recv() => { + println!("鍋滄涓插彛鏁版嵁璇诲彇浠诲姟"); + break; + } + _ = tokio::time::sleep(Duration::from_millis(100)) => { + // 瀹氭湡灏濊瘯璇诲彇锛岄伩鍏嶉暱鏃堕棿闃诲 + let mut serial_port_guard = SERIAL_PORT.lock().await; + if let Some(port) = serial_port_guard.as_mut() { + match port.read(buffer.as_mut_slice()) { + Ok(bytes_read) => { + if bytes_read > 0 { + data_buffer.extend_from_slice(&buffer[..bytes_read]); + + // Process data_buffer to extract complete 22-byte packets + while data_buffer.len() >= 22 { + let data = data_buffer.drain(..22).collect::<Vec<u8>>(); + if let Err(e) = app_handle_clone.emit("serial_data", data) { + eprintln!("鍙戝皠浜嬩欢澶辫触: {}", e); + } + } + } + } + Err(ref e) if e.kind() == ErrorKind::TimedOut => { /* 瓒呮椂锛岀户缁� */ } + Err(e) => { + eprintln!("璇诲彇涓插彛鏁版嵁澶辫触: {}", e); + break; // 璇诲彇澶辫触锛岄��鍑哄惊鐜� + } + } + } else { + eprintln!("涓插彛鏈墦寮�锛屽仠姝㈣鍙栦换鍔�"); + break; + } + } + } + } + }); + let log_message = format!("鎴愬姛鎵撳紑涓插彛: {}", port_name); + crate::log_data(app_handle, log_message.clone()).map_err(|e| e.to_string())?; + Ok(log_message) + } + Err(e) => Err(format!("鎵撳紑涓插彛澶辫触: {}", e)), + } +} + +#[tauri::command] +pub async fn close_serial_port() -> Result<String, String> { + let mut serial_port_guard = SERIAL_PORT.lock().await; + if serial_port_guard.is_none() { + return Err("涓插彛鏈墦寮�".into()); + } + + // 鍙戦�佸仠姝俊鍙� + if let Some(tx) = STOP_SIGNAL_SENDER.lock().await.take() { + if let Err(e) = tx.send(()) { + eprintln!("鍙戦�佸仠姝俊鍙峰け璐�: {}", e); + } + } + + *serial_port_guard = None; + Ok("涓插彛宸插叧闂�".into()) +} + +// 绉婚櫎 read_serial_data 鍛戒护锛屽洜涓鸿鍙栭�昏緫宸查泦鎴愬埌 open_serial_port 涓� +// #[tauri::command] +// pub async fn read_serial_data(app_handle: tauri::AppHandle) -> Result<Vec<u8>, String> { +// let mut serial_port_guard = SERIAL_PORT.lock().await; +// if let Some(port) = serial_port_guard.as_mut() { +// let mut buffer: Vec<u8> = vec![0; 128]; // 鍋囪姣忔鏈�澶氳鍙�128瀛楄妭 +// match port.read(buffer.as_mut_slice()) { +// Ok(bytes_read) => { +// let data = buffer[..bytes_read].to_vec(); +// // 鍙互鍦ㄨ繖閲屽彂灏勪簨浠跺埌鍓嶇锛屽鏋滈渶瑕佸疄鏃舵樉绀� +// // app_handle.emit_all("serial_data", &data).unwrap(); +// Ok(data) +// } +// Err(ref e) if e.kind() == ErrorKind::TimedOut => Ok(vec![]), // 瓒呮椂涓嶆槸閿欒 +// Err(e) => Err(format!("璇诲彇涓插彛鏁版嵁澶辫触: {}", e)), +// } +// } else { +// Err("涓插彛鏈墦寮�".into()) +// } +// } + +#[tauri::command] +pub async fn write_serial_data(data: Vec<u8>) -> Result<usize, String> { + let mut serial_port_guard = SERIAL_PORT.lock().await; + if let Some(port) = serial_port_guard.as_mut() { + match port.write_all(&data) { + Ok(_) => Ok(data.len()), + Err(e) => Err(format!("鍐欏叆涓插彛鏁版嵁澶辫触: {}", e)), + } + } else { + Err("涓插彛鏈墦寮�".into()) + } +} + +#[tauri::command] +pub fn list_serial_ports() -> Result<Vec<String>, String> { + match serialport::available_ports() { + Ok(ports) => { + let port_names = ports.into_iter().map(|p| p.port_name).collect(); + Ok(port_names) + } + Err(e) => Err(format!("鍒楀嚭涓插彛澶辫触: {}", e)), + } +} \ No newline at end of file diff --git a/src-tauri/src/ws_client.rs b/src-tauri/src/ws_client.rs deleted file mode 100644 index 0184b8c..0000000 --- a/src-tauri/src/ws_client.rs +++ /dev/null @@ -1,45 +0,0 @@ -use std::sync::{Arc, Mutex}; -use once_cell::sync::Lazy; -use tokio::runtime::Runtime; -use tokio_tungstenite::connect_async; -use futures_util::{StreamExt}; - -// 鍏ㄥ眬缂撳瓨鏈�鏂板叚缁村姏鏁版嵁 -pub static LATEST_WS_DATA: Lazy<Arc<Mutex<Option<String>>>> = Lazy::new(|| Arc::new(Mutex::new(None))); - -// WebSocket 鏈嶅姟绔湴鍧�锛堝彲鏍规嵁瀹為檯鎯呭喌淇敼锛� -const WS_SERVER_URL: &str = "ws://192.168.21.25:5000"; - -pub fn start_ws_client() { - // 鍚姩 tokio runtime - std::thread::spawn(|| { - let rt = Runtime::new().unwrap(); - rt.block_on(async move { - if let Err(e) = ws_client_task().await { - eprintln!("WebSocket 瀹㈡埛绔惎鍔ㄥけ璐�: {}", e); - } - }); - }); -} - -async fn ws_client_task() -> anyhow::Result<()> { - println!("灏濊瘯杩炴帴 WebSocket 鏈嶅姟绔�: {}", WS_SERVER_URL); - let (ws_stream, _) = connect_async(WS_SERVER_URL).await?; - println!("WebSocket 宸茶繛鎺�"); - let (_, mut read) = ws_stream.split(); - while let Some(msg) = read.next().await { - match msg { - Ok(tungstenite::Message::Text(text)) => { - // 鍋囪鏈嶅姟绔帹閫佺殑灏辨槸鍏淮鍔涙暟鎹殑 JSON 瀛楃涓� - let mut data = LATEST_WS_DATA.lock().unwrap(); - *data = Some(text.clone()); - }, - Ok(_) => {}, - Err(e) => { - eprintln!("WebSocket 璇诲彇閿欒: {}", e); - break; - } - } - } - Ok(()) -} \ No newline at end of file diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 9792d78..6ced086 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -2,7 +2,7 @@ "$schema": "https://schema.tauri.app/config/2", "productName": "six-axis-force", "version": "0.1.0", - "identifier": "com.lanbao.saf", + "identifier": "six-axis-force", "build": { "beforeDevCommand": "pnpm dev", "devUrl": "http://localhost:1420", diff --git a/src/App.vue b/src/App.vue index f6a644e..de2dee5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,30 +1,29 @@ <script setup lang="ts"> import { ref } from "vue"; -import { invoke } from "@tauri-apps/api/core"; import ForceChart from "./components/ForceChart.vue"; import GaugeDisplay from "./components/GaugeDisplay.vue"; import TableDisplay from "./components/TableDisplay.vue"; import ThreeDDisplay from "./components/ThreeDDisplay.vue"; import TitleBar from "./components/TitleBar.vue"; +import SerialPortConfig from "./components/SerialPortConfig.vue"; -// const message = ref(''); const logs = ref<string[]>([]); -const showChart = ref(false); -const pipeName = 'tauri-pipe-server'; -const currentDisplay = ref('line'); // 榛樿鏄剧ず鏇茬嚎鍥� -const dataSource = ref<'pipe' | 'ws'>('ws'); // 榛樿鏁版嵁婧愪负绠¢亾 +// const isSerialPortConnected = ref(false); // 鏂板锛氳窡韪覆鍙h繛鎺ョ姸鎬� -async function startPipeServer() { - try { - const res = await invoke('start_pipe_server_command', {pipeName}); - console.log(res); - logs.value.push('[绯荤粺] 鏁版嵁鎺ユ敹鏈嶅姟宸插惎鍔�'); - console.log('[绯荤粺] 绠¢亾鏈嶅姟绔凡鍚姩'); - showChart.value = true; - } catch (err) { - logs.value.push(`[閿欒] 鍚姩澶辫触: ${err}`); - } -} +const currentDisplay = ref('setting'); // 榛樿鏄剧ず鏇茬嚎鍥� + + +// async function startPipeServer() { +// try { +// const res = await invoke('start_pipe_server_command', {pipeName}); +// console.log(res); +// logs.value.push('[绯荤粺] 鏁版嵁鎺ユ敹鏈嶅姟宸插惎鍔�'); +// console.log('[绯荤粺] 绠¢亾鏈嶅姟绔凡鍚姩'); +// showChart.value = true; +// } catch (err) { +// logs.value.push(`[閿欒] 鍚姩澶辫触: ${err}`); +// } +// } // async function sendToPipe() { // if (!message.value) return; @@ -38,21 +37,27 @@ // logs.value.push(`[閿欒] 閫氫俊澶辫触: ${err}`); // } // } -startPipeServer(); +// startPipeServer(); + +const handleConnectionChange = (connected: boolean) => { + if (connected) { + currentDisplay.value = 'line'; + } +} </script> <template> - <TitleBar :currentDisplay="currentDisplay" @start-service="startPipeServer" @select-display="(mode) => currentDisplay = mode" /> + <TitleBar :currentDisplay="currentDisplay" @select-display="(mode) => currentDisplay = mode" /> <main class="container"> - <!-- <div class="data-source-switch"> - <label>鏁版嵁婧愶細</label> - <select v-model="dataSource"> - <option value="pipe">绠¢亾</option> - <option value="ws">WebSocket</option> - </select> - </div> --> - - <div class="display-mode-icons"> + + + <div class="display-mode-icons"> + <button :class="['icon-button', { active: currentDisplay === 'setting' }]" @click="currentDisplay = 'setting'" title="涓插彛璁剧疆"> + <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> + <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/> + <circle cx="12" cy="12" r="3"/> + </svg> + </button> <button :class="['icon-button', { active: currentDisplay === 'line' }]" @click="currentDisplay = 'line'" title="鏇茬嚎鍥�"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 13L8.5 6L13.5 12L19 7L22 10"/><path d="M18 13a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"/></svg> </button> @@ -70,15 +75,17 @@ <h2>Force Sensor Data Visualization</h2> </div> - - <!-- 鏄剧ず鍔涗紶鎰熷櫒鏁版嵁 --> - <div v-if="showChart" class="chart-wrapper"> - <ForceChart v-if="currentDisplay === 'line'" :pipeName="pipeName" :dataSource="dataSource" /> - <GaugeDisplay v-else-if="currentDisplay === 'gauge'" :pipeName="pipeName" :dataSource="dataSource" /> - <TableDisplay v-else-if="currentDisplay === 'table'" :pipeName="pipeName" :dataSource="dataSource" /> - <ThreeDDisplay v-else-if="currentDisplay === '3d'" :pipeName="pipeName" :dataSource="dataSource" /> + <div class="chart-wrapper"> + + <ForceChart v-if="currentDisplay === 'line'" /> + <GaugeDisplay v-else-if="currentDisplay === 'gauge'" /> + <TableDisplay v-else-if="currentDisplay === 'table'"/> + <ThreeDDisplay v-else-if="currentDisplay === '3d'" /> + <SerialPortConfig v-else-if="currentDisplay === 'setting'" @connection-change="handleConnectionChange" /> </div> + + <!-- <div class="input-group"> <input @@ -122,7 +129,7 @@ .log-container { border-radius: 8px; - max-height: 300px; + height: 34px; overflow-y: auto; } @@ -138,6 +145,41 @@ display: flex; align-items: center; gap: 8px; +} + +/* Modal Styles */ +.modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.5); + display: flex; + justify-content: center; + align-items: center; + z-index: 1000; +} + +.modal-content { + background-color: #fff; + padding: 20px; + border-radius: 8px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + position: relative; + min-width: 300px; + max-width: 90%; +} + +.close-button { + position: absolute; + top: 10px; + right: 10px; + background: none; + border: none; + font-size: 1.2em; + cursor: pointer; + color: #555; } </style> @@ -295,7 +337,7 @@ justify-content: center; gap: 4px; /* Smaller gap for icons */ margin-top: -27px; /* Space between icons and window controls */ - width: 100px; + width: 150px; z-index: 9999; } diff --git a/src/components/ForceChart.vue b/src/components/ForceChart.vue index bc3c801..b3b414c 100644 --- a/src/components/ForceChart.vue +++ b/src/components/ForceChart.vue @@ -3,6 +3,7 @@ import * as echarts from 'echarts'; import { createDataReceiver } from '../utils/dataFetcher'; + const chartContainer = ref<HTMLElement | null>(null); let chart: echarts.ECharts | null = null; @@ -152,29 +153,18 @@ chart?.resize(); } -// 瀹氭椂鑾峰彇鏁版嵁 -let dataTimer: number | null = null; - - onMounted(() => { initChart(); - - const receiveData = createDataReceiver( (forceData) => { + createDataReceiver( (forceData) => { + console.log('forceData', forceData); updateChart(forceData); - }); - - // 姣�100ms鑾峰彇涓�娆℃暟鎹� - dataTimer = window.setInterval(receiveData, 100); + }); // 浼犻�� isSerialPortConnected 鍑芥暟 // 鐩戝惉绐楀彛澶у皬鍙樺寲锛岃皟鏁村浘琛ㄥぇ灏� window.addEventListener('resize', handleResize); }); onUnmounted(() => { - // 娓呯悊瀹氭椂鍣ㄥ拰浜嬩欢鐩戝惉 - if (dataTimer !== null) { - clearInterval(dataTimer); - } window.removeEventListener('resize', handleResize); diff --git a/src/components/GaugeDisplay.vue b/src/components/GaugeDisplay.vue index 9630d2c..2338932 100644 --- a/src/components/GaugeDisplay.vue +++ b/src/components/GaugeDisplay.vue @@ -206,27 +206,18 @@ } - -let dataInterval: number | null = null; - onMounted(() => { initChart(); - const receiveData = createDataReceiver((forceData) => { + createDataReceiver( (forceData) => { updateChart(forceData); - }); - - // 姣�200ms鑾峰彇涓�娆℃暟鎹� - dataInterval = window.setInterval(receiveData, 200); + }); // 浼犻�� isSerialPortConnected 鍑芥暟 // 鐩戝惉绐楀彛澶у皬鍙樺寲锛岃皟鏁村浘琛ㄥぇ灏� window.addEventListener('resize', handleResize); }); onUnmounted(() => { - if (dataInterval !== null) { - clearInterval(dataInterval); - } if (chart) { chart.dispose(); diff --git a/src/components/SerialPortConfig.vue b/src/components/SerialPortConfig.vue new file mode 100644 index 0000000..b0f157b --- /dev/null +++ b/src/components/SerialPortConfig.vue @@ -0,0 +1,157 @@ +<template> + <div style="width: 100%; height: 100%; display: flex; justify-content: center;align-items: center;" > + <div class="serial-port-config"> + <h3>涓插彛閰嶇疆</h3> + <div class="control-group"> + <label for="port-select">閫夋嫨涓插彛:</label> + <select id="port-select" v-model="serialPortStore.selectedPort" @focus="listPorts"> + <option v-for="port in availablePorts" :key="port" :value="port">{{ port }}</option> + </select> + <button @click="listPorts">鍒锋柊</button> + </div> + <div class="control-group"> + <label for="baud-rate-select">娉㈢壒鐜�:</label> + <select id="baud-rate-select" v-model="serialPortStore.baudRate"> + <option v-for="rate in baudRates" :key="rate" :value="rate">{{ rate }}</option> + </select> + </div> + <div class="control-group"> + <button @click="togglePortConnection">{{ serialPortStore.isConnected ? '鍏抽棴涓插彛' : '鎵撳紑涓插彛' }}</button> + </div> + <p v-if="connectionStatus">鐘舵��: {{ connectionStatus }}</p> + </div> + </div> +</template> + +<script setup lang="ts"> +import { ref, onMounted, watch } from 'vue'; +import { invoke } from '@tauri-apps/api/core'; +import { useSerialPortStore } from '../store/serialPort'; + +const emit = defineEmits(['connection-change']); + +const serialPortStore = useSerialPortStore(); + +const availablePorts = ref<string[]>([]); +// const selectedPort = ref<string | null>(null); +const baudRates = ref<number[]>([9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600]); +// const baudRate = ref<number>(115200); // Default baud rate +// const isConnected = ref<boolean>(false); +const connectionStatus = ref<string>(''); + +// List available serial ports +async function listPorts() { + try { + const ports: string[] = await invoke('list_serial_ports'); + availablePorts.value = ports; + if (!serialPortStore.selectedPort && ports.length > 0) { + serialPortStore.setSelectedPort(ports[0]); + } + } catch (error) { + console.error('Error listing serial ports:', error); + connectionStatus.value = `閿欒: ${error}`; + } +} + +// Open or close the serial port +async function togglePortConnection() { + if (serialPortStore.isConnected) { + // Close port + try { + await invoke('close_serial_port'); + serialPortStore.setConnectionStatus(false); + connectionStatus.value = '涓插彛宸插叧闂�'; + console.log('Serial port closed'); + emit('connection-change', false); + } catch (error) { + console.error('Error closing serial port:', error); + connectionStatus.value = `閿欒: ${error}`; + } + } else { + // Open port + if (!serialPortStore.selectedPort) { + connectionStatus.value = '璇烽�夋嫨涓�涓覆鍙�'; + return; + } + try { + const result:string = await invoke('open_serial_port', { appHandle: null, portName: serialPortStore.selectedPort, baudRate: serialPortStore.baudRate }); // appHandle 鍦� Tauri 涓槸闅愬紡浼犻�掔殑锛岃繖閲屽彧鏄负浜嗗尮閰� Rust 鍑芥暟绛惧悕 + console.log("鎵撳紑涓插彛:",result); + serialPortStore.setConnectionStatus(true); + connectionStatus.value = `宸茶繛鎺ュ埌 ${serialPortStore.selectedPort} @ ${serialPortStore.baudRate} bps`; + console.log(`Connected to ${serialPortStore.selectedPort} @ ${serialPortStore.baudRate} bps`); + emit('connection-change', true); + } catch (error) { + console.error('Error opening serial port:', error); + serialPortStore.setConnectionStatus(false); + connectionStatus.value = `閿欒: ${error}`; + } + } +} + +// Automatically list ports when the component mounts +onMounted(() => { + listPorts(); +}); + +// Watch for changes in selectedPort or baudRate and emit them +watch([() => serialPortStore.selectedPort, () => serialPortStore.baudRate, () => serialPortStore.isConnected], () => { + // You might want to emit these values to a parent component or a global state manager + // For now, we'll just log them. + console.log('Selected Port:', serialPortStore.selectedPort); + console.log('Baud Rate:', serialPortStore.baudRate); + console.log('Is Connected:', serialPortStore.isConnected); +}); +</script> + +<style scoped> +.serial-port-config { + padding: 20px; + border: 1px solid #ccc; + border-radius: 8px; + margin-bottom: 20px; + width:300px; + height: 260px; + background-color: #f9f9f9; +} + +.control-group { + margin-bottom: 15px; + display: flex; + align-items: center; + gap: 10px; +} + +.control-group label { + font-weight: bold; + min-width: 80px; + text-align: right; +} + +.control-group select, +.control-group input[type="number"] { + padding: 8px; + border: 1px solid #ddd; + border-radius: 4px; + flex-grow: 1; +} + +.control-group button { + padding: 8px 15px; + background-color: #007bff; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + transition: background-color 0.3s ease; +} + +.control-group button:hover { + background-color: #0056b3; +} + +p { + margin-top: 10px; + font-size: 0.9em; + color: #555; +} +</style> \ No newline at end of file diff --git a/src/components/TableDisplay.vue b/src/components/TableDisplay.vue index 9e6eb01..0fc93f1 100644 --- a/src/components/TableDisplay.vue +++ b/src/components/TableDisplay.vue @@ -1,5 +1,5 @@ <script setup lang="ts"> -import { ref, onMounted, onUnmounted } from 'vue'; +import { ref, onMounted, onUnmounted} from 'vue'; import { createDataReceiver } from '../utils/dataFetcher'; interface ForceData { @@ -38,22 +38,14 @@ } } - - -let dataInterval: number | null = null; - onMounted(() => { - const receiveData = createDataReceiver( (forceData) => { + createDataReceiver((forceData) => { updateTable(forceData); }); - // 姣�500ms鑾峰彇涓�娆℃暟鎹� - dataInterval = window.setInterval(receiveData, 500); }); onUnmounted(() => { - if (dataInterval !== null) { - clearInterval(dataInterval); - } + }); </script> diff --git a/src/components/ThreeDDisplay copy.vue b/src/components/ThreeDDisplay copy.vue deleted file mode 100644 index 239e4d5..0000000 --- a/src/components/ThreeDDisplay copy.vue +++ /dev/null @@ -1,525 +0,0 @@ -<script setup lang="ts"> -import { ref, onMounted, onUnmounted } from 'vue'; -import * as THREE from 'three'; -import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'; -import { sendToPipe } from '../pipe_client'; - -const props = defineProps<{ - pipeName: string; -}>(); - -const containerRef = ref<HTMLElement | null>(null); -let scene: THREE.Scene | null = null; -let camera: THREE.PerspectiveCamera | null = null; -let renderer: THREE.WebGLRenderer | null = null; -let controls: OrbitControls | null = null; - -// 鍔涘拰鍔涚煩鐨勭澶� -let forceArrows: THREE.ArrowHelper[] = []; -let torqueArcs: THREE.Line[] = []; - -// 褰撳墠鍔涘拰鍔涚煩鏁版嵁 -const currentData = ref<number[]>([0, 0, 0, 0, 0, 0]); - -// 棰滆壊瀹氫箟 -const colors = { - fx: 0xff0000, // 绾㈣壊 - fy: 0x00ff00, // 缁胯壊 - fz: 0x0000ff, // 钃濊壊 - mx: 0xff00ff, // 绱壊 - my: 0xffff00, // 榛勮壊 - mz: 0x00ffff // 闈掕壊 -}; - -// 鍒濆鍖�3D鍦烘櫙 -function initScene() { - if (!containerRef.value) return; - - // 鍒涘缓鍦烘櫙 - scene = new THREE.Scene(); - scene.background = new THREE.Color(0x000000); - - // 鍒涘缓鐩告満 - const width = containerRef.value.clientWidth; - const height = containerRef.value.clientHeight; - camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000); - camera.position.set(5, 5, 5); - camera.lookAt(0, 0, 0); - - // 鍒涘缓娓叉煋鍣� - renderer = new THREE.WebGLRenderer({ antialias: true }); - renderer.setSize(width, height); - containerRef.value.appendChild(renderer.domElement); - - // 娣诲姞杞ㄩ亾鎺у埗鍣� - controls = new OrbitControls(camera, renderer.domElement); - controls.enableDamping = true; - controls.dampingFactor = 0.25; - - // 娣诲姞鍧愭爣杞� - const axesHelper = new THREE.AxesHelper(4); - axesHelper.setColors( - new THREE.Color(0x707070), // X杞撮鑹� - new THREE.Color(0x707070), // Y杞撮鑹� - new THREE.Color(0x707070) // Z杞撮鑹� - ); - // 璁剧疆鍧愭爣杞寸殑娓叉煋椤哄簭涓鸿緝浣庡�� - axesHelper.renderOrder = -1; - if (axesHelper instanceof THREE.Object3D) { - axesHelper.traverse((child) => { - if (child instanceof THREE.Line) { - if (child.material instanceof THREE.LineBasicMaterial) { - child.material.depthTest = false; - } - } - }); - } - scene.add(axesHelper); - - // 娣诲姞鍧愭爣杞存爣绛� - const textDistance = 4.2; // 鍧愭爣杞撮暱搴� + 涓�鐐归棿璺� - - // 鍒涘缓鏍囩绮剧伒 - function createAxisLabel(text: string, position: THREE.Vector3) { - const canvas = document.createElement('canvas'); - const context = canvas.getContext('2d'); - if (!context) return null; - - canvas.width = 64; - canvas.height = 64; - - context.fillStyle = '#ffffff'; - context.font = 'bold 48px Arial'; - context.textAlign = 'center'; - context.textBaseline = 'middle'; - context.fillText(text, 32, 32); - - const texture = new THREE.CanvasTexture(canvas); - const spriteMaterial = new THREE.SpriteMaterial({ map: texture }); - const sprite = new THREE.Sprite(spriteMaterial); - - sprite.position.copy(position); - sprite.scale.set(0.5, 0.5, 1); - return sprite; - } - - // 鍒涘缓骞舵坊鍔燲YZ杞存爣绛� - const labelX = createAxisLabel('X', new THREE.Vector3(textDistance, 0, 0)); - const labelY = createAxisLabel('Y', new THREE.Vector3(0, textDistance, 0)); - const labelZ = createAxisLabel('Z', new THREE.Vector3(0, 0, textDistance)); - - if (labelX) scene.add(labelX); - if (labelY) scene.add(labelY); - if (labelZ) scene.add(labelZ); - - // 娣诲姞缃戞牸 - const gridHelper = new THREE.GridHelper(20, 20, 0x404040, 0x404040); - gridHelper.material.opacity = 0.5; - gridHelper.material.transparent = true; - scene.add(gridHelper); - - // 娣诲姞鐜鍏� - const ambientLight = new THREE.AmbientLight(0xffffff, 0.7); - scene.add(ambientLight); - - // 娣诲姞鏂瑰悜鍏� - const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8); - directionalLight.position.set(10, 10, 10); - scene.add(directionalLight); - - // 鍒濆鍖栧姏鍜屽姏鐭╃殑绠ご - initForceArrows(); - initTorqueArcs(); - - // 寮�濮嬪姩鐢诲惊鐜� - animate(); - - // 鍝嶅簲绐楀彛澶у皬鍙樺寲 - window.addEventListener('resize', handleResize); -} - -// 鍒濆鍖栧姏鐨勭澶� -function initForceArrows() { - if (!scene) return; - - // 娓呴櫎鐜版湁鐨勭澶� - forceArrows.forEach(arrow => scene?.remove(arrow)); - forceArrows = []; - - // 鍒涘缓涓変釜鍔涚殑绠ご (Fx, Fy, Fz) - const headLength = 0.5; - const headWidth = 0.3; - - // 鍒涘缓鍔涚殑绠ご (鍒濆闀垮害涓�0) - const fxArrow = new THREE.ArrowHelper( - new THREE.Vector3(1, 0, 0), - new THREE.Vector3(0, 0, 0), - 0.001, - colors.fx, - headLength, - headWidth - ); - fxArrow.renderOrder = 1; - - - const fyArrow = new THREE.ArrowHelper( - new THREE.Vector3(0, 1, 0), - new THREE.Vector3(0, 0, 0), - 0.001, - colors.fy, - headLength, - headWidth - ); - fyArrow.renderOrder = 1; - - - const fzArrow = new THREE.ArrowHelper( - new THREE.Vector3(0, 0, 1), - new THREE.Vector3(0, 0, 0), - 0.001, - colors.fz, - headLength, - headWidth - ); - fzArrow.renderOrder = 1; - - - // 娣诲姞鍒板満鏅� - scene.add(fxArrow); - scene.add(fyArrow); - scene.add(fzArrow); - - // 淇濆瓨寮曠敤 - forceArrows = [fxArrow, fyArrow, fzArrow]; -} - -// 鍒濆鍖栧姏鐭╃殑寮у舰琛ㄧず -function initTorqueArcs() { - if (!scene) return; - - // 娓呴櫎鐜版湁鐨勫姬褰� - torqueArcs.forEach(arc => scene?.remove(arc)); - torqueArcs = []; - - // 鍒涘缓涓変釜鍔涚煩鐨勫姬褰� (Mx, My, Mz) - const radius = 2; - const segments = 32; - - // 鍒涘缓X杞村姏鐭╁姬褰� (缁昘杞存棆杞�) - const mxGeometry = new THREE.BufferGeometry(); - const mxPoints = []; - for (let i = 0; i <= segments; i++) { - const theta = (i / segments) * Math.PI; - mxPoints.push(new THREE.Vector3(0, radius * Math.cos(theta), radius * Math.sin(theta))); - } - mxGeometry.setFromPoints(mxPoints); - const mxArc = new THREE.Line(mxGeometry, new THREE.LineBasicMaterial({ color: colors.mx, linewidth: 2 })); - - // 鍒涘缓Y杞村姏鐭╁姬褰� (缁昚杞存棆杞�) - const myGeometry = new THREE.BufferGeometry(); - const myPoints = []; - for (let i = 0; i <= segments; i++) { - const theta = (i / segments) * Math.PI; - myPoints.push(new THREE.Vector3(radius * Math.cos(theta), 0, radius * Math.sin(theta))); - } - myGeometry.setFromPoints(myPoints); - const myArc = new THREE.Line(myGeometry, new THREE.LineBasicMaterial({ color: colors.my, linewidth: 2 })); - - // 鍒涘缓Z杞村姏鐭╁姬褰� (缁昛杞存棆杞�) - const mzGeometry = new THREE.BufferGeometry(); - const mzPoints = []; - for (let i = 0; i <= segments; i++) { - const theta = (i / segments) * Math.PI; - mzPoints.push(new THREE.Vector3(radius * Math.cos(theta), radius * Math.sin(theta), 0)); - } - mzGeometry.setFromPoints(mzPoints); - const mzArc = new THREE.Line(mzGeometry, new THREE.LineBasicMaterial({ color: colors.mz, linewidth: 2 })); - - // 娣诲姞鍒板満鏅� - scene.add(mxArc); - scene.add(myArc); - scene.add(mzArc); - - // 淇濆瓨寮曠敤 - torqueArcs = [mxArc, myArc, mzArc]; - - // 鍒濆鐘舵�佷笅闅愯棌寮у舰 - torqueArcs.forEach(arc => { - arc.visible = false; - }); -} - -// 鏇存柊鍔涘拰鍔涚煩鐨勫彲瑙嗗寲 -function updateVisualization(forceData: number[]) { - if (!scene) return; - - // 鏇存柊褰撳墠鏁版嵁 - currentData.value = forceData; - - // 璁$畻鍔涚殑鏈�澶у�硷紝鐢ㄤ簬褰掍竴鍖� - const maxForce = Math.max( - Math.abs(forceData[0]), - Math.abs(forceData[1]), - Math.abs(forceData[2]) - ) || 1; // 閬垮厤闄や互闆� - - // 璁$畻鍔涚煩鐨勬渶澶у�硷紝鐢ㄤ簬褰掍竴鍖� - const maxTorque = Math.max( - Math.abs(forceData[3]), - Math.abs(forceData[4]), - Math.abs(forceData[5]) - ) || 1; // 閬垮厤闄や互闆� - - // 鏇存柊鍔涚殑绠ご - const forceScale = 3; // 鏈�澶ч暱搴︿负3涓崟浣� - for (let i = 0; i < 3; i++) { - const force = forceData[i]; - const length = Math.abs(force) / maxForce * forceScale; - - // 鏇存柊绠ご闀垮害鍜屾柟鍚� - if (forceArrows[i]) { - // 濡傛灉鍔涗负闆舵垨闈炲父灏忥紝鍒欏嚑涔庝笉鍙 - if (Math.abs(force) < 0.1) { - forceArrows[i].setLength(0.001); - } else { - forceArrows[i].setLength(length); - - // 濡傛灉鍔涗负璐燂紝鍒欏弽杞柟鍚� - if (force < 0) { - const dir = new THREE.Vector3(); - if (i === 0) dir.set(-1, 0, 0); - if (i === 1) dir.set(0, -1, 0); - if (i === 2) dir.set(0, 0, -1); - forceArrows[i].setDirection(dir); - } else { - const dir = new THREE.Vector3(); - if (i === 0) dir.set(1, 0, 0); - if (i === 1) dir.set(0, 1, 0); - if (i === 2) dir.set(0, 0, 1); - forceArrows[i].setDirection(dir); - } - } - } - } - - // 鏇存柊鍔涚煩鐨勫姬褰� - for (let i = 0; i < 3; i++) { - const torque = forceData[i + 3]; - - // 鏄剧ず鎴栭殣钘忓姏鐭╁姬褰� - if (torqueArcs[i]) { - if (Math.abs(torque) < 0.1) { - torqueArcs[i].visible = false; - } else { - torqueArcs[i].visible = true; - - // 鏍规嵁鍔涚煩鏂瑰悜鏃嬭浆寮у舰 - const arc = torqueArcs[i]; - arc.rotation.set(0, 0, 0); // 閲嶇疆鏃嬭浆 - - // 鏍规嵁鍔涚煩澶у皬鍜屾柟鍚戣缃棆杞� - const rotationAngle = (Math.abs(torque) / maxTorque) * Math.PI / 2; - - if (i === 0) { // Mx - arc.rotation.x = torque > 0 ? rotationAngle : -rotationAngle; - } else if (i === 1) { // My - arc.rotation.y = torque > 0 ? rotationAngle : -rotationAngle; - } else if (i === 2) { // Mz - arc.rotation.z = torque > 0 ? rotationAngle : -rotationAngle; - } - } - } - } -} - -// 鍔ㄧ敾寰幆 -function animate() { - if (!scene || !camera || !renderer || !controls) return; - - requestAnimationFrame(animate); - - // 鏇存柊鎺у埗鍣� - controls.update(); - - // 娓叉煋鍦烘櫙 - renderer.render(scene, camera); -} - -// 澶勭悊绐楀彛澶у皬鍙樺寲 -function handleResize() { - if (!containerRef.value || !camera || !renderer) return; - - const width = containerRef.value.clientWidth; - const height = containerRef.value.clientHeight; - - camera.aspect = width / height; - camera.updateProjectionMatrix(); - - renderer.setSize(width, height); -} - -// 鐘舵�佸彉閲忥紝鐢ㄤ簬鎺у埗閿欒鏄剧ず棰戠巼 -const errorCount = ref(0); -const maxConsecutiveErrors = 5; -const showingError = ref(false); - -// 鎺ユ敹绠¢亾鏁版嵁鐨勫嚱鏁� -async function receiveForceData() { - try { - // 浠庣閬撴帴鏀舵暟鎹� - const response = await sendToPipe(props.pipeName, 'GET_FORCE_DATA'); - - // 鎴愬姛鎺ユ敹鏁版嵁锛岄噸缃敊璇鏁� - errorCount.value = 0; - if (showingError.value) { - showingError.value = false; - console.log('绠¢亾閫氫俊宸叉仮澶�'); - } - - // 瑙f瀽鎺ユ敹鍒扮殑鏁版嵁 - try { - const forceData = JSON.parse(response); - if (Array.isArray(forceData) && forceData.length === 6) { - updateVisualization(forceData); - } - } catch (e) { - console.warn('瑙f瀽鏁版嵁澶辫触:', e); - } - } catch (err) { - // 澧炲姞閿欒璁℃暟 - errorCount.value++; - - // 鍙湪杩炵画閿欒杈惧埌闃堝�兼椂鏄剧ず閿欒淇℃伅锛岄伩鍏嶆棩蹇楀埛灞� - if (errorCount.value >= maxConsecutiveErrors && !showingError.value) { - showingError.value = true; - console.error('绠¢亾閫氫俊鎸佺画澶辫触锛岃妫�鏌ユ湇鍔$鐘舵��:', err); - } - } -} - -// 瀹氭椂鑾峰彇鏁版嵁 -let dataTimer: number | null = null; - -onMounted(() => { - initScene(); - - // 姣忕鑾峰彇涓�娆℃暟鎹� - dataTimer = window.setInterval(receiveForceData, 3000); -}); - -onUnmounted(() => { - // 娓呯悊瀹氭椂鍣ㄥ拰浜嬩欢鐩戝惉 - if (dataTimer !== null) { - clearInterval(dataTimer); - } - - window.removeEventListener('resize', handleResize); - - // 娓呯悊Three.js璧勬簮 - if (renderer) { - renderer.dispose(); - containerRef.value?.removeChild(renderer.domElement); - } - - // 娓呴櫎鍦烘櫙涓殑鎵�鏈夊璞� - if (scene) { - scene.clear(); - } - - // 娓呯┖寮曠敤 - scene = null; - camera = null; - renderer = null; - controls = null; - forceArrows = []; - torqueArcs = []; -}); -</script> - -<template> - <div class="three-container"> - <div class="three-scene" ref="containerRef"></div> - <div class="data-panel"> - <h3 style="color: #ffffff;">鍏淮鍔涙暟鎹�</h3> - <div class="data-row"> - <div class="data-item" style="color: #ff0000"> - <span class="label">Fx:</span> - <span class="value">{{ currentData[0].toFixed(2) }} N</span> - </div> - <div class="data-item" style="color: #00ff00"> - <span class="label">Fy:</span> - <span class="value">{{ currentData[1].toFixed(2) }} N</span> - </div> - <div class="data-item" style="color: #0000ff"> - <span class="label">Fz:</span> - <span class="value">{{ currentData[2].toFixed(2) }} N</span> - </div> - </div> - <div class="data-row"> - <div class="data-item" style="color: #ff00ff"> - <span class="label">Mx:</span> - <span class="value">{{ currentData[3].toFixed(2) }} Nm</span> - </div> - <div class="data-item" style="color: #ffff00"> - <span class="label">My:</span> - <span class="value">{{ currentData[4].toFixed(2) }} Nm</span> - </div> - <div class="data-item" style="color: #00ffff"> - <span class="label">Mz:</span> - <span class="value">{{ currentData[5].toFixed(2) }} Nm</span> - </div> - </div> - </div> - </div> -</template> - -<style scoped> -.three-container { - width: 100%; - height: 540px; - margin: 20px 0; - display: flex; - flex-direction: column; - background-color: #ffffff; - border-radius: 8px; - overflow: hidden; -} - -.three-scene { - width: 100%; - height: 450px; - position: relative; -} - -.data-panel { - padding: 10px 20px; - background-color: #000000; - border-top: 1px solid #535353; -} - -.data-panel h3 { - margin: 0 0 10px 0; - font-size: 16px; - text-align: center; -} - -.data-row { - display: flex; - justify-content: space-around; - margin-bottom: 5px; -} - -.data-item { - display: flex; - align-items: center; - font-weight: bold; -} - -.label { - margin-right: 5px; -} - -.value { - font-family: monospace; -} -</style> \ No newline at end of file diff --git a/src/components/ThreeDDisplay.vue b/src/components/ThreeDDisplay.vue index 10c71da..d8ab4bd 100644 --- a/src/components/ThreeDDisplay.vue +++ b/src/components/ThreeDDisplay.vue @@ -3,8 +3,6 @@ import * as THREE from 'three'; import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'; import { createDataReceiver } from '../utils/dataFetcher'; - - const containerRef = ref<HTMLElement | null>(null); let scene: THREE.Scene | null = null; let camera: THREE.PerspectiveCamera | null = null; @@ -358,29 +356,22 @@ -// 瀹氭椂鑾峰彇鏁版嵁 -let dataTimer: number | null = null; onMounted(() => { initScene(); animate(); - const receiveData = createDataReceiver( (forceData) => { + // createDataReceiver 鐜板湪鐩存帴娉ㄥ唽鍥炶皟骞惰繑鍥炰竴涓竻鐞嗗嚱鏁� + createDataReceiver((forceData) => { updateVisualization(forceData); - }); - - // 姣�100ms鑾峰彇涓�娆℃暟鎹� - dataTimer = window.setInterval(receiveData, 100); + }); // 浼犻�� isSerialPortConnected 鍑芥暟 // 鐩戝惉绐楀彛澶у皬鍙樺寲 window.addEventListener('resize', handleResize); }); onUnmounted(() => { - // 娓呯悊瀹氭椂鍣ㄥ拰浜嬩欢鐩戝惉 - if (dataTimer !== null) { - clearInterval(dataTimer); - } + window.removeEventListener('resize', handleResize); diff --git a/src/main.ts b/src/main.ts index 2b93e5b..d82099e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,10 +1,14 @@ -import { createApp } from "vue"; +import { createApp } from 'vue'; +import { createPinia } from 'pinia'; import App from "./App.vue"; - import { invoke } from "@tauri-apps/api/core"; +import { listen } from '@tauri-apps/api/event'; +import { processSerialData } from './utils/dataFetcher'; -createApp(App).mount("#app"); - +const app = createApp(App); +const pinia = createPinia(); +app.use(pinia); +app.mount("#app"); function sleep(seconds: number): Promise<void> { return new Promise((resolve) => setTimeout(resolve, seconds * 1000)); @@ -17,8 +21,15 @@ console.log("鍓嶇搴旂敤鍚姩瀹屾垚111"); // 璋冪敤鍚庣搴旂敤 invoke("set_complete", { task: "frontend" }); -} + // 鐩戝惉鏉ヨ嚜Rust鍚庣鐨勪覆鍙f暟鎹簨浠� + await listen('serial_data', (event) => { + console.log('serial_data', event); + // event.payload 鏄粠Rust鍙戦�佽繃鏉ョ殑鏁版嵁 + const data = event.payload as number[]; // 鍋囪鏁版嵁鏄瓧鑺傛暟缁� + processSerialData(data); + }); +} window.addEventListener("DOMContentLoaded", () => { console.log("鍓嶇搴旂敤鍚姩222"); diff --git a/src/pipe_client.ts b/src/pipe_client.ts deleted file mode 100644 index 37b8c10..0000000 --- a/src/pipe_client.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { invoke } from '@tauri-apps/api/core'; - -export async function startPipeServer(pipeName: string): Promise<void> { - try { - await invoke('start_pipe_server_command', { pipeName }); - console.log(`Pipe server started on \\\.\\pipe\\${pipeName}`); - } catch (err) { - console.error('Failed to start pipe server:', err); - } -} - -export async function sendToPipe(pipeName: string, message: string): Promise<string> { - // 娣诲姞閲嶈瘯鏈哄埗 - const maxRetries = 3; - let retryCount = 0; - let lastError: any; - - while (retryCount < maxRetries) { - try { - return await invoke('send_pipe_message', { pipeName, message }); - } catch (err) { - lastError = err; - console.warn(`绠¢亾閫氫俊澶辫触锛屾鍦ㄩ噸璇� (${retryCount + 1}/${maxRetries}):`, err); - retryCount++; - - // 绛夊緟涓�娈垫椂闂村啀閲嶈瘯 - if (retryCount < maxRetries) { - await new Promise(resolve => setTimeout(resolve, 500 * retryCount)); - } - } - } - - // 鎵�鏈夐噸璇曢兘澶辫触锛屾姏鍑烘渶鍚庝竴涓敊璇� - throw lastError; -} - -export async function getLatestWsData(): Promise<string | null> { - try { - const result = await invoke<string | null>('get_latest_ws_data'); - console.log("getlatestwsData", result); - return result; - } catch (err) { - console.error('鑾峰彇 WebSocket 鏁版嵁澶辫触:', err); - return null; - } -} \ No newline at end of file diff --git a/src/store/serialPort.ts b/src/store/serialPort.ts new file mode 100644 index 0000000..3ad4e64 --- /dev/null +++ b/src/store/serialPort.ts @@ -0,0 +1,20 @@ +import { defineStore } from 'pinia'; + +export const useSerialPortStore = defineStore('serialPort', { + state: () => ({ + isConnected: false, + selectedPort: null as string | null, + baudRate: 115200 as number, + }), + actions: { + setConnectionStatus(status: boolean) { + this.isConnected = status; + }, + setSelectedPort(port: string | null) { + this.selectedPort = port; + }, + setBaudRate(rate: number) { + this.baudRate = rate; + }, + }, +}); \ No newline at end of file diff --git a/src/utils/dataFetcher.ts b/src/utils/dataFetcher.ts index 05bfdfe..e935fb5 100644 --- a/src/utils/dataFetcher.ts +++ b/src/utils/dataFetcher.ts @@ -1,68 +1,118 @@ -import { getLatestWsData } from '../pipe_client'; +import { invoke } from '@tauri-apps/api/core'; -// const pipeName = 'tauri-pipe-server'; +import * as math from 'mathjs'; -// const dataSource = 'ws'; // pipe|ws +// 瀹氫箟涓�涓被鍨嬶紝鐢ㄤ簬瀛樺偍鎵�鏈夋敞鍐岀殑鍥炶皟鍑芥暟 +type DataCallback = (data: number[]) => void; +const dataCallbacks: DataCallback[] = []; -export async function fetchForceData() { - try { - let response: string | null = null; - - // if (dataSource === 'pipe') { - // if (!pipeName) throw new Error('Pipe name is required for pipe data source'); - // response = await sendToPipe(pipeName, 'GET_FORCE_DATA'); - // } else if (dataSource === 'ws') { - response = await getLatestWsData(); - if (!response) return null; - // } - - if (!response) return null; - - const jsonData = JSON.parse(response); - const forceData = jsonData[0]; - if (Array.isArray(forceData) && forceData.length === 6) { - // 灏嗘暟缁勪腑鐨勬瘡涓暟鍒嗗埆*4000/4194303 - for (let i = 0; i < forceData.length; i++) { - forceData[i] = forceData[i] * 4000 / 4194303; - } - return forceData; - } - - return null; - } catch (error) { - console.error('Error fetching force data:', error); - return null; +// 娉ㄥ唽鏁版嵁鎺ユ敹鍥炶皟鍑芥暟 +export function registerDataCallback(callback: DataCallback) { + dataCallbacks.push(callback); +} + +// 绉婚櫎鏁版嵁鎺ユ敹鍥炶皟鍑芥暟 +export function unregisterDataCallback(callback: DataCallback) { + const index = dataCallbacks.indexOf(callback); + if (index > -1) { + dataCallbacks.splice(index, 1); } } -export function createDataReceiver( callback: (data: number[]) => void) { - let errorCount = 0; - const maxConsecutiveErrors = 5; - let showingError = false; - - return async () => { - try { - const forceData = await fetchForceData(); - console.log('forceData111', forceData); - if (forceData) { - // 閲嶇疆閿欒璁℃暟 - errorCount = 0; - if (showingError) { - showingError = false; - console.log('鏁版嵁閫氫俊宸叉仮澶�'); - } - console.log('forceData222', forceData); - callback(forceData); - } - } catch (err) { - // 澧炲姞閿欒璁℃暟 - errorCount++; - - // 鍙湪杩炵画閿欒杈惧埌闃堝�兼椂鏄剧ず閿欒淇℃伅锛岄伩鍏嶆棩蹇楀埛灞� - if (errorCount >= maxConsecutiveErrors && !showingError) { - showingError = true; - console.error('鏁版嵁閫氫俊鎸佺画澶辫触锛岃妫�鏌ユ湇鍔$鐘舵��:', err); - } +// 澶勭悊浠嶳ust鍚庣鎺ユ敹鍒扮殑涓插彛鏁版嵁 +export function processSerialData(data: number[]): number[] | undefined { + // 瀵规帴鏀跺埌鐨勬暟鎹繘琛宑rc鏍¢獙,鍓嶄袱涓瓧鑺傛槸甯уご锛屽悗涓や釜瀛楄妭鏄牎楠屽�� + // 鏍¢獙鏁版嵁鏄惁姝g‘ + // 鍘婚櫎鍓嶄袱涓瓧鑺傚拰鍚庝袱涓瓧鑺� + const dataWithoutHeaderAndCRC = data.slice(0, -2); + const crc16 = crc16modbus(dataWithoutHeaderAndCRC); + // 鏍¢獙鏁版嵁鏄惁姝g‘ + if (crc16[0] === data[data.length - 2] && crc16[1] === data[data.length - 1]) { + console.log('鏍¢獙鏁版嵁姝g‘'); + } + + const dataWithoutHeader = data.slice(2, -2); + // dataWithoutHeader 涓瘡涓変釜瀛楄妭杞崲鎴愪竴涓暟 + const dataArray: number[] = []; + for (let i = 0; i < dataWithoutHeader.length; i += 3) { + const num = dataWithoutHeader[i] * 256 * 256 + dataWithoutHeader[i + 1] * 256 + dataWithoutHeader[i + 2]; + dataArray.push(num); + } + console.log('dataArray', dataArray); + invoke('log_data', { data: JSON.stringify(dataArray) }) + .then(() => console.log('Data logged successfully')) + .catch((e: any) => console.error('Failed to log data:', e)); + // 瀵规帴鏀跺埌鐨勬暟鎹繘琛屽鐞� + if (Array.isArray(dataArray) && dataArray.length === 6) { + // 灏嗘暟缁勪腑鐨勬瘡涓暟鍒嗗埆*4000/4194303 + for (let i = 0; i < dataArray.length; i++) { + dataArray[i] = dataArray[i] * 4000 / 4194303; } + + // 瀹氫箟B鐭╅樀锛堜粠Excel鏂囦欢涓幏鍙栵級 + const B = [ + [-6.501014986, 49.89944483, -47.37512707, 3.306871125, -730.3864937, 731.892412], + [39.02334352, -20.01844412, -28.31245682, -846.7104044, 422.5886114, 423.8930456], + [1323.394066, 1311.347472, 1318.438012, -6.141452446, -5.309142718, -17.72182533], + [-0.461934807, 38.31359845, -37.51342676, -10.30786014, 5.431648347, -4.552001119], + [44.06827786, -21.49540034, -22.28032529, -0.447302394, -8.60890465, 9.325018254], + [1.125851578, 1.306669827, 1.532290446, -23.04749193, -23.05906062, -23.19316741] + ]; + + // 璁$畻鐪熷疄鐨勫姏鍊硷細F = B * dataArray + const realForces = math.multiply(B, dataArray); + + // 灏嗗鐞嗗悗鐨勬暟鎹垎鍙戠粰鎵�鏈夋敞鍐岀殑鍥炶皟鍑芥暟 + dataCallbacks.forEach(callback => callback(realForces as number[])); + // 杩斿洖鐪熷疄鐨勫姏鍊兼暟缁� + return realForces as number[]; + } else { + console.error("Data array must contain 6 elements."); + return undefined; + } +} + +export function createDataReceiver(callback: (data: number[]) => void) { + // 鐩存帴娉ㄥ唽鍥炶皟鍑芥暟锛屼笉鍐嶉渶瑕佽疆璇㈡垨閿欒璁℃暟 + registerDataCallback(callback); + + // 杩斿洖涓�涓竻鐞嗗嚱鏁帮紝鐢ㄤ簬鍦ㄧ粍浠跺嵏杞芥椂绉婚櫎鍥炶皟 + return () => { + unregisterDataCallback(callback); }; -} \ No newline at end of file +} + +// CRC-16/Modbus 鏌ヨ〃娉曢鐢熸垚 256 涓� CRC 鍊� +function makeCRCTable() { + const table = new Array(256); + const polynomial = 0xA001; + + for (let i = 0; i < 256; i++) { + let crc = i; + for (let j = 0; j < 8; j++) { + if (crc & 0x0001) { + crc = (crc >>> 1) ^ polynomial; + } else { + crc >>>= 1; + } + } + table[i] = crc; + } + return table; +} + +const crcTable = makeCRCTable(); + +// CRC-16/Modbus 璁$畻鍑芥暟 +function crc16modbus(buffer: number[]) { + let crc = 0xFFFF; + + for (let i = 0; i < buffer.length; i++) { + let tableIndex = (crc ^ buffer[i]) & 0xFF; + crc = (crc >>> 8) ^ crcTable[tableIndex]; + } + + // 杩斿洖灏忕鏍煎紡锛圡odbus 瑕佹眰浣庝綅鍦ㄥ墠锛夛紝浠ュ瓧鑺傛暟缁勭殑褰㈠紡杩斿洖 + const crcBytes = [crc & 0xFF, crc >>> 8]; + return crcBytes; +} -- Gitblit v1.9.3