├── .gitignore ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── cipy-app ├── lib │ └── colorsys.mpy ├── main.py ├── ui.json └── watch ├── dev-ws-rs ├── Cargo.toml └── src │ └── main.rs ├── enc ├── serial-ws-bridge ├── Cargo.lock ├── Cargo.toml ├── run.sh └── src │ ├── main.rs │ └── serial.rs ├── src ├── bin │ ├── encode.rs │ ├── json.rs │ └── sizes.rs └── lib.rs ├── stm32f4-app ├── .cargo │ └── config.toml ├── Cargo.lock ├── Cargo.toml ├── build.rs ├── memory.x ├── rust-toolchain.toml └── src │ └── main.rs ├── update_elf.sh ├── web-app ├── .gitignore ├── Cargo.toml ├── Dioxus.toml ├── LICENSE ├── README.md ├── public │ ├── chart.js │ ├── d3.v7.min.js │ ├── favicon.ico │ └── style.css └── src │ ├── components.rs │ ├── defmt_handler.rs │ ├── lib.rs │ ├── main.rs │ └── ser_de.rs └── ws-py ├── .envrc ├── .gitignore ├── README.md ├── client.py └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /Cargo.lock 3 | .vscode 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "embedded-web-ui" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [workspace] 7 | members = ["web-app", "serial-ws-bridge"] 8 | exclude = ["ws-py", "cipy-app", "stm32f4-app"] 9 | 10 | 11 | [dependencies] 12 | defmt = { version = "=0.3.2", optional = true } 13 | heapless = { version = "0.7", default-features = false, features = [ 14 | "defmt-impl", 15 | "serde", 16 | ] } 17 | serde = { version = "1", default_features = false, features = ["derive"] } 18 | postcard = { version = "1.0.4", features = ["use-std"], optional = true } 19 | serde_json = { version = "1", optional = true } 20 | 21 | [dev-dependencies] 22 | postcard = { version = "1.0.4", features = ["use-std"] } 23 | 24 | [features] 25 | std = [] 26 | defmt = ["dep:defmt"] 27 | postcard = ["dep:postcard"] 28 | json = ["dep:serde_json"] 29 | 30 | [[bin]] 31 | name = "sizes" 32 | required-features = ["postcard"] 33 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Anatol Ulrich 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # embedded-web-ui 2 | 3 | Remote web UI for embedded (Rust) applications. 4 | Control an embedded application (or anything, really) using a browser, which talks to a websocket/serial bridge. 5 | Receive data back and plot in live charts. 6 | 7 | https://github.com/spookyvision/embedded-web-ui/assets/45840/a1f33a06-5b54-44d1-8552-ea7130e319e5 8 | 9 | ### FFT example (link to youtube): 10 | [![Live FFT chart sampled from microphone](https://img.youtube.com/vi/OVQCu2fmVps/0.jpg)](https://www.youtube.com/watch?v=OVQCu2fmVps) 11 | 12 | ## High level usage 13 | 14 | - You need a serial device connected to the host. 15 | - Describe your desired UI primitives (buttons, sliders, charts, etc.) in your embedded application and send them out over this connection. Same goes for data updates (chart time series ticks, bar data). The list **MUST** start with a `Reset`. 16 | - These widgets are then displayed on a web page. User interactions (button press, slider value change, ...) are sent back to the device. 17 | 18 | ## Running 19 | Since Mozilla's position on WebSerial is [a hard no](https://mozilla.github.io/standards-positions/#webserial), 20 | we include a bridge that translates serial packets to WebSockets: 21 | 22 | ```sh 23 | $ cd serial-ws-bridge 24 | 25 | # tries to guess the serial device 26 | $ cargo run 27 | 28 | # alternatively, specify the name 29 | $ cargo run -- /dev/cu.usbserial1234 30 | ``` 31 | 32 | 33 | now, start the web server: 34 | 35 | (**TODO add more convenient dev server option** by providing a prebuilt app) 36 | 37 | ```sh 38 | # once: install dioxus CLI 39 | # you can use `cargo install dioxus-cli` when these fixes have made it to the release version: 40 | # https://github.com/DioxusLabs/cli/pull/122 41 | # https://github.com/DioxusLabs/cli/pull/130 42 | $ cargo install --git https://github.com/spookyvision/dioxus-cli --branch patch-1 43 | 44 | $ cd web-app 45 | $ dioxus serve --features postcard # for Rust applications 46 | # or 47 | $ dioxus serve --features json # for e.g. micropython/circuitpython 48 | 49 | # open in browser: http://localhost:8080/ 50 | ``` 51 | 52 | finally, connect the serial device and enjoy your remote UI! 53 | 54 | ## UI details 55 | 56 | - available primitives: see `/src/lib.rs`. 57 | 58 | 59 | ## example stm32f4 app 60 | 61 | (extremely proof of concept only - do not take as reference implementation!) 62 | - toggles board LED 63 | - sends random chart data when requested 64 | 65 | ## notes on JSON 66 | 67 | The serial/ws bridge is largely content agnostic but assumes packets sent from the serial device are framed/terminated with nullbytes. 68 | The other direction doesn't need such a separator, since WebSockets are already framed. 69 | 70 | In practice this means: 71 | - postcard COBS encoding is fine to transmit as-is 72 | - other COBS encodings might need an explicit `\0` appended, since it's strictly speaking not part of the actual payload 73 | - JSON data needs to be terminated with an explicit `\0` 74 | - any other data is fine, as long as it does not contain `\0` except for framing. The web app currently only supports decoding JSON and postcard-cobs, though. See `web-app/src/ser_de.rs` for details. 75 | -------------------------------------------------------------------------------- /cipy-app/lib/colorsys.mpy: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: Python Software Foundation 2 | # 3 | # SPDX-License-Identifier: PSF-2.0 4 | 5 | """ 6 | `colorsys` 7 | ==================================================== 8 | 9 | Subset of CPython module colorsys for use in CircuitPython. 10 | 11 | Conversion functions between RGB and other color systems 12 | 13 | * Author(s): Python Software Foundation 14 | 15 | Implementation Notes 16 | -------------------- 17 | 18 | **Software and Dependencies:** 19 | 20 | * Adafruit CircuitPython firmware for the supported boards: 21 | https://github.com/adafruit/circuitpython/releases 22 | 23 | """ 24 | 25 | try: 26 | from typing import Tuple 27 | except ImportError: 28 | pass 29 | 30 | 31 | __version__ = "2.0.14" 32 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Colorsys.git" 33 | __all__ = ["hls_to_rgb", "hsv_to_rgb"] 34 | 35 | # Some floating point constants 36 | 37 | ONE_THIRD = 1.0 / 3.0 38 | ONE_SIXTH = 1.0 / 6.0 39 | TWO_THIRD = 2.0 / 3.0 40 | 41 | # HLS: Hue, Luminance, Saturation 42 | # H: position in the spectrum 43 | # L: color lightness 44 | # S: color saturation 45 | 46 | 47 | def hls_to_rgb(hue: float, light: float, sat: float) -> Tuple[float, float, float]: 48 | """Converts HLS to RGB values 49 | 50 | :param float hue: The hue of the color to convert 51 | :param float light: The lightness of the color to convert 52 | :param float sat: The saturation of the color to convert 53 | """ 54 | 55 | if sat == 0.0: 56 | return light, light, light 57 | if light <= 0.5: 58 | chroma2 = light * (1.0 + sat) 59 | else: 60 | chroma2 = light + sat - (light * sat) 61 | chroma1 = 2.0 * light - chroma2 62 | return ( 63 | int(_v(chroma1, chroma2, hue + ONE_THIRD) * 255), 64 | int(_v(chroma1, chroma2, hue) * 255), 65 | int(_v(chroma1, chroma2, hue - ONE_THIRD) * 255), 66 | ) 67 | 68 | 69 | def _v(chroma1: float, chroma2: float, hue: float) -> float: 70 | hue = hue % 1.0 71 | if hue < ONE_SIXTH: 72 | return chroma1 + (chroma2 - chroma1) * hue * 6.0 73 | if hue < 0.5: 74 | return chroma2 75 | if hue < TWO_THIRD: 76 | return chroma1 + (chroma2 - chroma1) * (TWO_THIRD - hue) * 6.0 77 | return chroma1 78 | 79 | 80 | # HSV: Hue, Saturation, Value 81 | # H: position in the spectrum 82 | # S: color saturation ("purity") 83 | # V: color brightness 84 | 85 | 86 | def hsv_to_rgb( # pylint: disable=too-many-return-statements,inconsistent-return-statements 87 | hue: float, sat: float, val: float 88 | ) -> Tuple[float, float, float]: 89 | """Converts HSV to RGB values 90 | 91 | :param float hue: The hue of the color to convert 92 | :param float sat: The saturation of the color to convert 93 | :param float val: The value (or brightness) of the color to convert 94 | """ 95 | if sat == 0.0: 96 | return val, val, val 97 | i = int(hue * 6.0) # assume int() truncates! 98 | hue1 = (hue * 6.0) - i 99 | chroma1 = val * (1.0 - sat) 100 | chroma2 = val * (1.0 - sat * hue1) 101 | chroma3 = val * (1.0 - sat * (1.0 - hue1)) 102 | i = i % 6 103 | if i == 0: 104 | return int(val * 255), int(chroma3 * 255), int(chroma1 * 255) 105 | if i == 1: 106 | return int(chroma2 * 255), int(val * 255), int(chroma1 * 255) 107 | if i == 2: 108 | return int(chroma1 * 255), int(val * 255), int(chroma3 * 255) 109 | if i == 3: 110 | return int(chroma1 * 255), int(chroma2 * 255), int(val * 255) 111 | if i == 4: 112 | return int(chroma3 * 255), int(chroma1 * 255), int(val * 255) 113 | if i == 5: 114 | return int(val * 255), int(chroma1 * 255), int(chroma2 * 255) 115 | # Cannot get here 116 | -------------------------------------------------------------------------------- /cipy-app/main.py: -------------------------------------------------------------------------------- 1 | import usb_cdc 2 | import json 3 | import board 4 | import neopixel 5 | from rainbowio import colorwheel 6 | from time import sleep 7 | 8 | 9 | board_pixel = neopixel.NeoPixel(board.NEOPIXEL, 1) 10 | 11 | 12 | def to_components(i): 13 | rgb = colorwheel(i) 14 | return (rgb & 0xff, rgb >> 8 & 0xff, rgb >> 16 & 0xff) 15 | 16 | 17 | data = None 18 | with open('ui.json', 'rb') as fh: 19 | data = fh.read() 20 | usb_cdc.data.write(data) 21 | usb_cdc.data.write(b'\0') 22 | bof = bytearray() 23 | print("ready for action") 24 | while True: 25 | sep = b'\0' 26 | recv = usb_cdc.data.read() 27 | bof.extend(recv) 28 | while sep in bof: 29 | split = bof.index(sep) 30 | 31 | try: 32 | s = bof[:split].decode() 33 | dec = json.loads(s) 34 | print(dec) 35 | if dec.get('Click') == 0: 36 | usb_cdc.data.write(data) 37 | usb_cdc.data.write(b'\0') 38 | elif dec.get('Click') == 1: 39 | board_pixel[0] = (10, 10, 10) 40 | elif dec.get('Click') == 2: 41 | board_pixel[0] = (0, 0, 0) 42 | else: 43 | slider = dec.get('Slider') 44 | if slider is not None: 45 | [idx, val] = slider 46 | board_pixel[0] = to_components(val) 47 | except: 48 | print("decode error") 49 | bof = bof[split+1:] 50 | -------------------------------------------------------------------------------- /cipy-app/ui.json: -------------------------------------------------------------------------------- 1 | [ 2 | "Reset", 3 | { 4 | "UI": { 5 | "Widget": { 6 | "kind": "Button", 7 | "label": "LED on", 8 | "id": 1 9 | } 10 | } 11 | }, 12 | { 13 | "UI": { 14 | "Widget": { 15 | "kind": "Button", 16 | "label": "LED off", 17 | "id": 2 18 | } 19 | } 20 | }, 21 | { 22 | "UI": { 23 | "Widget": { 24 | "kind": "Button", 25 | "label": "give data", 26 | "id": 3 27 | } 28 | } 29 | }, 30 | { 31 | "UI": "Break" 32 | }, 33 | { 34 | "UI": { 35 | "Widget": { 36 | "kind": "Slider", 37 | "label": "slidos", 38 | "id": 4 39 | } 40 | } 41 | }, 42 | { 43 | "UI": "Break" 44 | }, 45 | { 46 | "UI": { 47 | "Widget": { 48 | "kind": "BarChart", 49 | "label": "a bar chart", 50 | "id": 5 51 | } 52 | } 53 | } 54 | ] -------------------------------------------------------------------------------- /cipy-app/watch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | fswatch -0 $@ | xargs -0 -I {} cp {} /Volumes/CIRCUITPY 3 | -------------------------------------------------------------------------------- /dev-ws-rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dev-ws-rs" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | futures-util = "0.3.28" 10 | log = "0.4.17" 11 | pretty_env_logger = "0.4.0" 12 | tokio = { version = "1.27.0", features = ["full"] } 13 | tokio-tungstenite = "0.18.0" 14 | tungstenite = "0.18.0" 15 | embedded-web-ui = { path = "..", features = ["std"] } 16 | postcard = { version = "1.0.4", features = ["use-std"] } 17 | -------------------------------------------------------------------------------- /dev-ws-rs/src/main.rs: -------------------------------------------------------------------------------- 1 | use embedded_web_ui::{Command, Input, Widget, WidgetKind, UI}; 2 | use futures_util::{SinkExt, StreamExt}; 3 | use log::*; 4 | use std::{net::SocketAddr, time::Duration}; 5 | use tokio::net::{TcpListener, TcpStream}; 6 | use tokio_tungstenite::accept_async; 7 | use tungstenite::Message; 8 | 9 | async fn accept_connection(peer: SocketAddr, stream: TcpStream) { 10 | if let Err(e) = handle_connection(peer, stream).await { 11 | error!("(maybe) error processing connection: {e:?}") 12 | } 13 | } 14 | 15 | async fn handle_connection( 16 | peer: SocketAddr, 17 | stream: TcpStream, 18 | ) -> Result<(), Box> { 19 | let ws_stream = accept_async(stream).await.expect("Failed to accept"); 20 | info!("New WebSocket connection: {}", peer); 21 | let (mut ws_sender, mut ws_receiver) = ws_stream.split(); 22 | let mut interval = tokio::time::interval(Duration::from_millis(1000)); 23 | 24 | let items: Vec = vec![ 25 | Command::Reset, 26 | Widget { 27 | kind: WidgetKind::Button, 28 | label: "oh,aye".into(), 29 | id: 1, 30 | } 31 | .into(), 32 | UI::Break.into(), 33 | Widget { 34 | kind: WidgetKind::Slider, 35 | label: "slidos".into(), 36 | id: 2, 37 | } 38 | .into(), 39 | UI::Break.into(), 40 | Widget { 41 | kind: WidgetKind::BarChart, 42 | label: "a bar chart".into(), 43 | id: 3, 44 | } 45 | .into(), 46 | UI::Break.into(), 47 | Widget { 48 | kind: WidgetKind::BarChart, 49 | label: "another bar chart".into(), 50 | id: 4, 51 | } 52 | .into(), 53 | ]; 54 | 55 | let ser = postcard::to_allocvec_cobs(&items)?; 56 | 57 | loop { 58 | tokio::select! { 59 | msg = ws_receiver.next() => { 60 | match msg { 61 | Some(msg) => { 62 | let msg = msg?; 63 | match msg { 64 | Message::Binary(mut data) => { 65 | match postcard::from_bytes_cobs::(&mut data) { 66 | Ok(input) => info!("received input {input:?}"), 67 | Err(e) => error!("oh noes, {e:?}"), 68 | } 69 | }, 70 | Message::Close(_) => break, 71 | _ => info!("naw ") 72 | } 73 | 74 | } 75 | None => break, 76 | } 77 | } 78 | _ = interval.tick() => { 79 | ws_sender.send(Message::Binary(ser.clone())).await?; 80 | } 81 | } 82 | } 83 | 84 | Ok(()) 85 | } 86 | 87 | #[tokio::main] 88 | async fn main() { 89 | pretty_env_logger::init(); 90 | 91 | let addr = "127.0.0.1:9002"; 92 | let listener = TcpListener::bind(&addr).await.expect("Can't listen"); 93 | info!("Listening on: {}", addr); 94 | 95 | while let Ok((stream, _)) = listener.accept().await { 96 | let peer = stream 97 | .peer_addr() 98 | .expect("connected streams should have a peer address"); 99 | info!("Peer address: {}", peer); 100 | 101 | tokio::spawn(accept_connection(peer, stream)); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /enc: -------------------------------------------------------------------------------- 1 | awebr 2 | -------------------------------------------------------------------------------- /serial-ws-bridge/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "CoreFoundation-sys" 7 | version = "0.1.4" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d0e9889e6db118d49d88d84728d0e964d973a5680befb5f85f55141beea5c20b" 10 | dependencies = [ 11 | "libc", 12 | "mach 0.1.2", 13 | ] 14 | 15 | [[package]] 16 | name = "IOKit-sys" 17 | version = "0.1.5" 18 | source = "registry+https://github.com/rust-lang/crates.io-index" 19 | checksum = "99696c398cbaf669d2368076bdb3d627fb0ce51a26899d7c61228c5c0af3bf4a" 20 | dependencies = [ 21 | "CoreFoundation-sys", 22 | "libc", 23 | "mach 0.1.2", 24 | ] 25 | 26 | [[package]] 27 | name = "addr2line" 28 | version = "0.19.0" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" 31 | dependencies = [ 32 | "gimli", 33 | ] 34 | 35 | [[package]] 36 | name = "adler" 37 | version = "1.0.2" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 40 | 41 | [[package]] 42 | name = "aho-corasick" 43 | version = "0.7.20" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" 46 | dependencies = [ 47 | "memchr", 48 | ] 49 | 50 | [[package]] 51 | name = "anyhow" 52 | version = "1.0.70" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" 55 | 56 | [[package]] 57 | name = "async-stream" 58 | version = "0.3.5" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" 61 | dependencies = [ 62 | "async-stream-impl", 63 | "futures-core", 64 | "pin-project-lite", 65 | ] 66 | 67 | [[package]] 68 | name = "async-stream-impl" 69 | version = "0.3.5" 70 | source = "registry+https://github.com/rust-lang/crates.io-index" 71 | checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" 72 | dependencies = [ 73 | "proc-macro2", 74 | "quote", 75 | "syn 2.0.13", 76 | ] 77 | 78 | [[package]] 79 | name = "async-trait" 80 | version = "0.1.68" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" 83 | dependencies = [ 84 | "proc-macro2", 85 | "quote", 86 | "syn 2.0.13", 87 | ] 88 | 89 | [[package]] 90 | name = "autocfg" 91 | version = "1.1.0" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 94 | 95 | [[package]] 96 | name = "axum" 97 | version = "0.6.12" 98 | source = "registry+https://github.com/rust-lang/crates.io-index" 99 | checksum = "349f8ccfd9221ee7d1f3d4b33e1f8319b3a81ed8f61f2ea40b37b859794b4491" 100 | dependencies = [ 101 | "async-trait", 102 | "axum-core", 103 | "base64 0.21.0", 104 | "bitflags", 105 | "bytes", 106 | "futures-util", 107 | "headers", 108 | "http", 109 | "http-body", 110 | "hyper", 111 | "itoa", 112 | "matchit", 113 | "memchr", 114 | "mime", 115 | "percent-encoding", 116 | "pin-project-lite", 117 | "rustversion", 118 | "serde", 119 | "serde_json", 120 | "serde_path_to_error", 121 | "serde_urlencoded", 122 | "sha1", 123 | "sync_wrapper", 124 | "tokio", 125 | "tokio-tungstenite", 126 | "tower", 127 | "tower-layer", 128 | "tower-service", 129 | ] 130 | 131 | [[package]] 132 | name = "axum-core" 133 | version = "0.3.3" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "b2f958c80c248b34b9a877a643811be8dbca03ca5ba827f2b63baf3a81e5fc4e" 136 | dependencies = [ 137 | "async-trait", 138 | "bytes", 139 | "futures-util", 140 | "http", 141 | "http-body", 142 | "mime", 143 | "rustversion", 144 | "tower-layer", 145 | "tower-service", 146 | ] 147 | 148 | [[package]] 149 | name = "backtrace" 150 | version = "0.3.67" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" 153 | dependencies = [ 154 | "addr2line", 155 | "cc", 156 | "cfg-if", 157 | "libc", 158 | "miniz_oxide", 159 | "object", 160 | "rustc-demangle", 161 | ] 162 | 163 | [[package]] 164 | name = "base64" 165 | version = "0.13.1" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" 168 | 169 | [[package]] 170 | name = "base64" 171 | version = "0.21.0" 172 | source = "registry+https://github.com/rust-lang/crates.io-index" 173 | checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" 174 | 175 | [[package]] 176 | name = "bitflags" 177 | version = "1.3.2" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 180 | 181 | [[package]] 182 | name = "block-buffer" 183 | version = "0.10.4" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 186 | dependencies = [ 187 | "generic-array", 188 | ] 189 | 190 | [[package]] 191 | name = "byteorder" 192 | version = "1.4.3" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 195 | 196 | [[package]] 197 | name = "bytes" 198 | version = "1.4.0" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" 201 | 202 | [[package]] 203 | name = "cc" 204 | version = "1.0.79" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 207 | 208 | [[package]] 209 | name = "cfg-if" 210 | version = "1.0.0" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 213 | 214 | [[package]] 215 | name = "color-eyre" 216 | version = "0.6.2" 217 | source = "registry+https://github.com/rust-lang/crates.io-index" 218 | checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" 219 | dependencies = [ 220 | "backtrace", 221 | "color-spantrace", 222 | "eyre", 223 | "indenter", 224 | "once_cell", 225 | "owo-colors", 226 | "tracing-error", 227 | ] 228 | 229 | [[package]] 230 | name = "color-spantrace" 231 | version = "0.2.0" 232 | source = "registry+https://github.com/rust-lang/crates.io-index" 233 | checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" 234 | dependencies = [ 235 | "once_cell", 236 | "owo-colors", 237 | "tracing-core", 238 | "tracing-error", 239 | ] 240 | 241 | [[package]] 242 | name = "console-api" 243 | version = "0.4.0" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | checksum = "e57ff02e8ad8e06ab9731d5dc72dc23bef9200778eae1a89d555d8c42e5d4a86" 246 | dependencies = [ 247 | "prost", 248 | "prost-types", 249 | "tonic", 250 | "tracing-core", 251 | ] 252 | 253 | [[package]] 254 | name = "console-subscriber" 255 | version = "0.1.8" 256 | source = "registry+https://github.com/rust-lang/crates.io-index" 257 | checksum = "22a3a81dfaf6b66bce5d159eddae701e3a002f194d378cbf7be5f053c281d9be" 258 | dependencies = [ 259 | "console-api", 260 | "crossbeam-channel", 261 | "crossbeam-utils", 262 | "futures", 263 | "hdrhistogram", 264 | "humantime", 265 | "prost-types", 266 | "serde", 267 | "serde_json", 268 | "thread_local", 269 | "tokio", 270 | "tokio-stream", 271 | "tonic", 272 | "tracing", 273 | "tracing-core", 274 | "tracing-subscriber", 275 | ] 276 | 277 | [[package]] 278 | name = "cpufeatures" 279 | version = "0.2.6" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" 282 | dependencies = [ 283 | "libc", 284 | ] 285 | 286 | [[package]] 287 | name = "crc32fast" 288 | version = "1.3.2" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" 291 | dependencies = [ 292 | "cfg-if", 293 | ] 294 | 295 | [[package]] 296 | name = "crossbeam-channel" 297 | version = "0.5.7" 298 | source = "registry+https://github.com/rust-lang/crates.io-index" 299 | checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" 300 | dependencies = [ 301 | "cfg-if", 302 | "crossbeam-utils", 303 | ] 304 | 305 | [[package]] 306 | name = "crossbeam-utils" 307 | version = "0.8.15" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" 310 | dependencies = [ 311 | "cfg-if", 312 | ] 313 | 314 | [[package]] 315 | name = "crypto-common" 316 | version = "0.1.6" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 319 | dependencies = [ 320 | "generic-array", 321 | "typenum", 322 | ] 323 | 324 | [[package]] 325 | name = "digest" 326 | version = "0.10.6" 327 | source = "registry+https://github.com/rust-lang/crates.io-index" 328 | checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" 329 | dependencies = [ 330 | "block-buffer", 331 | "crypto-common", 332 | ] 333 | 334 | [[package]] 335 | name = "either" 336 | version = "1.8.1" 337 | source = "registry+https://github.com/rust-lang/crates.io-index" 338 | checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" 339 | 340 | [[package]] 341 | name = "eyre" 342 | version = "0.6.8" 343 | source = "registry+https://github.com/rust-lang/crates.io-index" 344 | checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" 345 | dependencies = [ 346 | "indenter", 347 | "once_cell", 348 | ] 349 | 350 | [[package]] 351 | name = "flate2" 352 | version = "1.0.25" 353 | source = "registry+https://github.com/rust-lang/crates.io-index" 354 | checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" 355 | dependencies = [ 356 | "crc32fast", 357 | "miniz_oxide", 358 | ] 359 | 360 | [[package]] 361 | name = "fnv" 362 | version = "1.0.7" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 365 | 366 | [[package]] 367 | name = "form_urlencoded" 368 | version = "1.1.0" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 371 | dependencies = [ 372 | "percent-encoding", 373 | ] 374 | 375 | [[package]] 376 | name = "futures" 377 | version = "0.3.28" 378 | source = "registry+https://github.com/rust-lang/crates.io-index" 379 | checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" 380 | dependencies = [ 381 | "futures-channel", 382 | "futures-core", 383 | "futures-executor", 384 | "futures-io", 385 | "futures-sink", 386 | "futures-task", 387 | "futures-util", 388 | ] 389 | 390 | [[package]] 391 | name = "futures-channel" 392 | version = "0.3.28" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" 395 | dependencies = [ 396 | "futures-core", 397 | "futures-sink", 398 | ] 399 | 400 | [[package]] 401 | name = "futures-core" 402 | version = "0.3.28" 403 | source = "registry+https://github.com/rust-lang/crates.io-index" 404 | checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" 405 | 406 | [[package]] 407 | name = "futures-executor" 408 | version = "0.3.28" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" 411 | dependencies = [ 412 | "futures-core", 413 | "futures-task", 414 | "futures-util", 415 | ] 416 | 417 | [[package]] 418 | name = "futures-io" 419 | version = "0.3.28" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" 422 | 423 | [[package]] 424 | name = "futures-macro" 425 | version = "0.3.28" 426 | source = "registry+https://github.com/rust-lang/crates.io-index" 427 | checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" 428 | dependencies = [ 429 | "proc-macro2", 430 | "quote", 431 | "syn 2.0.13", 432 | ] 433 | 434 | [[package]] 435 | name = "futures-sink" 436 | version = "0.3.28" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" 439 | 440 | [[package]] 441 | name = "futures-task" 442 | version = "0.3.28" 443 | source = "registry+https://github.com/rust-lang/crates.io-index" 444 | checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" 445 | 446 | [[package]] 447 | name = "futures-util" 448 | version = "0.3.28" 449 | source = "registry+https://github.com/rust-lang/crates.io-index" 450 | checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" 451 | dependencies = [ 452 | "futures-channel", 453 | "futures-core", 454 | "futures-io", 455 | "futures-macro", 456 | "futures-sink", 457 | "futures-task", 458 | "memchr", 459 | "pin-project-lite", 460 | "pin-utils", 461 | "slab", 462 | ] 463 | 464 | [[package]] 465 | name = "generic-array" 466 | version = "0.14.7" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" 469 | dependencies = [ 470 | "typenum", 471 | "version_check", 472 | ] 473 | 474 | [[package]] 475 | name = "getrandom" 476 | version = "0.2.8" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" 479 | dependencies = [ 480 | "cfg-if", 481 | "libc", 482 | "wasi", 483 | ] 484 | 485 | [[package]] 486 | name = "gimli" 487 | version = "0.27.2" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" 490 | 491 | [[package]] 492 | name = "glob" 493 | version = "0.3.1" 494 | source = "registry+https://github.com/rust-lang/crates.io-index" 495 | checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" 496 | 497 | [[package]] 498 | name = "h2" 499 | version = "0.3.16" 500 | source = "registry+https://github.com/rust-lang/crates.io-index" 501 | checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" 502 | dependencies = [ 503 | "bytes", 504 | "fnv", 505 | "futures-core", 506 | "futures-sink", 507 | "futures-util", 508 | "http", 509 | "indexmap", 510 | "slab", 511 | "tokio", 512 | "tokio-util", 513 | "tracing", 514 | ] 515 | 516 | [[package]] 517 | name = "hashbrown" 518 | version = "0.12.3" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 521 | 522 | [[package]] 523 | name = "hdrhistogram" 524 | version = "7.5.2" 525 | source = "registry+https://github.com/rust-lang/crates.io-index" 526 | checksum = "7f19b9f54f7c7f55e31401bb647626ce0cf0f67b0004982ce815b3ee72a02aa8" 527 | dependencies = [ 528 | "base64 0.13.1", 529 | "byteorder", 530 | "flate2", 531 | "nom", 532 | "num-traits", 533 | ] 534 | 535 | [[package]] 536 | name = "headers" 537 | version = "0.3.8" 538 | source = "registry+https://github.com/rust-lang/crates.io-index" 539 | checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" 540 | dependencies = [ 541 | "base64 0.13.1", 542 | "bitflags", 543 | "bytes", 544 | "headers-core", 545 | "http", 546 | "httpdate", 547 | "mime", 548 | "sha1", 549 | ] 550 | 551 | [[package]] 552 | name = "headers-core" 553 | version = "0.2.0" 554 | source = "registry+https://github.com/rust-lang/crates.io-index" 555 | checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" 556 | dependencies = [ 557 | "http", 558 | ] 559 | 560 | [[package]] 561 | name = "hermit-abi" 562 | version = "0.2.6" 563 | source = "registry+https://github.com/rust-lang/crates.io-index" 564 | checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" 565 | dependencies = [ 566 | "libc", 567 | ] 568 | 569 | [[package]] 570 | name = "http" 571 | version = "0.2.9" 572 | source = "registry+https://github.com/rust-lang/crates.io-index" 573 | checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" 574 | dependencies = [ 575 | "bytes", 576 | "fnv", 577 | "itoa", 578 | ] 579 | 580 | [[package]] 581 | name = "http-body" 582 | version = "0.4.5" 583 | source = "registry+https://github.com/rust-lang/crates.io-index" 584 | checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" 585 | dependencies = [ 586 | "bytes", 587 | "http", 588 | "pin-project-lite", 589 | ] 590 | 591 | [[package]] 592 | name = "http-range-header" 593 | version = "0.3.0" 594 | source = "registry+https://github.com/rust-lang/crates.io-index" 595 | checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" 596 | 597 | [[package]] 598 | name = "httparse" 599 | version = "1.8.0" 600 | source = "registry+https://github.com/rust-lang/crates.io-index" 601 | checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" 602 | 603 | [[package]] 604 | name = "httpdate" 605 | version = "1.0.2" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" 608 | 609 | [[package]] 610 | name = "humantime" 611 | version = "2.1.0" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" 614 | 615 | [[package]] 616 | name = "hyper" 617 | version = "0.14.25" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" 620 | dependencies = [ 621 | "bytes", 622 | "futures-channel", 623 | "futures-core", 624 | "futures-util", 625 | "h2", 626 | "http", 627 | "http-body", 628 | "httparse", 629 | "httpdate", 630 | "itoa", 631 | "pin-project-lite", 632 | "socket2", 633 | "tokio", 634 | "tower-service", 635 | "tracing", 636 | "want", 637 | ] 638 | 639 | [[package]] 640 | name = "hyper-timeout" 641 | version = "0.4.1" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" 644 | dependencies = [ 645 | "hyper", 646 | "pin-project-lite", 647 | "tokio", 648 | "tokio-io-timeout", 649 | ] 650 | 651 | [[package]] 652 | name = "idna" 653 | version = "0.3.0" 654 | source = "registry+https://github.com/rust-lang/crates.io-index" 655 | checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" 656 | dependencies = [ 657 | "unicode-bidi", 658 | "unicode-normalization", 659 | ] 660 | 661 | [[package]] 662 | name = "indenter" 663 | version = "0.3.3" 664 | source = "registry+https://github.com/rust-lang/crates.io-index" 665 | checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" 666 | 667 | [[package]] 668 | name = "indexmap" 669 | version = "1.9.3" 670 | source = "registry+https://github.com/rust-lang/crates.io-index" 671 | checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" 672 | dependencies = [ 673 | "autocfg", 674 | "hashbrown", 675 | ] 676 | 677 | [[package]] 678 | name = "itertools" 679 | version = "0.10.5" 680 | source = "registry+https://github.com/rust-lang/crates.io-index" 681 | checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" 682 | dependencies = [ 683 | "either", 684 | ] 685 | 686 | [[package]] 687 | name = "itoa" 688 | version = "1.0.6" 689 | source = "registry+https://github.com/rust-lang/crates.io-index" 690 | checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" 691 | 692 | [[package]] 693 | name = "lazy_static" 694 | version = "1.4.0" 695 | source = "registry+https://github.com/rust-lang/crates.io-index" 696 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 697 | 698 | [[package]] 699 | name = "libc" 700 | version = "0.2.141" 701 | source = "registry+https://github.com/rust-lang/crates.io-index" 702 | checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" 703 | 704 | [[package]] 705 | name = "listenfd" 706 | version = "1.0.1" 707 | source = "registry+https://github.com/rust-lang/crates.io-index" 708 | checksum = "e0500463acd96259d219abb05dc57e5a076ef04b2db9a2112846929b5f174c96" 709 | dependencies = [ 710 | "libc", 711 | "uuid", 712 | "winapi", 713 | ] 714 | 715 | [[package]] 716 | name = "lock_api" 717 | version = "0.4.9" 718 | source = "registry+https://github.com/rust-lang/crates.io-index" 719 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 720 | dependencies = [ 721 | "autocfg", 722 | "scopeguard", 723 | ] 724 | 725 | [[package]] 726 | name = "log" 727 | version = "0.4.17" 728 | source = "registry+https://github.com/rust-lang/crates.io-index" 729 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 730 | dependencies = [ 731 | "cfg-if", 732 | ] 733 | 734 | [[package]] 735 | name = "mach" 736 | version = "0.1.2" 737 | source = "registry+https://github.com/rust-lang/crates.io-index" 738 | checksum = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" 739 | dependencies = [ 740 | "libc", 741 | ] 742 | 743 | [[package]] 744 | name = "mach" 745 | version = "0.3.2" 746 | source = "registry+https://github.com/rust-lang/crates.io-index" 747 | checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" 748 | dependencies = [ 749 | "libc", 750 | ] 751 | 752 | [[package]] 753 | name = "matchers" 754 | version = "0.1.0" 755 | source = "registry+https://github.com/rust-lang/crates.io-index" 756 | checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" 757 | dependencies = [ 758 | "regex-automata", 759 | ] 760 | 761 | [[package]] 762 | name = "matchit" 763 | version = "0.7.0" 764 | source = "registry+https://github.com/rust-lang/crates.io-index" 765 | checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" 766 | 767 | [[package]] 768 | name = "memchr" 769 | version = "2.5.0" 770 | source = "registry+https://github.com/rust-lang/crates.io-index" 771 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 772 | 773 | [[package]] 774 | name = "memoffset" 775 | version = "0.7.1" 776 | source = "registry+https://github.com/rust-lang/crates.io-index" 777 | checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" 778 | dependencies = [ 779 | "autocfg", 780 | ] 781 | 782 | [[package]] 783 | name = "mime" 784 | version = "0.3.17" 785 | source = "registry+https://github.com/rust-lang/crates.io-index" 786 | checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" 787 | 788 | [[package]] 789 | name = "mime_guess" 790 | version = "2.0.4" 791 | source = "registry+https://github.com/rust-lang/crates.io-index" 792 | checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" 793 | dependencies = [ 794 | "mime", 795 | "unicase", 796 | ] 797 | 798 | [[package]] 799 | name = "minimal-lexical" 800 | version = "0.2.1" 801 | source = "registry+https://github.com/rust-lang/crates.io-index" 802 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 803 | 804 | [[package]] 805 | name = "miniz_oxide" 806 | version = "0.6.2" 807 | source = "registry+https://github.com/rust-lang/crates.io-index" 808 | checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" 809 | dependencies = [ 810 | "adler", 811 | ] 812 | 813 | [[package]] 814 | name = "mio" 815 | version = "0.8.6" 816 | source = "registry+https://github.com/rust-lang/crates.io-index" 817 | checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" 818 | dependencies = [ 819 | "libc", 820 | "log", 821 | "wasi", 822 | "windows-sys", 823 | ] 824 | 825 | [[package]] 826 | name = "mio-serial" 827 | version = "5.0.5" 828 | source = "registry+https://github.com/rust-lang/crates.io-index" 829 | checksum = "20a4c60ca5c9c0e114b3bd66ff4aa5f9b2b175442be51ca6c4365d687a97a2ac" 830 | dependencies = [ 831 | "log", 832 | "mio", 833 | "nix 0.26.2", 834 | "serialport", 835 | "winapi", 836 | ] 837 | 838 | [[package]] 839 | name = "nix" 840 | version = "0.24.3" 841 | source = "registry+https://github.com/rust-lang/crates.io-index" 842 | checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" 843 | dependencies = [ 844 | "bitflags", 845 | "cfg-if", 846 | "libc", 847 | ] 848 | 849 | [[package]] 850 | name = "nix" 851 | version = "0.26.2" 852 | source = "registry+https://github.com/rust-lang/crates.io-index" 853 | checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" 854 | dependencies = [ 855 | "bitflags", 856 | "cfg-if", 857 | "libc", 858 | "memoffset", 859 | "pin-utils", 860 | "static_assertions", 861 | ] 862 | 863 | [[package]] 864 | name = "nom" 865 | version = "7.1.3" 866 | source = "registry+https://github.com/rust-lang/crates.io-index" 867 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" 868 | dependencies = [ 869 | "memchr", 870 | "minimal-lexical", 871 | ] 872 | 873 | [[package]] 874 | name = "nu-ansi-term" 875 | version = "0.46.0" 876 | source = "registry+https://github.com/rust-lang/crates.io-index" 877 | checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" 878 | dependencies = [ 879 | "overload", 880 | "winapi", 881 | ] 882 | 883 | [[package]] 884 | name = "num-traits" 885 | version = "0.2.15" 886 | source = "registry+https://github.com/rust-lang/crates.io-index" 887 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 888 | dependencies = [ 889 | "autocfg", 890 | ] 891 | 892 | [[package]] 893 | name = "num_cpus" 894 | version = "1.15.0" 895 | source = "registry+https://github.com/rust-lang/crates.io-index" 896 | checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" 897 | dependencies = [ 898 | "hermit-abi", 899 | "libc", 900 | ] 901 | 902 | [[package]] 903 | name = "object" 904 | version = "0.30.3" 905 | source = "registry+https://github.com/rust-lang/crates.io-index" 906 | checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" 907 | dependencies = [ 908 | "memchr", 909 | ] 910 | 911 | [[package]] 912 | name = "once_cell" 913 | version = "1.17.1" 914 | source = "registry+https://github.com/rust-lang/crates.io-index" 915 | checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" 916 | 917 | [[package]] 918 | name = "overload" 919 | version = "0.1.1" 920 | source = "registry+https://github.com/rust-lang/crates.io-index" 921 | checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" 922 | 923 | [[package]] 924 | name = "owo-colors" 925 | version = "3.5.0" 926 | source = "registry+https://github.com/rust-lang/crates.io-index" 927 | checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" 928 | 929 | [[package]] 930 | name = "parking_lot" 931 | version = "0.12.1" 932 | source = "registry+https://github.com/rust-lang/crates.io-index" 933 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 934 | dependencies = [ 935 | "lock_api", 936 | "parking_lot_core", 937 | ] 938 | 939 | [[package]] 940 | name = "parking_lot_core" 941 | version = "0.9.7" 942 | source = "registry+https://github.com/rust-lang/crates.io-index" 943 | checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" 944 | dependencies = [ 945 | "cfg-if", 946 | "libc", 947 | "redox_syscall", 948 | "smallvec", 949 | "windows-sys", 950 | ] 951 | 952 | [[package]] 953 | name = "percent-encoding" 954 | version = "2.2.0" 955 | source = "registry+https://github.com/rust-lang/crates.io-index" 956 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 957 | 958 | [[package]] 959 | name = "pin-project" 960 | version = "1.0.12" 961 | source = "registry+https://github.com/rust-lang/crates.io-index" 962 | checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" 963 | dependencies = [ 964 | "pin-project-internal", 965 | ] 966 | 967 | [[package]] 968 | name = "pin-project-internal" 969 | version = "1.0.12" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" 972 | dependencies = [ 973 | "proc-macro2", 974 | "quote", 975 | "syn 1.0.109", 976 | ] 977 | 978 | [[package]] 979 | name = "pin-project-lite" 980 | version = "0.2.9" 981 | source = "registry+https://github.com/rust-lang/crates.io-index" 982 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 983 | 984 | [[package]] 985 | name = "pin-utils" 986 | version = "0.1.0" 987 | source = "registry+https://github.com/rust-lang/crates.io-index" 988 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 989 | 990 | [[package]] 991 | name = "ppv-lite86" 992 | version = "0.2.17" 993 | source = "registry+https://github.com/rust-lang/crates.io-index" 994 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 995 | 996 | [[package]] 997 | name = "pretty-hex" 998 | version = "0.3.0" 999 | source = "registry+https://github.com/rust-lang/crates.io-index" 1000 | checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5" 1001 | 1002 | [[package]] 1003 | name = "proc-macro2" 1004 | version = "1.0.56" 1005 | source = "registry+https://github.com/rust-lang/crates.io-index" 1006 | checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" 1007 | dependencies = [ 1008 | "unicode-ident", 1009 | ] 1010 | 1011 | [[package]] 1012 | name = "prost" 1013 | version = "0.11.8" 1014 | source = "registry+https://github.com/rust-lang/crates.io-index" 1015 | checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" 1016 | dependencies = [ 1017 | "bytes", 1018 | "prost-derive", 1019 | ] 1020 | 1021 | [[package]] 1022 | name = "prost-derive" 1023 | version = "0.11.8" 1024 | source = "registry+https://github.com/rust-lang/crates.io-index" 1025 | checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" 1026 | dependencies = [ 1027 | "anyhow", 1028 | "itertools", 1029 | "proc-macro2", 1030 | "quote", 1031 | "syn 1.0.109", 1032 | ] 1033 | 1034 | [[package]] 1035 | name = "prost-types" 1036 | version = "0.11.8" 1037 | source = "registry+https://github.com/rust-lang/crates.io-index" 1038 | checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88" 1039 | dependencies = [ 1040 | "prost", 1041 | ] 1042 | 1043 | [[package]] 1044 | name = "quote" 1045 | version = "1.0.26" 1046 | source = "registry+https://github.com/rust-lang/crates.io-index" 1047 | checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" 1048 | dependencies = [ 1049 | "proc-macro2", 1050 | ] 1051 | 1052 | [[package]] 1053 | name = "rand" 1054 | version = "0.8.5" 1055 | source = "registry+https://github.com/rust-lang/crates.io-index" 1056 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 1057 | dependencies = [ 1058 | "libc", 1059 | "rand_chacha", 1060 | "rand_core", 1061 | ] 1062 | 1063 | [[package]] 1064 | name = "rand_chacha" 1065 | version = "0.3.1" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 1068 | dependencies = [ 1069 | "ppv-lite86", 1070 | "rand_core", 1071 | ] 1072 | 1073 | [[package]] 1074 | name = "rand_core" 1075 | version = "0.6.4" 1076 | source = "registry+https://github.com/rust-lang/crates.io-index" 1077 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 1078 | dependencies = [ 1079 | "getrandom", 1080 | ] 1081 | 1082 | [[package]] 1083 | name = "redox_syscall" 1084 | version = "0.2.16" 1085 | source = "registry+https://github.com/rust-lang/crates.io-index" 1086 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 1087 | dependencies = [ 1088 | "bitflags", 1089 | ] 1090 | 1091 | [[package]] 1092 | name = "regex" 1093 | version = "1.7.3" 1094 | source = "registry+https://github.com/rust-lang/crates.io-index" 1095 | checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" 1096 | dependencies = [ 1097 | "aho-corasick", 1098 | "memchr", 1099 | "regex-syntax", 1100 | ] 1101 | 1102 | [[package]] 1103 | name = "regex-automata" 1104 | version = "0.1.10" 1105 | source = "registry+https://github.com/rust-lang/crates.io-index" 1106 | checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" 1107 | dependencies = [ 1108 | "regex-syntax", 1109 | ] 1110 | 1111 | [[package]] 1112 | name = "regex-syntax" 1113 | version = "0.6.29" 1114 | source = "registry+https://github.com/rust-lang/crates.io-index" 1115 | checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" 1116 | 1117 | [[package]] 1118 | name = "rustc-demangle" 1119 | version = "0.1.22" 1120 | source = "registry+https://github.com/rust-lang/crates.io-index" 1121 | checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" 1122 | 1123 | [[package]] 1124 | name = "rustversion" 1125 | version = "1.0.12" 1126 | source = "registry+https://github.com/rust-lang/crates.io-index" 1127 | checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" 1128 | 1129 | [[package]] 1130 | name = "ryu" 1131 | version = "1.0.13" 1132 | source = "registry+https://github.com/rust-lang/crates.io-index" 1133 | checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" 1134 | 1135 | [[package]] 1136 | name = "scopeguard" 1137 | version = "1.1.0" 1138 | source = "registry+https://github.com/rust-lang/crates.io-index" 1139 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 1140 | 1141 | [[package]] 1142 | name = "sender-sink" 1143 | version = "0.2.0" 1144 | source = "registry+https://github.com/rust-lang/crates.io-index" 1145 | checksum = "2b83a4d5ddaf7f8f705370014d280bb17cc809d04fef967d82d685f3a5dba4a9" 1146 | dependencies = [ 1147 | "futures", 1148 | "tokio", 1149 | ] 1150 | 1151 | [[package]] 1152 | name = "serde" 1153 | version = "1.0.159" 1154 | source = "registry+https://github.com/rust-lang/crates.io-index" 1155 | checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" 1156 | dependencies = [ 1157 | "serde_derive", 1158 | ] 1159 | 1160 | [[package]] 1161 | name = "serde_derive" 1162 | version = "1.0.159" 1163 | source = "registry+https://github.com/rust-lang/crates.io-index" 1164 | checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" 1165 | dependencies = [ 1166 | "proc-macro2", 1167 | "quote", 1168 | "syn 2.0.13", 1169 | ] 1170 | 1171 | [[package]] 1172 | name = "serde_json" 1173 | version = "1.0.95" 1174 | source = "registry+https://github.com/rust-lang/crates.io-index" 1175 | checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" 1176 | dependencies = [ 1177 | "itoa", 1178 | "ryu", 1179 | "serde", 1180 | ] 1181 | 1182 | [[package]] 1183 | name = "serde_path_to_error" 1184 | version = "0.1.11" 1185 | source = "registry+https://github.com/rust-lang/crates.io-index" 1186 | checksum = "f7f05c1d5476066defcdfacce1f52fc3cae3af1d3089727100c02ae92e5abbe0" 1187 | dependencies = [ 1188 | "serde", 1189 | ] 1190 | 1191 | [[package]] 1192 | name = "serde_urlencoded" 1193 | version = "0.7.1" 1194 | source = "registry+https://github.com/rust-lang/crates.io-index" 1195 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 1196 | dependencies = [ 1197 | "form_urlencoded", 1198 | "itoa", 1199 | "ryu", 1200 | "serde", 1201 | ] 1202 | 1203 | [[package]] 1204 | name = "serial-ws-bridge" 1205 | version = "0.1.0" 1206 | dependencies = [ 1207 | "axum", 1208 | "bytes", 1209 | "color-eyre", 1210 | "console-subscriber", 1211 | "eyre", 1212 | "futures", 1213 | "futures-util", 1214 | "glob", 1215 | "listenfd", 1216 | "pretty-hex", 1217 | "sender-sink", 1218 | "serde_json", 1219 | "tokio", 1220 | "tokio-serial", 1221 | "tokio-stream", 1222 | "tokio-util", 1223 | "tower-http", 1224 | "tracing", 1225 | "tracing-subscriber", 1226 | ] 1227 | 1228 | [[package]] 1229 | name = "serialport" 1230 | version = "4.2.0" 1231 | source = "registry+https://github.com/rust-lang/crates.io-index" 1232 | checksum = "aab92efb5cf60ad310548bc3f16fa6b0d950019cb7ed8ff41968c3d03721cf12" 1233 | dependencies = [ 1234 | "CoreFoundation-sys", 1235 | "IOKit-sys", 1236 | "bitflags", 1237 | "cfg-if", 1238 | "mach 0.3.2", 1239 | "nix 0.24.3", 1240 | "regex", 1241 | "winapi", 1242 | ] 1243 | 1244 | [[package]] 1245 | name = "sha1" 1246 | version = "0.10.5" 1247 | source = "registry+https://github.com/rust-lang/crates.io-index" 1248 | checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" 1249 | dependencies = [ 1250 | "cfg-if", 1251 | "cpufeatures", 1252 | "digest", 1253 | ] 1254 | 1255 | [[package]] 1256 | name = "sharded-slab" 1257 | version = "0.1.4" 1258 | source = "registry+https://github.com/rust-lang/crates.io-index" 1259 | checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" 1260 | dependencies = [ 1261 | "lazy_static", 1262 | ] 1263 | 1264 | [[package]] 1265 | name = "signal-hook-registry" 1266 | version = "1.4.1" 1267 | source = "registry+https://github.com/rust-lang/crates.io-index" 1268 | checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" 1269 | dependencies = [ 1270 | "libc", 1271 | ] 1272 | 1273 | [[package]] 1274 | name = "slab" 1275 | version = "0.4.8" 1276 | source = "registry+https://github.com/rust-lang/crates.io-index" 1277 | checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" 1278 | dependencies = [ 1279 | "autocfg", 1280 | ] 1281 | 1282 | [[package]] 1283 | name = "smallvec" 1284 | version = "1.10.0" 1285 | source = "registry+https://github.com/rust-lang/crates.io-index" 1286 | checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" 1287 | 1288 | [[package]] 1289 | name = "socket2" 1290 | version = "0.4.9" 1291 | source = "registry+https://github.com/rust-lang/crates.io-index" 1292 | checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" 1293 | dependencies = [ 1294 | "libc", 1295 | "winapi", 1296 | ] 1297 | 1298 | [[package]] 1299 | name = "static_assertions" 1300 | version = "1.1.0" 1301 | source = "registry+https://github.com/rust-lang/crates.io-index" 1302 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 1303 | 1304 | [[package]] 1305 | name = "syn" 1306 | version = "1.0.109" 1307 | source = "registry+https://github.com/rust-lang/crates.io-index" 1308 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1309 | dependencies = [ 1310 | "proc-macro2", 1311 | "quote", 1312 | "unicode-ident", 1313 | ] 1314 | 1315 | [[package]] 1316 | name = "syn" 1317 | version = "2.0.13" 1318 | source = "registry+https://github.com/rust-lang/crates.io-index" 1319 | checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" 1320 | dependencies = [ 1321 | "proc-macro2", 1322 | "quote", 1323 | "unicode-ident", 1324 | ] 1325 | 1326 | [[package]] 1327 | name = "sync_wrapper" 1328 | version = "0.1.2" 1329 | source = "registry+https://github.com/rust-lang/crates.io-index" 1330 | checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" 1331 | 1332 | [[package]] 1333 | name = "thiserror" 1334 | version = "1.0.40" 1335 | source = "registry+https://github.com/rust-lang/crates.io-index" 1336 | checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" 1337 | dependencies = [ 1338 | "thiserror-impl", 1339 | ] 1340 | 1341 | [[package]] 1342 | name = "thiserror-impl" 1343 | version = "1.0.40" 1344 | source = "registry+https://github.com/rust-lang/crates.io-index" 1345 | checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" 1346 | dependencies = [ 1347 | "proc-macro2", 1348 | "quote", 1349 | "syn 2.0.13", 1350 | ] 1351 | 1352 | [[package]] 1353 | name = "thread_local" 1354 | version = "1.1.7" 1355 | source = "registry+https://github.com/rust-lang/crates.io-index" 1356 | checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" 1357 | dependencies = [ 1358 | "cfg-if", 1359 | "once_cell", 1360 | ] 1361 | 1362 | [[package]] 1363 | name = "tinyvec" 1364 | version = "1.6.0" 1365 | source = "registry+https://github.com/rust-lang/crates.io-index" 1366 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 1367 | dependencies = [ 1368 | "tinyvec_macros", 1369 | ] 1370 | 1371 | [[package]] 1372 | name = "tinyvec_macros" 1373 | version = "0.1.1" 1374 | source = "registry+https://github.com/rust-lang/crates.io-index" 1375 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 1376 | 1377 | [[package]] 1378 | name = "tokio" 1379 | version = "1.27.0" 1380 | source = "registry+https://github.com/rust-lang/crates.io-index" 1381 | checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" 1382 | dependencies = [ 1383 | "autocfg", 1384 | "bytes", 1385 | "libc", 1386 | "mio", 1387 | "num_cpus", 1388 | "parking_lot", 1389 | "pin-project-lite", 1390 | "signal-hook-registry", 1391 | "socket2", 1392 | "tokio-macros", 1393 | "tracing", 1394 | "windows-sys", 1395 | ] 1396 | 1397 | [[package]] 1398 | name = "tokio-io-timeout" 1399 | version = "1.2.0" 1400 | source = "registry+https://github.com/rust-lang/crates.io-index" 1401 | checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" 1402 | dependencies = [ 1403 | "pin-project-lite", 1404 | "tokio", 1405 | ] 1406 | 1407 | [[package]] 1408 | name = "tokio-macros" 1409 | version = "2.0.0" 1410 | source = "registry+https://github.com/rust-lang/crates.io-index" 1411 | checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" 1412 | dependencies = [ 1413 | "proc-macro2", 1414 | "quote", 1415 | "syn 2.0.13", 1416 | ] 1417 | 1418 | [[package]] 1419 | name = "tokio-serial" 1420 | version = "5.4.4" 1421 | source = "registry+https://github.com/rust-lang/crates.io-index" 1422 | checksum = "aa6e2e4cf0520a99c5f87d5abb24172b5bd220de57c3181baaaa5440540c64aa" 1423 | dependencies = [ 1424 | "cfg-if", 1425 | "futures", 1426 | "log", 1427 | "mio-serial", 1428 | "tokio", 1429 | ] 1430 | 1431 | [[package]] 1432 | name = "tokio-stream" 1433 | version = "0.1.12" 1434 | source = "registry+https://github.com/rust-lang/crates.io-index" 1435 | checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" 1436 | dependencies = [ 1437 | "futures-core", 1438 | "pin-project-lite", 1439 | "tokio", 1440 | "tokio-util", 1441 | ] 1442 | 1443 | [[package]] 1444 | name = "tokio-tungstenite" 1445 | version = "0.18.0" 1446 | source = "registry+https://github.com/rust-lang/crates.io-index" 1447 | checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" 1448 | dependencies = [ 1449 | "futures-util", 1450 | "log", 1451 | "tokio", 1452 | "tungstenite", 1453 | ] 1454 | 1455 | [[package]] 1456 | name = "tokio-util" 1457 | version = "0.7.7" 1458 | source = "registry+https://github.com/rust-lang/crates.io-index" 1459 | checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" 1460 | dependencies = [ 1461 | "bytes", 1462 | "futures-core", 1463 | "futures-sink", 1464 | "pin-project-lite", 1465 | "tokio", 1466 | "tracing", 1467 | ] 1468 | 1469 | [[package]] 1470 | name = "tonic" 1471 | version = "0.8.3" 1472 | source = "registry+https://github.com/rust-lang/crates.io-index" 1473 | checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" 1474 | dependencies = [ 1475 | "async-stream", 1476 | "async-trait", 1477 | "axum", 1478 | "base64 0.13.1", 1479 | "bytes", 1480 | "futures-core", 1481 | "futures-util", 1482 | "h2", 1483 | "http", 1484 | "http-body", 1485 | "hyper", 1486 | "hyper-timeout", 1487 | "percent-encoding", 1488 | "pin-project", 1489 | "prost", 1490 | "prost-derive", 1491 | "tokio", 1492 | "tokio-stream", 1493 | "tokio-util", 1494 | "tower", 1495 | "tower-layer", 1496 | "tower-service", 1497 | "tracing", 1498 | "tracing-futures", 1499 | ] 1500 | 1501 | [[package]] 1502 | name = "tower" 1503 | version = "0.4.13" 1504 | source = "registry+https://github.com/rust-lang/crates.io-index" 1505 | checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" 1506 | dependencies = [ 1507 | "futures-core", 1508 | "futures-util", 1509 | "indexmap", 1510 | "pin-project", 1511 | "pin-project-lite", 1512 | "rand", 1513 | "slab", 1514 | "tokio", 1515 | "tokio-util", 1516 | "tower-layer", 1517 | "tower-service", 1518 | "tracing", 1519 | ] 1520 | 1521 | [[package]] 1522 | name = "tower-http" 1523 | version = "0.4.0" 1524 | source = "registry+https://github.com/rust-lang/crates.io-index" 1525 | checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" 1526 | dependencies = [ 1527 | "bitflags", 1528 | "bytes", 1529 | "futures-core", 1530 | "futures-util", 1531 | "http", 1532 | "http-body", 1533 | "http-range-header", 1534 | "httpdate", 1535 | "mime", 1536 | "mime_guess", 1537 | "percent-encoding", 1538 | "pin-project-lite", 1539 | "tokio", 1540 | "tokio-util", 1541 | "tower-layer", 1542 | "tower-service", 1543 | "tracing", 1544 | ] 1545 | 1546 | [[package]] 1547 | name = "tower-layer" 1548 | version = "0.3.2" 1549 | source = "registry+https://github.com/rust-lang/crates.io-index" 1550 | checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" 1551 | 1552 | [[package]] 1553 | name = "tower-service" 1554 | version = "0.3.2" 1555 | source = "registry+https://github.com/rust-lang/crates.io-index" 1556 | checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" 1557 | 1558 | [[package]] 1559 | name = "tracing" 1560 | version = "0.1.37" 1561 | source = "registry+https://github.com/rust-lang/crates.io-index" 1562 | checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" 1563 | dependencies = [ 1564 | "cfg-if", 1565 | "log", 1566 | "pin-project-lite", 1567 | "tracing-attributes", 1568 | "tracing-core", 1569 | ] 1570 | 1571 | [[package]] 1572 | name = "tracing-attributes" 1573 | version = "0.1.23" 1574 | source = "registry+https://github.com/rust-lang/crates.io-index" 1575 | checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" 1576 | dependencies = [ 1577 | "proc-macro2", 1578 | "quote", 1579 | "syn 1.0.109", 1580 | ] 1581 | 1582 | [[package]] 1583 | name = "tracing-core" 1584 | version = "0.1.30" 1585 | source = "registry+https://github.com/rust-lang/crates.io-index" 1586 | checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" 1587 | dependencies = [ 1588 | "once_cell", 1589 | "valuable", 1590 | ] 1591 | 1592 | [[package]] 1593 | name = "tracing-error" 1594 | version = "0.2.0" 1595 | source = "registry+https://github.com/rust-lang/crates.io-index" 1596 | checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" 1597 | dependencies = [ 1598 | "tracing", 1599 | "tracing-subscriber", 1600 | ] 1601 | 1602 | [[package]] 1603 | name = "tracing-futures" 1604 | version = "0.2.5" 1605 | source = "registry+https://github.com/rust-lang/crates.io-index" 1606 | checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" 1607 | dependencies = [ 1608 | "pin-project", 1609 | "tracing", 1610 | ] 1611 | 1612 | [[package]] 1613 | name = "tracing-log" 1614 | version = "0.1.3" 1615 | source = "registry+https://github.com/rust-lang/crates.io-index" 1616 | checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" 1617 | dependencies = [ 1618 | "lazy_static", 1619 | "log", 1620 | "tracing-core", 1621 | ] 1622 | 1623 | [[package]] 1624 | name = "tracing-subscriber" 1625 | version = "0.3.16" 1626 | source = "registry+https://github.com/rust-lang/crates.io-index" 1627 | checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" 1628 | dependencies = [ 1629 | "matchers", 1630 | "nu-ansi-term", 1631 | "once_cell", 1632 | "regex", 1633 | "sharded-slab", 1634 | "smallvec", 1635 | "thread_local", 1636 | "tracing", 1637 | "tracing-core", 1638 | "tracing-log", 1639 | ] 1640 | 1641 | [[package]] 1642 | name = "try-lock" 1643 | version = "0.2.4" 1644 | source = "registry+https://github.com/rust-lang/crates.io-index" 1645 | checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" 1646 | 1647 | [[package]] 1648 | name = "tungstenite" 1649 | version = "0.18.0" 1650 | source = "registry+https://github.com/rust-lang/crates.io-index" 1651 | checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" 1652 | dependencies = [ 1653 | "base64 0.13.1", 1654 | "byteorder", 1655 | "bytes", 1656 | "http", 1657 | "httparse", 1658 | "log", 1659 | "rand", 1660 | "sha1", 1661 | "thiserror", 1662 | "url", 1663 | "utf-8", 1664 | ] 1665 | 1666 | [[package]] 1667 | name = "typenum" 1668 | version = "1.16.0" 1669 | source = "registry+https://github.com/rust-lang/crates.io-index" 1670 | checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" 1671 | 1672 | [[package]] 1673 | name = "unicase" 1674 | version = "2.6.0" 1675 | source = "registry+https://github.com/rust-lang/crates.io-index" 1676 | checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" 1677 | dependencies = [ 1678 | "version_check", 1679 | ] 1680 | 1681 | [[package]] 1682 | name = "unicode-bidi" 1683 | version = "0.3.13" 1684 | source = "registry+https://github.com/rust-lang/crates.io-index" 1685 | checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" 1686 | 1687 | [[package]] 1688 | name = "unicode-ident" 1689 | version = "1.0.8" 1690 | source = "registry+https://github.com/rust-lang/crates.io-index" 1691 | checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" 1692 | 1693 | [[package]] 1694 | name = "unicode-normalization" 1695 | version = "0.1.22" 1696 | source = "registry+https://github.com/rust-lang/crates.io-index" 1697 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 1698 | dependencies = [ 1699 | "tinyvec", 1700 | ] 1701 | 1702 | [[package]] 1703 | name = "url" 1704 | version = "2.3.1" 1705 | source = "registry+https://github.com/rust-lang/crates.io-index" 1706 | checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" 1707 | dependencies = [ 1708 | "form_urlencoded", 1709 | "idna", 1710 | "percent-encoding", 1711 | ] 1712 | 1713 | [[package]] 1714 | name = "utf-8" 1715 | version = "0.7.6" 1716 | source = "registry+https://github.com/rust-lang/crates.io-index" 1717 | checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" 1718 | 1719 | [[package]] 1720 | name = "uuid" 1721 | version = "1.3.0" 1722 | source = "registry+https://github.com/rust-lang/crates.io-index" 1723 | checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" 1724 | 1725 | [[package]] 1726 | name = "valuable" 1727 | version = "0.1.0" 1728 | source = "registry+https://github.com/rust-lang/crates.io-index" 1729 | checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" 1730 | 1731 | [[package]] 1732 | name = "version_check" 1733 | version = "0.9.4" 1734 | source = "registry+https://github.com/rust-lang/crates.io-index" 1735 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1736 | 1737 | [[package]] 1738 | name = "want" 1739 | version = "0.3.0" 1740 | source = "registry+https://github.com/rust-lang/crates.io-index" 1741 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 1742 | dependencies = [ 1743 | "log", 1744 | "try-lock", 1745 | ] 1746 | 1747 | [[package]] 1748 | name = "wasi" 1749 | version = "0.11.0+wasi-snapshot-preview1" 1750 | source = "registry+https://github.com/rust-lang/crates.io-index" 1751 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1752 | 1753 | [[package]] 1754 | name = "winapi" 1755 | version = "0.3.9" 1756 | source = "registry+https://github.com/rust-lang/crates.io-index" 1757 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1758 | dependencies = [ 1759 | "winapi-i686-pc-windows-gnu", 1760 | "winapi-x86_64-pc-windows-gnu", 1761 | ] 1762 | 1763 | [[package]] 1764 | name = "winapi-i686-pc-windows-gnu" 1765 | version = "0.4.0" 1766 | source = "registry+https://github.com/rust-lang/crates.io-index" 1767 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1768 | 1769 | [[package]] 1770 | name = "winapi-x86_64-pc-windows-gnu" 1771 | version = "0.4.0" 1772 | source = "registry+https://github.com/rust-lang/crates.io-index" 1773 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1774 | 1775 | [[package]] 1776 | name = "windows-sys" 1777 | version = "0.45.0" 1778 | source = "registry+https://github.com/rust-lang/crates.io-index" 1779 | checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 1780 | dependencies = [ 1781 | "windows-targets", 1782 | ] 1783 | 1784 | [[package]] 1785 | name = "windows-targets" 1786 | version = "0.42.2" 1787 | source = "registry+https://github.com/rust-lang/crates.io-index" 1788 | checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 1789 | dependencies = [ 1790 | "windows_aarch64_gnullvm", 1791 | "windows_aarch64_msvc", 1792 | "windows_i686_gnu", 1793 | "windows_i686_msvc", 1794 | "windows_x86_64_gnu", 1795 | "windows_x86_64_gnullvm", 1796 | "windows_x86_64_msvc", 1797 | ] 1798 | 1799 | [[package]] 1800 | name = "windows_aarch64_gnullvm" 1801 | version = "0.42.2" 1802 | source = "registry+https://github.com/rust-lang/crates.io-index" 1803 | checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 1804 | 1805 | [[package]] 1806 | name = "windows_aarch64_msvc" 1807 | version = "0.42.2" 1808 | source = "registry+https://github.com/rust-lang/crates.io-index" 1809 | checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 1810 | 1811 | [[package]] 1812 | name = "windows_i686_gnu" 1813 | version = "0.42.2" 1814 | source = "registry+https://github.com/rust-lang/crates.io-index" 1815 | checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 1816 | 1817 | [[package]] 1818 | name = "windows_i686_msvc" 1819 | version = "0.42.2" 1820 | source = "registry+https://github.com/rust-lang/crates.io-index" 1821 | checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 1822 | 1823 | [[package]] 1824 | name = "windows_x86_64_gnu" 1825 | version = "0.42.2" 1826 | source = "registry+https://github.com/rust-lang/crates.io-index" 1827 | checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 1828 | 1829 | [[package]] 1830 | name = "windows_x86_64_gnullvm" 1831 | version = "0.42.2" 1832 | source = "registry+https://github.com/rust-lang/crates.io-index" 1833 | checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 1834 | 1835 | [[package]] 1836 | name = "windows_x86_64_msvc" 1837 | version = "0.42.2" 1838 | source = "registry+https://github.com/rust-lang/crates.io-index" 1839 | checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 1840 | -------------------------------------------------------------------------------- /serial-ws-bridge/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "serial-ws-bridge" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | axum = { version = "0.6.12", features = ["ws", "headers"] } 10 | bytes = "1.4.0" 11 | color-eyre = "0.6.2" 12 | console-subscriber = "0.1.8" 13 | eyre = "0.6.8" 14 | futures = "0.3.28" 15 | futures-util = "0.3.28" 16 | glob = "0.3.1" 17 | listenfd = "1.0.1" 18 | pretty-hex = "0.3.0" 19 | sender-sink = "0.2.0" 20 | serde_json = "1.0.95" 21 | tokio = { version = "1.27.0", features = ["full"] } 22 | tokio-serial = "5.4.4" 23 | tokio-stream = { version = "0.1.12", features = ["sync"] } 24 | tokio-util = { version = "0.7.7", features = ["codec"] } 25 | tower-http = { version = "0.4.0", features = ["cors", "fs", "trace"] } 26 | tracing = "0.1.37" 27 | tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } 28 | -------------------------------------------------------------------------------- /serial-ws-bridge/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | RUST_LOG=info,serial_ws_bridge=debug cargo run -- "$1" 3 | -------------------------------------------------------------------------------- /serial-ws-bridge/src/main.rs: -------------------------------------------------------------------------------- 1 | use bytes::Bytes; 2 | use futures::{stream::StreamExt, SinkExt, TryStreamExt}; 3 | use listenfd::ListenFd; 4 | use pretty_hex::pretty_hex; 5 | use sender_sink::wrappers::UnboundedSenderSink; 6 | use std::{ 7 | env, 8 | io::{self, ErrorKind}, 9 | net::SocketAddr, 10 | sync::Arc, 11 | time::Duration, 12 | }; 13 | use tokio_serial::SerialStream; 14 | 15 | use tokio::{ 16 | sync::{ 17 | broadcast, 18 | mpsc::{self, UnboundedSender}, 19 | }, 20 | time::sleep, 21 | }; 22 | use tokio_stream::wrappers::{BroadcastStream, UnboundedReceiverStream}; 23 | use tokio_util::codec::Decoder; 24 | use tower_http::{ 25 | cors::CorsLayer, 26 | trace::{DefaultMakeSpan, TraceLayer}, 27 | }; 28 | use tracing::{debug, error, info, warn}; 29 | 30 | use axum::{ 31 | extract::{ 32 | ws::{self, Message, WebSocket, WebSocketUpgrade}, 33 | DefaultBodyLimit, Extension, TypedHeader, 34 | }, 35 | headers::UserAgent, 36 | http::{ 37 | header::{AUTHORIZATION, CONTENT_TYPE}, 38 | Method, 39 | }, 40 | response::IntoResponse, 41 | routing::{get, post}, 42 | Router, 43 | }; 44 | 45 | mod serial; 46 | 47 | type ServerMessage = Vec; 48 | struct AppState { 49 | to_websocket: broadcast::Sender, 50 | to_serial: broadcast::Sender, 51 | from_serial_tx: UnboundedSender, 52 | } 53 | impl AppState { 54 | fn new( 55 | to_websocket: broadcast::Sender, 56 | to_serial: broadcast::Sender, 57 | from_serial_tx: UnboundedSender, 58 | ) -> Self { 59 | Self { 60 | to_websocket, 61 | to_serial, 62 | from_serial_tx, 63 | } 64 | } 65 | } 66 | 67 | #[tokio::main] 68 | async fn main() -> eyre::Result<()> { 69 | color_eyre::install()?; 70 | tracing_subscriber::fmt::init(); 71 | info!("start"); 72 | 73 | let mut args = env::args(); 74 | 75 | let serial_dev = args.nth(1); 76 | 77 | // the rx part is created later 78 | let (to_websocket_tx, _) = broadcast::channel(100); 79 | // the rx part is created later 80 | let (to_serial_tx, _) = broadcast::channel(100); 81 | let (from_serial_tx, from_serial_rx) = mpsc::unbounded_channel(); 82 | 83 | // TODO can't do that, apparently :| 84 | // let forward_serial_to_websocket = 85 | // UnboundedReceiverStream::new(from_serial_rx).forward(to_websocket_tx.into()); 86 | 87 | let _forward_serial_to_websocket_task = { 88 | let to_websocket_tx = to_websocket_tx.clone(); 89 | tokio::spawn(async move { 90 | let mut from_serial_rx = UnboundedReceiverStream::new(from_serial_rx); 91 | while let Some(item) = from_serial_rx.next().await { 92 | debug!("serial>ws {}", pretty_hex(&item)); 93 | // TODO ok() 94 | to_websocket_tx.send(item).ok(); 95 | } 96 | }) 97 | }; 98 | 99 | let app_state = Arc::new(AppState::new(to_websocket_tx, to_serial_tx, from_serial_tx)); 100 | let _serial_task = tokio::spawn(uart_launcher_loop(serial_dev, app_state.clone())); 101 | let app = Router::new() 102 | .route("/", get(websocket_handler)) 103 | .route("/backdoor", post(backdoor_handler)) 104 | // ELF or whatever else you want to upload size limit 105 | .layer(DefaultBodyLimit::max(15 * 1024 * 1024)) 106 | .layer(Extension(app_state.clone())) 107 | // logging so we can see whats going on 108 | .layer( 109 | TraceLayer::new_for_http() 110 | .make_span_with(DefaultMakeSpan::default().include_headers(true)), 111 | ) 112 | // of corse 113 | .layer( 114 | CorsLayer::new() 115 | .allow_headers(vec![CONTENT_TYPE, AUTHORIZATION]) 116 | .allow_origin(tower_http::cors::Any) 117 | .allow_methods(vec![Method::GET, Method::POST, Method::PUT, Method::DELETE]), 118 | ); 119 | 120 | let mut listenfd = ListenFd::from_env(); 121 | 122 | let port = 3030; 123 | let server = if let Some(l) = listenfd.take_tcp_listener(0).unwrap() { 124 | axum::Server::from_tcp(l)? 125 | } else { 126 | let addr = SocketAddr::from(([127, 0, 0, 1], port)); 127 | axum::Server::bind(&addr) 128 | }; 129 | 130 | debug!("startup complete: {:?}", server); 131 | info!("listening on port {port}"); 132 | server.serve(app.into_make_service()).await.unwrap(); 133 | Ok(()) 134 | } 135 | 136 | async fn backdoor_handler( 137 | TypedHeader(_user_agent): TypedHeader, 138 | Extension(state): Extension>, 139 | body: Bytes, 140 | ) -> impl IntoResponse { 141 | let _msg = pretty_hex(&body); 142 | debug!("got a sneaky update"); 143 | match state.to_websocket.send(body.into()) { 144 | Ok(_) => "OK", 145 | Err(_) => "nobody home?", 146 | } 147 | } 148 | async fn websocket_handler( 149 | TypedHeader(user_agent): TypedHeader, 150 | ws: WebSocketUpgrade, 151 | Extension(state): Extension>, 152 | ) -> impl IntoResponse { 153 | debug!("User-Agent: {:?}", user_agent); 154 | ws.on_upgrade(|socket| do_websocket(socket, state, user_agent)) 155 | } 156 | async fn do_websocket(stream: WebSocket, state: Arc, _user_agent: UserAgent) { 157 | let (mut to_websocket_tx, mut from_websocket_rx) = stream.split(); 158 | 159 | let to_websocket_rx = state.to_websocket.subscribe(); 160 | let mut to_websocket_rx = tokio_stream::wrappers::BroadcastStream::new(to_websocket_rx); 161 | 162 | let to_serial_tx = state.to_serial.clone(); 163 | 164 | // BUG/workaround in dioxus websocket context - need to initialize state with a server hello 165 | to_websocket_tx 166 | .send(ws::Message::Text("hello".to_string())) 167 | .await 168 | .ok(); 169 | 170 | // This task will receive messages from the mcu and send them to broadcast subscribers ("browser windows"). 171 | // TODO would rather use .forward() 172 | let mut send_task = tokio::spawn(async move { 173 | loop { 174 | while let Some(to_ws) = to_websocket_rx.next().await { 175 | match to_ws { 176 | Ok(to_ws) => { 177 | // TODO ok() 178 | to_websocket_tx.send(ws::Message::Binary(to_ws)).await.ok(); 179 | } 180 | Err(e) => { 181 | error!("{e:?}"); 182 | break; 183 | } 184 | } 185 | } 186 | } 187 | }); 188 | 189 | // This task will receive messages from browser window(s) and send them to the mcu. 190 | // TODO would rather use .forward() 191 | let mut recv_task = tokio::spawn(async move { 192 | while let Some(Ok(msg)) = from_websocket_rx.next().await { 193 | let client_message: Option, eyre::Report>> = match &msg { 194 | Message::Text(text) => { 195 | debug!("Text"); 196 | Some(Ok(text.as_bytes().into())) 197 | } 198 | Message::Binary(data) => { 199 | debug!("Binary"); 200 | Some(Ok(data.clone())) 201 | } 202 | Message::Ping(_) => { 203 | debug!("PING"); 204 | None 205 | } 206 | Message::Pong(_) => { 207 | debug!("PONG"); 208 | None 209 | } 210 | Message::Close(_) => { 211 | info!("ws::Message::Close - bye"); 212 | None 213 | } 214 | }; 215 | match client_message { 216 | Some(Err(oh_no)) => { 217 | error!("could not parse client message: {:#?} {:#?}", msg, oh_no) 218 | } 219 | Some(Ok(client_message)) => { 220 | let msg = pretty_hex(&client_message); 221 | debug!("ws>serial: {msg}"); 222 | 223 | // TODO ok() 224 | to_serial_tx.send(client_message).ok(); 225 | } 226 | _ => {} 227 | } 228 | } 229 | }); 230 | 231 | // If any one of the tasks exit, abort the other. 232 | tokio::select! { 233 | _ = (&mut send_task) => recv_task.abort(), 234 | _ = (&mut recv_task) => send_task.abort(), 235 | }; 236 | 237 | debug!("client disconnected"); 238 | } 239 | 240 | async fn uart_inner( 241 | stream: SerialStream, 242 | to_serial_tx: broadcast::Sender, 243 | from_serial_tx: UnboundedSender, 244 | ) -> eyre::Result<()> { 245 | let (tx, rx) = serial::NullSepCodec.framed(stream).split(); 246 | // TODO weird error stuff 247 | let to_serial_rx = BroadcastStream::new(to_serial_tx.subscribe()).map_err(|e| { 248 | let inner_error = format!("{e:?}"); 249 | io::Error::new(ErrorKind::Other, inner_error) 250 | }); 251 | 252 | let to_serial_stream = to_serial_rx.forward(tx); 253 | 254 | let from_serial_tx: UnboundedSenderSink<_> = from_serial_tx.into(); 255 | 256 | // TODO weird error stuff 257 | let from_serial_stream = rx.forward(from_serial_tx.sink_map_err(|e| { 258 | let inner_error = format!("{e:?}"); 259 | io::Error::new(ErrorKind::Other, inner_error) 260 | })); 261 | 262 | tokio::try_join!(to_serial_stream, from_serial_stream)?; 263 | 264 | Ok(()) 265 | } 266 | 267 | async fn uart_launcher_loop(port_name: Option, app_state: Arc) { 268 | let retry_interval = Duration::from_millis(1000); 269 | let to_serial = app_state.to_serial.clone(); 270 | let from_serial_tx = app_state.from_serial_tx.clone(); 271 | loop { 272 | match serial::open_tty(port_name.clone()) { 273 | Ok(stream) => { 274 | if let Err(e) = uart_inner(stream, to_serial.clone(), from_serial_tx.clone()).await 275 | { 276 | warn!("serial device threw up: {e:?}"); 277 | } 278 | } 279 | Err(e) => { 280 | warn!("could not open a serial device: {e:?}"); 281 | } 282 | } 283 | 284 | sleep(retry_interval).await 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /serial-ws-bridge/src/serial.rs: -------------------------------------------------------------------------------- 1 | use bytes::BytesMut; 2 | use tokio_serial::{SerialPortBuilderExt, SerialStream}; 3 | use tokio_util::codec::{Decoder, Encoder}; 4 | use tracing::{debug, info, warn}; 5 | 6 | pub(crate) struct NullSepCodec; 7 | 8 | impl Decoder for NullSepCodec { 9 | type Item = Vec; 10 | type Error = std::io::Error; 11 | 12 | fn decode(&mut self, src: &mut BytesMut) -> Result, Self::Error> { 13 | let null = src.as_ref().iter().position(|b| *b == b'\0'); 14 | if let Some(n) = null { 15 | let chunk = src.split_to(n + 1); 16 | return Ok(Some(chunk.into())); 17 | } 18 | Ok(None) 19 | } 20 | } 21 | 22 | impl Encoder> for NullSepCodec { 23 | type Error = std::io::Error; 24 | 25 | fn encode(&mut self, item: Vec, dst: &mut BytesMut) -> Result<(), Self::Error> { 26 | dst.extend_from_slice(&item); 27 | Ok(()) 28 | } 29 | } 30 | 31 | pub(crate) fn open_tty(arg: Option) -> eyre::Result { 32 | // filter out macos builtin bluetooth "ports" 33 | let available_ports = tokio_serial::available_ports()?; 34 | let auto_ports = || { 35 | available_ports 36 | .iter() 37 | .map(|port| port.port_name.clone()) 38 | .filter(|port| !port.to_lowercase().contains("bluetooth")) 39 | .collect() 40 | }; 41 | 42 | // ensure arg is not empty 43 | let ports = match arg.as_deref() { 44 | Some("") => auto_ports(), 45 | Some(port) => vec![port.to_string()], 46 | None => auto_ports(), 47 | }; 48 | 49 | for port in ports { 50 | info!("opening {port}"); 51 | match tokio_serial::new(&port, 115_200).open_native_async() { 52 | Ok(stream) => { 53 | // the tokio-serial example sets this, but it doesn't seem to get along with e.g. micropython's cdc 54 | // #[cfg(unix)] 55 | // stream 56 | // .set_exclusive(false) 57 | // .expect("Unable to set serial port exclusive to false"); 58 | debug!("ok!"); 59 | return Ok(stream); 60 | } 61 | Err(e) => warn!("error opening {port}: {e}"), 62 | } 63 | } 64 | 65 | Err(eyre::eyre!("could not find a usable serial port")) 66 | } 67 | -------------------------------------------------------------------------------- /src/bin/encode.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | env, 3 | io::{self, ErrorKind, Write}, 4 | }; 5 | 6 | use embedded_web_ui::{Command, Log}; 7 | 8 | pub fn main() -> Result<(), Box> { 9 | let path = env::args() 10 | .nth(1) 11 | .ok_or(std::io::Error::new(ErrorKind::Other, "need a file name"))?; 12 | let content = std::fs::read(path)?; 13 | 14 | let commands = vec![Command::Log(Log::Elf(&content))]; 15 | let ser = postcard::to_allocvec_cobs(&commands)?; 16 | io::stdout().write_all(&ser)?; 17 | Ok(()) 18 | } 19 | -------------------------------------------------------------------------------- /src/bin/json.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | env, 3 | io::{self, ErrorKind, Write}, 4 | }; 5 | 6 | use embedded_web_ui::{BarData, Command, Input, Widget, WidgetKind, CHART_BARS, UI}; 7 | 8 | pub fn main() -> Result<(), Box> { 9 | let ui = [ 10 | Command::Reset, 11 | Widget { 12 | kind: WidgetKind::Button, 13 | label: "LED on".into(), 14 | id: 1, 15 | } 16 | .into(), 17 | Widget { 18 | kind: WidgetKind::Button, 19 | label: "LED off".into(), 20 | id: 2, 21 | } 22 | .into(), 23 | Widget { 24 | kind: WidgetKind::Button, 25 | label: "give data".into(), 26 | id: 3, 27 | } 28 | .into(), 29 | UI::Break.into(), 30 | Widget { 31 | kind: WidgetKind::Slider, 32 | label: "slidos".into(), 33 | id: 4, 34 | } 35 | .into(), 36 | UI::Break.into(), 37 | Widget { 38 | kind: WidgetKind::BarChart, 39 | label: "a bar chart".into(), 40 | id: 5, 41 | } 42 | .into(), 43 | ]; 44 | 45 | let ser = serde_json::to_vec(&ui)?; 46 | 47 | io::stdout().write_all(&ser)?; 48 | Ok(()) 49 | } 50 | -------------------------------------------------------------------------------- /src/bin/sizes.rs: -------------------------------------------------------------------------------- 1 | use embedded_web_ui::BarData; 2 | 3 | fn main() -> Result<(), Box> { 4 | let mut vals = heapless::Vec::new(); 5 | for i in 0u8..64 { 6 | vals.push(i).unwrap(); 7 | } 8 | let data = BarData { id: 1, vals }; 9 | let ser = postcard::to_allocvec_cobs(&data)?; 10 | println!("{}", ser.len()); 11 | Ok(()) 12 | } 13 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(not(any(test, feature = "std")), no_std)] 2 | 3 | // TODO defmt & std are mutually exclusive, should somehow express this 4 | #[cfg(feature = "defmt")] 5 | use defmt::Format; 6 | 7 | use serde::{Deserialize, Serialize}; 8 | pub type Id = u16; 9 | pub type ChartTime = u16; 10 | pub type ChartVal = u8; 11 | pub type SliderVal = u8; 12 | pub const CHART_BARS: usize = 64; 13 | 14 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 15 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 16 | #[cfg_attr(all(feature = "defmt", not(feature = "std")), derive(Format))] 17 | pub enum Log<'a> { 18 | Elf(&'a [u8]), 19 | Packet(&'a [u8]), 20 | } 21 | 22 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 23 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 24 | #[cfg_attr(all(feature = "defmt", not(feature = "std")), derive(Format))] 25 | pub enum Command<'a> { 26 | #[serde(borrow)] 27 | Log(Log<'a>), 28 | Reset, 29 | UI(UI), 30 | TimeSeriesData(TimeSeriesData), 31 | BarData(BarData), 32 | } 33 | 34 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 35 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 36 | #[cfg_attr(feature = "defmt", derive(Format))] 37 | pub enum Input { 38 | Click(Id), 39 | Slider(Id, SliderVal), 40 | } 41 | 42 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 43 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 44 | #[cfg_attr(feature = "defmt", derive(Format))] 45 | pub enum UI { 46 | Widget(Widget), 47 | Break, 48 | } 49 | 50 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 51 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 52 | #[cfg_attr(feature = "defmt", derive(Format))] 53 | pub struct TimeSeriesData { 54 | pub id: Id, 55 | pub time: ChartTime, 56 | pub val: ChartVal, 57 | } 58 | 59 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 60 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 61 | #[cfg_attr(feature = "defmt", derive(Format))] 62 | pub struct BarData { 63 | pub id: Id, 64 | pub vals: heapless::Vec, 65 | } 66 | 67 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 68 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 69 | #[cfg_attr(feature = "defmt", derive(Format))] 70 | pub enum UIInput { 71 | Button(Id), 72 | Slider(Id, SliderVal), 73 | } 74 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 75 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 76 | #[cfg_attr(feature = "defmt", derive(Format))] 77 | pub struct Widget { 78 | pub kind: WidgetKind, 79 | pub label: heapless::String<32>, 80 | pub id: Id, 81 | } 82 | 83 | #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] 84 | #[cfg_attr(feature = "std", derive(Debug, Hash))] 85 | #[cfg_attr(feature = "defmt", derive(Format))] 86 | pub enum WidgetKind { 87 | TimeSeriesChart, 88 | BarChart, 89 | Button, 90 | Slider, 91 | } 92 | 93 | impl<'a> From for Command<'a> { 94 | fn from(value: Widget) -> Self { 95 | Command::UI(UI::Widget(value)) 96 | } 97 | } 98 | 99 | impl<'a> From for Command<'a> { 100 | fn from(value: UI) -> Self { 101 | match value { 102 | UI::Widget(w) => w.into(), 103 | UI::Break => Command::UI(UI::Break), 104 | } 105 | } 106 | } 107 | 108 | #[cfg(test)] 109 | mod tests { 110 | use super::*; 111 | 112 | #[test] 113 | fn it_works() { 114 | // cool 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /stm32f4-app/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] 2 | # replace STM32F429ZITx with your chip as listed in `probe-run --list-chips` 3 | runner = "probe-run --chip STM32F411CEUx" 4 | 5 | [build] 6 | target = "thumbv7em-none-eabi" 7 | 8 | [env] 9 | DEFMT_LOG = "trace" 10 | -------------------------------------------------------------------------------- /stm32f4-app/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "as-slice" 7 | version = "0.1.5" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" 10 | dependencies = [ 11 | "generic-array 0.12.4", 12 | "generic-array 0.13.3", 13 | "generic-array 0.14.7", 14 | "stable_deref_trait", 15 | ] 16 | 17 | [[package]] 18 | name = "as-slice" 19 | version = "0.2.1" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" 22 | dependencies = [ 23 | "stable_deref_trait", 24 | ] 25 | 26 | [[package]] 27 | name = "atomic-polyfill" 28 | version = "0.1.11" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" 31 | dependencies = [ 32 | "critical-section", 33 | ] 34 | 35 | [[package]] 36 | name = "atomic-polyfill" 37 | version = "1.0.2" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "c314e70d181aa6053b26e3f7fbf86d1dfff84f816a6175b967666b3506ef7289" 40 | dependencies = [ 41 | "critical-section", 42 | ] 43 | 44 | [[package]] 45 | name = "atomic-pool" 46 | version = "1.0.1" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | checksum = "58c5fc22e05ec2884db458bf307dc7b278c9428888d2b6e6fad9c0ae7804f5f6" 49 | dependencies = [ 50 | "as-slice 0.1.5", 51 | "as-slice 0.2.1", 52 | "atomic-polyfill 1.0.2", 53 | "stable_deref_trait", 54 | ] 55 | 56 | [[package]] 57 | name = "autocfg" 58 | version = "1.1.0" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 61 | 62 | [[package]] 63 | name = "bare-metal" 64 | version = "0.2.5" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" 67 | dependencies = [ 68 | "rustc_version 0.2.3", 69 | ] 70 | 71 | [[package]] 72 | name = "bitfield" 73 | version = "0.13.2" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" 76 | 77 | [[package]] 78 | name = "bitflags" 79 | version = "1.3.2" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 82 | 83 | [[package]] 84 | name = "bxcan" 85 | version = "0.7.0" 86 | source = "registry+https://github.com/rust-lang/crates.io-index" 87 | checksum = "40ac3d0c0a542d0ab5521211f873f62706a7136df415676f676d347e5a41dd80" 88 | dependencies = [ 89 | "bitflags", 90 | "defmt", 91 | "embedded-hal 0.2.7", 92 | "nb 1.1.0", 93 | "vcell", 94 | ] 95 | 96 | [[package]] 97 | name = "byteorder" 98 | version = "1.4.3" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 101 | 102 | [[package]] 103 | name = "cfg-if" 104 | version = "1.0.0" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 107 | 108 | [[package]] 109 | name = "cobs" 110 | version = "0.2.3" 111 | source = "registry+https://github.com/rust-lang/crates.io-index" 112 | checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" 113 | 114 | [[package]] 115 | name = "cortex-m" 116 | version = "0.7.7" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" 119 | dependencies = [ 120 | "bare-metal", 121 | "bitfield", 122 | "critical-section", 123 | "embedded-hal 0.2.7", 124 | "volatile-register", 125 | ] 126 | 127 | [[package]] 128 | name = "cortex-m-rt" 129 | version = "0.7.3" 130 | source = "registry+https://github.com/rust-lang/crates.io-index" 131 | checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1" 132 | dependencies = [ 133 | "cortex-m-rt-macros", 134 | ] 135 | 136 | [[package]] 137 | name = "cortex-m-rt-macros" 138 | version = "0.7.0" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7" 141 | dependencies = [ 142 | "proc-macro2", 143 | "quote", 144 | "syn 1.0.109", 145 | ] 146 | 147 | [[package]] 148 | name = "critical-section" 149 | version = "1.1.1" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" 152 | 153 | [[package]] 154 | name = "darling" 155 | version = "0.13.4" 156 | source = "registry+https://github.com/rust-lang/crates.io-index" 157 | checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" 158 | dependencies = [ 159 | "darling_core", 160 | "darling_macro", 161 | ] 162 | 163 | [[package]] 164 | name = "darling_core" 165 | version = "0.13.4" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" 168 | dependencies = [ 169 | "fnv", 170 | "ident_case", 171 | "proc-macro2", 172 | "quote", 173 | "strsim", 174 | "syn 1.0.109", 175 | ] 176 | 177 | [[package]] 178 | name = "darling_macro" 179 | version = "0.13.4" 180 | source = "registry+https://github.com/rust-lang/crates.io-index" 181 | checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" 182 | dependencies = [ 183 | "darling_core", 184 | "quote", 185 | "syn 1.0.109", 186 | ] 187 | 188 | [[package]] 189 | name = "defmt" 190 | version = "0.3.2" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "d3a0ae7494d9bff013d7b89471f4c424356a71e9752e0c78abe7e6c608a16bb3" 193 | dependencies = [ 194 | "bitflags", 195 | "defmt-macros", 196 | ] 197 | 198 | [[package]] 199 | name = "defmt-macros" 200 | version = "0.3.4" 201 | source = "registry+https://github.com/rust-lang/crates.io-index" 202 | checksum = "82610855c67a4dc36299cc6bfcf140f329e4f013582531c7ba7d32512ddabc47" 203 | dependencies = [ 204 | "defmt-parser", 205 | "proc-macro-error", 206 | "proc-macro2", 207 | "quote", 208 | "syn 1.0.109", 209 | ] 210 | 211 | [[package]] 212 | name = "defmt-parser" 213 | version = "0.3.2" 214 | source = "registry+https://github.com/rust-lang/crates.io-index" 215 | checksum = "e15e994575e38332cf4a2dc9dc745ff6a65695d37a41e00efadd57fcd42c1ba4" 216 | dependencies = [ 217 | "thiserror", 218 | ] 219 | 220 | [[package]] 221 | name = "defmt-rtt" 222 | version = "0.4.0" 223 | source = "registry+https://github.com/rust-lang/crates.io-index" 224 | checksum = "609923761264dd99ed9c7d209718cda4631c5fe84668e0f0960124cbb844c49f" 225 | dependencies = [ 226 | "critical-section", 227 | "defmt", 228 | ] 229 | 230 | [[package]] 231 | name = "embassy-cortex-m" 232 | version = "0.1.0" 233 | dependencies = [ 234 | "atomic-polyfill 1.0.2", 235 | "cfg-if", 236 | "cortex-m", 237 | "critical-section", 238 | "embassy-executor", 239 | "embassy-hal-common", 240 | "embassy-macros", 241 | "embassy-sync", 242 | ] 243 | 244 | [[package]] 245 | name = "embassy-embedded-hal" 246 | version = "0.1.0" 247 | dependencies = [ 248 | "defmt", 249 | "embassy-sync", 250 | "embedded-hal 0.2.7", 251 | "embedded-hal 1.0.0-alpha.9", 252 | "embedded-hal-async", 253 | "embedded-storage", 254 | "embedded-storage-async", 255 | "nb 1.1.0", 256 | ] 257 | 258 | [[package]] 259 | name = "embassy-executor" 260 | version = "0.1.1" 261 | dependencies = [ 262 | "atomic-polyfill 1.0.2", 263 | "cortex-m", 264 | "critical-section", 265 | "defmt", 266 | "embassy-macros", 267 | "embassy-time", 268 | "futures-util", 269 | "static_cell", 270 | ] 271 | 272 | [[package]] 273 | name = "embassy-futures" 274 | version = "0.1.0" 275 | 276 | [[package]] 277 | name = "embassy-hal-common" 278 | version = "0.1.0" 279 | dependencies = [ 280 | "defmt", 281 | "num-traits", 282 | ] 283 | 284 | [[package]] 285 | name = "embassy-macros" 286 | version = "0.1.0" 287 | dependencies = [ 288 | "darling", 289 | "proc-macro2", 290 | "quote", 291 | "syn 1.0.109", 292 | ] 293 | 294 | [[package]] 295 | name = "embassy-net" 296 | version = "0.1.0" 297 | dependencies = [ 298 | "as-slice 0.2.1", 299 | "atomic-polyfill 1.0.2", 300 | "atomic-pool", 301 | "defmt", 302 | "embassy-hal-common", 303 | "embassy-net-driver", 304 | "embassy-sync", 305 | "embassy-time", 306 | "embedded-io", 307 | "embedded-nal-async", 308 | "futures", 309 | "generic-array 0.14.7", 310 | "heapless", 311 | "managed", 312 | "smoltcp", 313 | "stable_deref_trait", 314 | ] 315 | 316 | [[package]] 317 | name = "embassy-net-driver" 318 | version = "0.1.0" 319 | dependencies = [ 320 | "defmt", 321 | ] 322 | 323 | [[package]] 324 | name = "embassy-net-driver-channel" 325 | version = "0.1.0" 326 | dependencies = [ 327 | "embassy-futures", 328 | "embassy-net-driver", 329 | "embassy-sync", 330 | ] 331 | 332 | [[package]] 333 | name = "embassy-stm32" 334 | version = "0.1.0" 335 | dependencies = [ 336 | "atomic-polyfill 1.0.2", 337 | "bxcan", 338 | "cfg-if", 339 | "cortex-m", 340 | "cortex-m-rt", 341 | "critical-section", 342 | "defmt", 343 | "embassy-cortex-m", 344 | "embassy-embedded-hal", 345 | "embassy-executor", 346 | "embassy-futures", 347 | "embassy-hal-common", 348 | "embassy-net-driver", 349 | "embassy-sync", 350 | "embassy-time", 351 | "embassy-usb-driver", 352 | "embedded-hal 0.2.7", 353 | "embedded-hal 1.0.0-alpha.9", 354 | "embedded-hal-async", 355 | "embedded-hal-nb", 356 | "embedded-io", 357 | "embedded-storage", 358 | "futures", 359 | "nb 1.1.0", 360 | "proc-macro2", 361 | "quote", 362 | "rand_core", 363 | "sdio-host", 364 | "seq-macro", 365 | "stm32-fmc", 366 | "stm32-metapac", 367 | "vcell", 368 | ] 369 | 370 | [[package]] 371 | name = "embassy-stm32f4-examples" 372 | version = "0.1.0" 373 | dependencies = [ 374 | "cortex-m", 375 | "cortex-m-rt", 376 | "defmt", 377 | "defmt-rtt", 378 | "embassy-executor", 379 | "embassy-net", 380 | "embassy-stm32", 381 | "embassy-sync", 382 | "embassy-time", 383 | "embassy-usb", 384 | "embedded-hal 0.2.7", 385 | "embedded-io", 386 | "embedded-storage", 387 | "embedded-web-ui", 388 | "futures", 389 | "heapless", 390 | "micromath", 391 | "nb 1.1.0", 392 | "panic-probe", 393 | "postcard", 394 | "rand_core", 395 | "static_cell", 396 | "wyhash", 397 | ] 398 | 399 | [[package]] 400 | name = "embassy-sync" 401 | version = "0.1.0" 402 | dependencies = [ 403 | "cfg-if", 404 | "critical-section", 405 | "defmt", 406 | "embedded-io", 407 | "futures-util", 408 | "heapless", 409 | ] 410 | 411 | [[package]] 412 | name = "embassy-time" 413 | version = "0.1.0" 414 | dependencies = [ 415 | "atomic-polyfill 1.0.2", 416 | "cfg-if", 417 | "critical-section", 418 | "defmt", 419 | "embassy-sync", 420 | "embedded-hal 0.2.7", 421 | "embedded-hal 1.0.0-alpha.9", 422 | "futures-util", 423 | "heapless", 424 | ] 425 | 426 | [[package]] 427 | name = "embassy-usb" 428 | version = "0.1.0" 429 | dependencies = [ 430 | "defmt", 431 | "embassy-futures", 432 | "embassy-net-driver-channel", 433 | "embassy-sync", 434 | "embassy-usb-driver", 435 | "heapless", 436 | "ssmarshal", 437 | "usbd-hid", 438 | ] 439 | 440 | [[package]] 441 | name = "embassy-usb-driver" 442 | version = "0.1.0" 443 | dependencies = [ 444 | "defmt", 445 | ] 446 | 447 | [[package]] 448 | name = "embedded-hal" 449 | version = "0.2.7" 450 | source = "registry+https://github.com/rust-lang/crates.io-index" 451 | checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" 452 | dependencies = [ 453 | "nb 0.1.3", 454 | "void", 455 | ] 456 | 457 | [[package]] 458 | name = "embedded-hal" 459 | version = "1.0.0-alpha.9" 460 | source = "registry+https://github.com/rust-lang/crates.io-index" 461 | checksum = "129b101ddfee640565f7c07b301a31d95aa21e5acef21a491c307139f5fa4c91" 462 | 463 | [[package]] 464 | name = "embedded-hal-async" 465 | version = "0.2.0-alpha.0" 466 | source = "registry+https://github.com/rust-lang/crates.io-index" 467 | checksum = "608a322808d65da06715e03109c0cb69f79a5459af756fba393ab83e875d4969" 468 | dependencies = [ 469 | "embedded-hal 1.0.0-alpha.9", 470 | ] 471 | 472 | [[package]] 473 | name = "embedded-hal-nb" 474 | version = "1.0.0-alpha.1" 475 | source = "registry+https://github.com/rust-lang/crates.io-index" 476 | checksum = "7e0760ec0a3bf76859d5e33f39542af103f157d5b2ecfb00ace56dd461472e3a" 477 | dependencies = [ 478 | "embedded-hal 1.0.0-alpha.9", 479 | "nb 1.1.0", 480 | ] 481 | 482 | [[package]] 483 | name = "embedded-io" 484 | version = "0.4.0" 485 | source = "registry+https://github.com/rust-lang/crates.io-index" 486 | checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" 487 | dependencies = [ 488 | "defmt", 489 | ] 490 | 491 | [[package]] 492 | name = "embedded-nal" 493 | version = "0.6.0" 494 | source = "registry+https://github.com/rust-lang/crates.io-index" 495 | checksum = "db9efecb57ab54fa918730f2874d7d37647169c50fa1357fecb81abee840b113" 496 | dependencies = [ 497 | "heapless", 498 | "nb 1.1.0", 499 | "no-std-net 0.5.0", 500 | ] 501 | 502 | [[package]] 503 | name = "embedded-nal-async" 504 | version = "0.4.0" 505 | source = "registry+https://github.com/rust-lang/crates.io-index" 506 | checksum = "27ce84f518ca912777ec143db235f4d615e3bf8d4e46d507d6ef12daf5b1df98" 507 | dependencies = [ 508 | "embedded-io", 509 | "embedded-nal", 510 | "heapless", 511 | "no-std-net 0.6.0", 512 | ] 513 | 514 | [[package]] 515 | name = "embedded-storage" 516 | version = "0.3.0" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | checksum = "156d7a2fdd98ebbf9ae579cbceca3058cff946e13f8e17b90e3511db0508c723" 519 | 520 | [[package]] 521 | name = "embedded-storage-async" 522 | version = "0.4.0" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | checksum = "052997a894670d0cde873faa7405bc98e2fd29f569d2acd568561bc1c396b35a" 525 | dependencies = [ 526 | "embedded-storage", 527 | ] 528 | 529 | [[package]] 530 | name = "embedded-web-ui" 531 | version = "0.1.0" 532 | dependencies = [ 533 | "defmt", 534 | "heapless", 535 | "serde", 536 | ] 537 | 538 | [[package]] 539 | name = "encode_unicode" 540 | version = "0.3.6" 541 | source = "registry+https://github.com/rust-lang/crates.io-index" 542 | checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" 543 | 544 | [[package]] 545 | name = "fnv" 546 | version = "1.0.7" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 549 | 550 | [[package]] 551 | name = "futures" 552 | version = "0.3.28" 553 | source = "registry+https://github.com/rust-lang/crates.io-index" 554 | checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" 555 | dependencies = [ 556 | "futures-channel", 557 | "futures-core", 558 | "futures-io", 559 | "futures-sink", 560 | "futures-task", 561 | "futures-util", 562 | ] 563 | 564 | [[package]] 565 | name = "futures-channel" 566 | version = "0.3.28" 567 | source = "registry+https://github.com/rust-lang/crates.io-index" 568 | checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" 569 | dependencies = [ 570 | "futures-core", 571 | "futures-sink", 572 | ] 573 | 574 | [[package]] 575 | name = "futures-core" 576 | version = "0.3.28" 577 | source = "registry+https://github.com/rust-lang/crates.io-index" 578 | checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" 579 | 580 | [[package]] 581 | name = "futures-io" 582 | version = "0.3.28" 583 | source = "registry+https://github.com/rust-lang/crates.io-index" 584 | checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" 585 | 586 | [[package]] 587 | name = "futures-macro" 588 | version = "0.3.28" 589 | source = "registry+https://github.com/rust-lang/crates.io-index" 590 | checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" 591 | dependencies = [ 592 | "proc-macro2", 593 | "quote", 594 | "syn 2.0.13", 595 | ] 596 | 597 | [[package]] 598 | name = "futures-sink" 599 | version = "0.3.28" 600 | source = "registry+https://github.com/rust-lang/crates.io-index" 601 | checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" 602 | 603 | [[package]] 604 | name = "futures-task" 605 | version = "0.3.28" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" 608 | 609 | [[package]] 610 | name = "futures-util" 611 | version = "0.3.28" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" 614 | dependencies = [ 615 | "futures-core", 616 | "futures-macro", 617 | "futures-sink", 618 | "futures-task", 619 | "pin-project-lite", 620 | "pin-utils", 621 | ] 622 | 623 | [[package]] 624 | name = "generic-array" 625 | version = "0.12.4" 626 | source = "registry+https://github.com/rust-lang/crates.io-index" 627 | checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" 628 | dependencies = [ 629 | "typenum", 630 | ] 631 | 632 | [[package]] 633 | name = "generic-array" 634 | version = "0.13.3" 635 | source = "registry+https://github.com/rust-lang/crates.io-index" 636 | checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309" 637 | dependencies = [ 638 | "typenum", 639 | ] 640 | 641 | [[package]] 642 | name = "generic-array" 643 | version = "0.14.7" 644 | source = "registry+https://github.com/rust-lang/crates.io-index" 645 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" 646 | dependencies = [ 647 | "typenum", 648 | "version_check", 649 | ] 650 | 651 | [[package]] 652 | name = "hash32" 653 | version = "0.2.1" 654 | source = "registry+https://github.com/rust-lang/crates.io-index" 655 | checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" 656 | dependencies = [ 657 | "byteorder", 658 | ] 659 | 660 | [[package]] 661 | name = "heapless" 662 | version = "0.7.16" 663 | source = "registry+https://github.com/rust-lang/crates.io-index" 664 | checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" 665 | dependencies = [ 666 | "atomic-polyfill 0.1.11", 667 | "defmt", 668 | "hash32", 669 | "rustc_version 0.4.0", 670 | "serde", 671 | "spin", 672 | "stable_deref_trait", 673 | ] 674 | 675 | [[package]] 676 | name = "ident_case" 677 | version = "1.0.1" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 680 | 681 | [[package]] 682 | name = "lock_api" 683 | version = "0.4.9" 684 | source = "registry+https://github.com/rust-lang/crates.io-index" 685 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 686 | dependencies = [ 687 | "autocfg", 688 | "scopeguard", 689 | ] 690 | 691 | [[package]] 692 | name = "managed" 693 | version = "0.8.0" 694 | source = "registry+https://github.com/rust-lang/crates.io-index" 695 | checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d" 696 | 697 | [[package]] 698 | name = "micromath" 699 | version = "2.0.0" 700 | source = "registry+https://github.com/rust-lang/crates.io-index" 701 | checksum = "39617bc909d64b068dcffd0e3e31679195b5576d0c83fadc52690268cc2b2b55" 702 | 703 | [[package]] 704 | name = "nb" 705 | version = "0.1.3" 706 | source = "registry+https://github.com/rust-lang/crates.io-index" 707 | checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" 708 | dependencies = [ 709 | "nb 1.1.0", 710 | ] 711 | 712 | [[package]] 713 | name = "nb" 714 | version = "1.1.0" 715 | source = "registry+https://github.com/rust-lang/crates.io-index" 716 | checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" 717 | 718 | [[package]] 719 | name = "no-std-net" 720 | version = "0.5.0" 721 | source = "registry+https://github.com/rust-lang/crates.io-index" 722 | checksum = "1bcece43b12349917e096cddfa66107277f123e6c96a5aea78711dc601a47152" 723 | 724 | [[package]] 725 | name = "no-std-net" 726 | version = "0.6.0" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" 729 | 730 | [[package]] 731 | name = "num-traits" 732 | version = "0.2.15" 733 | source = "registry+https://github.com/rust-lang/crates.io-index" 734 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 735 | dependencies = [ 736 | "autocfg", 737 | ] 738 | 739 | [[package]] 740 | name = "panic-probe" 741 | version = "0.3.1" 742 | source = "registry+https://github.com/rust-lang/crates.io-index" 743 | checksum = "aa6fa5645ef5a760cd340eaa92af9c1ce131c8c09e7f8926d8a24b59d26652b9" 744 | dependencies = [ 745 | "cortex-m", 746 | "defmt", 747 | ] 748 | 749 | [[package]] 750 | name = "pin-project-lite" 751 | version = "0.2.9" 752 | source = "registry+https://github.com/rust-lang/crates.io-index" 753 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 754 | 755 | [[package]] 756 | name = "pin-utils" 757 | version = "0.1.0" 758 | source = "registry+https://github.com/rust-lang/crates.io-index" 759 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 760 | 761 | [[package]] 762 | name = "postcard" 763 | version = "1.0.4" 764 | source = "registry+https://github.com/rust-lang/crates.io-index" 765 | checksum = "cfa512cd0d087cc9f99ad30a1bf64795b67871edbead083ffc3a4dfafa59aa00" 766 | dependencies = [ 767 | "cobs", 768 | "defmt", 769 | "heapless", 770 | "serde", 771 | ] 772 | 773 | [[package]] 774 | name = "proc-macro-error" 775 | version = "1.0.4" 776 | source = "registry+https://github.com/rust-lang/crates.io-index" 777 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 778 | dependencies = [ 779 | "proc-macro-error-attr", 780 | "proc-macro2", 781 | "quote", 782 | "syn 1.0.109", 783 | "version_check", 784 | ] 785 | 786 | [[package]] 787 | name = "proc-macro-error-attr" 788 | version = "1.0.4" 789 | source = "registry+https://github.com/rust-lang/crates.io-index" 790 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 791 | dependencies = [ 792 | "proc-macro2", 793 | "quote", 794 | "version_check", 795 | ] 796 | 797 | [[package]] 798 | name = "proc-macro2" 799 | version = "1.0.56" 800 | source = "registry+https://github.com/rust-lang/crates.io-index" 801 | checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" 802 | dependencies = [ 803 | "unicode-ident", 804 | ] 805 | 806 | [[package]] 807 | name = "quote" 808 | version = "1.0.26" 809 | source = "registry+https://github.com/rust-lang/crates.io-index" 810 | checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" 811 | dependencies = [ 812 | "proc-macro2", 813 | ] 814 | 815 | [[package]] 816 | name = "rand_core" 817 | version = "0.6.4" 818 | source = "registry+https://github.com/rust-lang/crates.io-index" 819 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 820 | 821 | [[package]] 822 | name = "rustc_version" 823 | version = "0.2.3" 824 | source = "registry+https://github.com/rust-lang/crates.io-index" 825 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 826 | dependencies = [ 827 | "semver 0.9.0", 828 | ] 829 | 830 | [[package]] 831 | name = "rustc_version" 832 | version = "0.4.0" 833 | source = "registry+https://github.com/rust-lang/crates.io-index" 834 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 835 | dependencies = [ 836 | "semver 1.0.17", 837 | ] 838 | 839 | [[package]] 840 | name = "scopeguard" 841 | version = "1.1.0" 842 | source = "registry+https://github.com/rust-lang/crates.io-index" 843 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 844 | 845 | [[package]] 846 | name = "sdio-host" 847 | version = "0.5.0" 848 | source = "registry+https://github.com/rust-lang/crates.io-index" 849 | checksum = "f93c025f9cfe4c388c328ece47d11a54a823da3b5ad0370b22d95ad47137f85a" 850 | 851 | [[package]] 852 | name = "semver" 853 | version = "0.9.0" 854 | source = "registry+https://github.com/rust-lang/crates.io-index" 855 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 856 | dependencies = [ 857 | "semver-parser", 858 | ] 859 | 860 | [[package]] 861 | name = "semver" 862 | version = "1.0.17" 863 | source = "registry+https://github.com/rust-lang/crates.io-index" 864 | checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" 865 | 866 | [[package]] 867 | name = "semver-parser" 868 | version = "0.7.0" 869 | source = "registry+https://github.com/rust-lang/crates.io-index" 870 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 871 | 872 | [[package]] 873 | name = "seq-macro" 874 | version = "0.3.3" 875 | source = "registry+https://github.com/rust-lang/crates.io-index" 876 | checksum = "e6b44e8fc93a14e66336d230954dda83d18b4605ccace8fe09bc7514a71ad0bc" 877 | 878 | [[package]] 879 | name = "serde" 880 | version = "1.0.159" 881 | source = "registry+https://github.com/rust-lang/crates.io-index" 882 | checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" 883 | dependencies = [ 884 | "serde_derive", 885 | ] 886 | 887 | [[package]] 888 | name = "serde_derive" 889 | version = "1.0.159" 890 | source = "registry+https://github.com/rust-lang/crates.io-index" 891 | checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" 892 | dependencies = [ 893 | "proc-macro2", 894 | "quote", 895 | "syn 2.0.13", 896 | ] 897 | 898 | [[package]] 899 | name = "smoltcp" 900 | version = "0.9.1" 901 | source = "registry+https://github.com/rust-lang/crates.io-index" 902 | checksum = "7e9786ac45091b96f946693e05bfa4d8ca93e2d3341237d97a380107a6b38dea" 903 | dependencies = [ 904 | "bitflags", 905 | "byteorder", 906 | "cfg-if", 907 | "defmt", 908 | "heapless", 909 | "managed", 910 | ] 911 | 912 | [[package]] 913 | name = "spin" 914 | version = "0.9.8" 915 | source = "registry+https://github.com/rust-lang/crates.io-index" 916 | checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" 917 | dependencies = [ 918 | "lock_api", 919 | ] 920 | 921 | [[package]] 922 | name = "ssmarshal" 923 | version = "1.0.0" 924 | source = "registry+https://github.com/rust-lang/crates.io-index" 925 | checksum = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" 926 | dependencies = [ 927 | "encode_unicode", 928 | "serde", 929 | ] 930 | 931 | [[package]] 932 | name = "stable_deref_trait" 933 | version = "1.2.0" 934 | source = "registry+https://github.com/rust-lang/crates.io-index" 935 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" 936 | 937 | [[package]] 938 | name = "static_cell" 939 | version = "1.0.0" 940 | source = "registry+https://github.com/rust-lang/crates.io-index" 941 | checksum = "e4c37c250d21f53fa7165e76e5401d7e6539c211a8d2cf449e3962956a5cc2ce" 942 | dependencies = [ 943 | "atomic-polyfill 1.0.2", 944 | ] 945 | 946 | [[package]] 947 | name = "stm32-fmc" 948 | version = "0.2.4" 949 | source = "registry+https://github.com/rust-lang/crates.io-index" 950 | checksum = "cf16ee9bd5de754482883cf3eac9a49eb862baf1420f55ce408e001705e9ae74" 951 | dependencies = [ 952 | "embedded-hal 0.2.7", 953 | ] 954 | 955 | [[package]] 956 | name = "stm32-metapac" 957 | version = "3.0.0" 958 | source = "registry+https://github.com/rust-lang/crates.io-index" 959 | checksum = "2b1678ae205209ef7b078bbd70976cd282a418981afbd4334494905611ada850" 960 | dependencies = [ 961 | "cortex-m", 962 | "cortex-m-rt", 963 | ] 964 | 965 | [[package]] 966 | name = "strsim" 967 | version = "0.10.0" 968 | source = "registry+https://github.com/rust-lang/crates.io-index" 969 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 970 | 971 | [[package]] 972 | name = "syn" 973 | version = "1.0.109" 974 | source = "registry+https://github.com/rust-lang/crates.io-index" 975 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 976 | dependencies = [ 977 | "proc-macro2", 978 | "quote", 979 | "unicode-ident", 980 | ] 981 | 982 | [[package]] 983 | name = "syn" 984 | version = "2.0.13" 985 | source = "registry+https://github.com/rust-lang/crates.io-index" 986 | checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" 987 | dependencies = [ 988 | "proc-macro2", 989 | "quote", 990 | "unicode-ident", 991 | ] 992 | 993 | [[package]] 994 | name = "thiserror" 995 | version = "1.0.40" 996 | source = "registry+https://github.com/rust-lang/crates.io-index" 997 | checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" 998 | dependencies = [ 999 | "thiserror-impl", 1000 | ] 1001 | 1002 | [[package]] 1003 | name = "thiserror-impl" 1004 | version = "1.0.40" 1005 | source = "registry+https://github.com/rust-lang/crates.io-index" 1006 | checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" 1007 | dependencies = [ 1008 | "proc-macro2", 1009 | "quote", 1010 | "syn 2.0.13", 1011 | ] 1012 | 1013 | [[package]] 1014 | name = "typenum" 1015 | version = "1.16.0" 1016 | source = "registry+https://github.com/rust-lang/crates.io-index" 1017 | checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" 1018 | 1019 | [[package]] 1020 | name = "unicode-ident" 1021 | version = "1.0.8" 1022 | source = "registry+https://github.com/rust-lang/crates.io-index" 1023 | checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" 1024 | 1025 | [[package]] 1026 | name = "usb-device" 1027 | version = "0.2.9" 1028 | source = "registry+https://github.com/rust-lang/crates.io-index" 1029 | checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508" 1030 | 1031 | [[package]] 1032 | name = "usbd-hid" 1033 | version = "0.6.1" 1034 | source = "registry+https://github.com/rust-lang/crates.io-index" 1035 | checksum = "975bd411f4a939986751ea09992a24fa47c4d25c6ed108d04b4c2999a4fd0132" 1036 | dependencies = [ 1037 | "serde", 1038 | "ssmarshal", 1039 | "usb-device", 1040 | "usbd-hid-macros", 1041 | ] 1042 | 1043 | [[package]] 1044 | name = "usbd-hid-descriptors" 1045 | version = "0.1.2" 1046 | source = "registry+https://github.com/rust-lang/crates.io-index" 1047 | checksum = "dcbee8c6735e90894fba04770bc41e11fd3c5256018856e15dc4dd1e6c8a3dd1" 1048 | dependencies = [ 1049 | "bitfield", 1050 | ] 1051 | 1052 | [[package]] 1053 | name = "usbd-hid-macros" 1054 | version = "0.6.0" 1055 | source = "registry+https://github.com/rust-lang/crates.io-index" 1056 | checksum = "261079a9ada015fa1acac7cc73c98559f3a92585e15f508034beccf6a2ab75a2" 1057 | dependencies = [ 1058 | "byteorder", 1059 | "proc-macro2", 1060 | "quote", 1061 | "serde", 1062 | "syn 1.0.109", 1063 | "usbd-hid-descriptors", 1064 | ] 1065 | 1066 | [[package]] 1067 | name = "vcell" 1068 | version = "0.1.3" 1069 | source = "registry+https://github.com/rust-lang/crates.io-index" 1070 | checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" 1071 | 1072 | [[package]] 1073 | name = "version_check" 1074 | version = "0.9.4" 1075 | source = "registry+https://github.com/rust-lang/crates.io-index" 1076 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1077 | 1078 | [[package]] 1079 | name = "void" 1080 | version = "1.0.2" 1081 | source = "registry+https://github.com/rust-lang/crates.io-index" 1082 | checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 1083 | 1084 | [[package]] 1085 | name = "volatile-register" 1086 | version = "0.2.1" 1087 | source = "registry+https://github.com/rust-lang/crates.io-index" 1088 | checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" 1089 | dependencies = [ 1090 | "vcell", 1091 | ] 1092 | 1093 | [[package]] 1094 | name = "wyhash" 1095 | version = "0.5.0" 1096 | source = "registry+https://github.com/rust-lang/crates.io-index" 1097 | checksum = "baf6e163c25e3fac820b4b453185ea2dea3b6a3e0a721d4d23d75bd33734c295" 1098 | dependencies = [ 1099 | "rand_core", 1100 | ] 1101 | -------------------------------------------------------------------------------- /stm32f4-app/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "embassy-stm32f4-examples" 4 | version = "0.1.0" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [dependencies] 8 | embassy-sync = { version = "0.1.0", path = "../../embedded/embassy/embassy-sync", features = [ 9 | "defmt", 10 | ] } 11 | embassy-executor = { version = "0.1.0", path = "../../embedded/embassy/embassy-executor", features = [ 12 | "arch-cortex-m", 13 | "executor-thread", 14 | "executor-interrupt", 15 | "defmt", 16 | "integrated-timers", 17 | "arch-cortex-m", 18 | "executor-thread", 19 | "executor-interrupt", 20 | ] } 21 | embassy-time = { version = "0.1.0", path = "../../embedded/embassy/embassy-time", features = [ 22 | "defmt", 23 | "defmt-timestamp-uptime", 24 | "unstable-traits", 25 | "tick-hz-32_768", 26 | ] } 27 | embassy-stm32 = { version = "0.1.0", path = "../../embedded/embassy/embassy-stm32", features = [ 28 | "nightly", 29 | "unstable-traits", 30 | "defmt", 31 | "stm32f429zi", 32 | "unstable-pac", 33 | "memory-x", 34 | "time-driver-any", 35 | "exti", 36 | ] } 37 | embassy-usb = { version = "0.1.0", path = "../../embedded/embassy/embassy-usb", features = [ 38 | "defmt", 39 | ] } 40 | embassy-net = { version = "0.1.0", path = "../../embedded/embassy/embassy-net", features = [ 41 | "defmt", 42 | "tcp", 43 | "dhcpv4", 44 | "medium-ethernet", 45 | "nightly", 46 | ] } 47 | 48 | defmt = { version = "=0.3.2" } 49 | defmt-rtt = "0.4" 50 | 51 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } 52 | cortex-m-rt = "0.7.0" 53 | embedded-hal = "0.2.6" 54 | embedded-io = "0.4.0" 55 | panic-probe = { version = "0.3", features = ["print-defmt"] } 56 | futures = { version = "0.3.17", default-features = false, features = [ 57 | "async-await", 58 | ] } 59 | heapless = { version = "0.7", default-features = false } 60 | nb = "1.0.0" 61 | embedded-storage = "0.3.0" 62 | micromath = "2.0.0" 63 | static_cell = "1.0" 64 | embedded-web-ui = { path = "..", features = ["defmt"] } 65 | postcard = { version = "1.0.4", features = ["use-defmt"] } 66 | wyhash = "0.5.0" 67 | rand_core = "0.6.4" 68 | 69 | [profile.release] 70 | debug = 2 71 | -------------------------------------------------------------------------------- /stm32f4-app/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("cargo:rustc-link-arg-bins=--nmagic"); 3 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); 4 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); 5 | } 6 | -------------------------------------------------------------------------------- /stm32f4-app/memory.x: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | /* NOTE K = KiBi = 1024 bytes */ 4 | FLASH : ORIGIN = 0x08000000, LENGTH = 512K 5 | RAM : ORIGIN = 0x20000000, LENGTH = 128K 6 | } 7 | 8 | /* This is where the call stack will be allocated. */ 9 | /* The stack is of the full descending type. */ 10 | /* NOTE Do NOT modify `_stack_start` unless you know what you are doing */ 11 | _stack_start = ORIGIN(RAM) + LENGTH(RAM); -------------------------------------------------------------------------------- /stm32f4-app/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly" 3 | components = [ "rust-src", "rustfmt", "llvm-tools-preview" ] 4 | -------------------------------------------------------------------------------- /stm32f4-app/src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![no_main] 3 | #![feature(type_alias_impl_trait)] 4 | #![feature(slice_as_chunks)] 5 | 6 | use defmt::{panic, *}; 7 | use defmt_rtt as _; 8 | use embassy_executor::Spawner; 9 | use embassy_stm32::{ 10 | gpio::{Level, Output, Speed}, 11 | interrupt, 12 | peripherals::PC13, 13 | time::mhz, 14 | usb_otg::{Driver, Instance}, 15 | Config, 16 | }; 17 | use embassy_time::{Duration, Timer}; 18 | use embassy_usb::{ 19 | class::cdc_acm::{CdcAcmClass, State}, 20 | driver::EndpointError, 21 | Builder, 22 | }; 23 | use embedded_web_ui::{BarData, Command, Input, Widget, WidgetKind, CHART_BARS, UI}; 24 | use futures::future::join; 25 | use panic_probe as _; 26 | 27 | #[embassy_executor::main] 28 | async fn main(_spawner: Spawner) { 29 | info!("ohai"); 30 | 31 | let mut config = Config::default(); 32 | config.rcc.pll48 = true; 33 | config.rcc.sys_ck = Some(mhz(48)); 34 | 35 | let p = embassy_stm32::init(config); 36 | 37 | let mut led = Output::new(p.PC13, Level::High, Speed::Low); 38 | 39 | // Create the driver, from the HAL. 40 | let irq = interrupt::take!(OTG_FS); 41 | let mut ep_out_buffer = [0u8; 256]; 42 | let driver = Driver::new_fs(p.USB_OTG_FS, irq, p.PA12, p.PA11, &mut ep_out_buffer); 43 | 44 | // Create embassy-usb Config 45 | let mut config = embassy_usb::Config::new(0xc0de, 0xcafe); 46 | config.manufacturer = Some("Embassy"); 47 | config.product = Some("USB-serial example"); 48 | config.serial_number = Some("12345678"); 49 | 50 | // Required for windows compatiblity. 51 | // https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/kconfig/CONFIG_CDC_ACM_IAD.html#help 52 | config.device_class = 0xEF; 53 | config.device_sub_class = 0x02; 54 | config.device_protocol = 0x01; 55 | config.composite_with_iads = true; 56 | 57 | // Create embassy-usb DeviceBuilder using the driver and config. 58 | // It needs some buffers for building the descriptors. 59 | let mut device_descriptor = [0; 256]; 60 | let mut config_descriptor = [0; 256]; 61 | let mut bos_descriptor = [0; 256]; 62 | let mut control_buf = [0; 64]; 63 | 64 | let mut state = State::new(); 65 | 66 | let mut builder = Builder::new( 67 | driver, 68 | config, 69 | &mut device_descriptor, 70 | &mut config_descriptor, 71 | &mut bos_descriptor, 72 | &mut control_buf, 73 | ); 74 | 75 | // Create classes on the builder. 76 | let mut class = CdcAcmClass::new(&mut builder, &mut state, 64); 77 | 78 | // Build the builder. 79 | let mut usb = builder.build(); 80 | 81 | // Run the USB device. 82 | let usb_fut = usb.run(); 83 | 84 | // Do stuff with the class! 85 | let work_fut = async { 86 | loop { 87 | class.wait_connection().await; 88 | info!("Connected"); 89 | let _ = work(&mut class, &mut led).await; 90 | info!("Disconnected"); 91 | } 92 | }; 93 | 94 | // Run everything concurrently. 95 | // If we had made everything `'static` above instead, we could do this using separate tasks instead. 96 | join(usb_fut, work_fut).await; 97 | } 98 | 99 | struct Disconnected {} 100 | 101 | impl From for Disconnected { 102 | fn from(val: EndpointError) -> Self { 103 | match val { 104 | EndpointError::BufferOverflow => panic!("Buffer overflow"), 105 | EndpointError::Disabled => Disconnected {}, 106 | } 107 | } 108 | } 109 | 110 | async fn write_chunked<'d, T: Instance + 'd>( 111 | data: &[u8], 112 | class: &mut CdcAcmClass<'d, Driver<'d, T>>, 113 | ) -> Result<(), Disconnected> { 114 | let (chunks, rest) = data.as_chunks::<64>(); 115 | for chunk in chunks { 116 | class.write_packet(chunk).await?; 117 | } 118 | class.write_packet(rest).await?; 119 | Ok(()) 120 | } 121 | 122 | async fn work<'d, T: Instance + 'd>( 123 | class: &mut CdcAcmClass<'d, Driver<'d, T>>, 124 | led: &mut Output<'_, PC13>, 125 | ) -> Result<(), Disconnected> { 126 | let ui = [ 127 | Command::Reset, 128 | Widget { 129 | kind: WidgetKind::Button, 130 | label: "LED on".into(), 131 | id: 1, 132 | } 133 | .into(), 134 | Widget { 135 | kind: WidgetKind::Button, 136 | label: "LED off".into(), 137 | id: 2, 138 | } 139 | .into(), 140 | Widget { 141 | kind: WidgetKind::Button, 142 | label: "give data".into(), 143 | id: 3, 144 | } 145 | .into(), 146 | UI::Break.into(), 147 | Widget { 148 | kind: WidgetKind::Slider, 149 | label: "slidos".into(), 150 | id: 4, 151 | } 152 | .into(), 153 | UI::Break.into(), 154 | Widget { 155 | kind: WidgetKind::BarChart, 156 | label: "a bar chart".into(), 157 | id: 5, 158 | } 159 | .into(), 160 | ]; 161 | 162 | // give USB setup some time to settle 163 | Timer::after(Duration::from_secs(1)).await; 164 | 165 | let seed = [0, 1, 3, 3, 7, 0, 0, 0]; 166 | let mut rng = WyRng::from_seed(seed); 167 | 168 | let mut ser_buf = [0; 96]; 169 | let ser = postcard::to_slice_cobs(ui.as_slice(), &mut ser_buf).unwrap(); 170 | write_chunked(&ser, class).await?; 171 | 172 | let mut buf = [0; 64]; 173 | 174 | loop { 175 | let n = class.read_packet(&mut buf).await?; 176 | let data = &mut buf[..n]; 177 | match postcard::from_bytes_cobs::(data) { 178 | Ok(input) => { 179 | info!("got {}", input); 180 | match input { 181 | // refresh hack 182 | Input::Click(0) => { 183 | let ser = postcard::to_slice_cobs(ui.as_slice(), &mut ser_buf).unwrap(); 184 | write_chunked(&ser, class).await?; 185 | } 186 | Input::Click(1) => { 187 | led.set_low(); 188 | } 189 | Input::Click(2) => { 190 | led.set_high(); 191 | } 192 | Input::Click(3) => { 193 | for _ in 0..10 { 194 | let vals = random_chart_data(&mut rng); 195 | let commands = [Command::BarData(BarData { id: 5, vals })]; 196 | 197 | match postcard::to_slice_cobs(commands.as_slice(), &mut ser_buf) { 198 | Ok(ser) => { 199 | write_chunked(&ser, class).await?; 200 | } 201 | Err(e) => { 202 | error!("no! {}", e) 203 | } 204 | } 205 | Timer::after(Duration::from_millis(200)).await; 206 | } 207 | } 208 | Input::Slider(_, _) => {} 209 | _ => {} 210 | } 211 | } 212 | Err(_) => info!("gotnt!"), 213 | } 214 | } 215 | } 216 | 217 | use rand_core::{RngCore, SeedableRng}; 218 | use wyhash::WyRng; 219 | 220 | fn random_chart_data(rng: &mut WyRng) -> heapless::Vec { 221 | let mut vals = heapless::Vec::new(); 222 | for _ in 0..CHART_BARS / 8 { 223 | let r = rng.next_u64(); 224 | vals.extend(r.to_le_bytes()); 225 | } 226 | vals 227 | } 228 | -------------------------------------------------------------------------------- /update_elf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cargo run --bin encode --features std,postcard "$1" | curl --request POST --data-binary @- http://localhost:3030/backdoor 3 | -------------------------------------------------------------------------------- /web-app/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk 11 | 12 | /dist 13 | -------------------------------------------------------------------------------- /web-app/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "web-app" 3 | version = "0.1.0" 4 | authors = ["Anatol Ulrich "] 5 | edition = "2021" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | log = "0.4.6" 11 | dioxus = "0.3" 12 | dioxus-web = "0.3" 13 | chrono = { version = "0.4", features = ["wasmbind"] } 14 | #fermi = "0.3" 15 | gloo = { version = "0.8", features = ["futures"] } 16 | im-rc = "15.1.0" 17 | embedded-web-ui = { path = "..", features = ["std"] } 18 | 19 | # WebAssembly Debug 20 | wasm-logger = "0.2.0" 21 | console_error_panic_hook = "0.1.7" 22 | 23 | dioxus-websocket-hooks = { git = "https://github.com/spookyvision/dioxus-websocket-hooks.git" } 24 | 25 | defmt-decoder = { git = "https://github.com/spookyvision/defmt.git", features = [ 26 | "unstable", 27 | ] } 28 | 29 | 30 | serde = { version = "1.0.159", default_features = false, features = ["derive"] } 31 | postcard = { version = "1.0.4", features = ["use-std"], optional = true } 32 | serde_json = { version = "1", optional = true } 33 | futures = "0.3.28" 34 | wasm-bindgen = "0.2.84" 35 | anyhow = "1.0.70" 36 | ouroboros = "0.15.6" 37 | md5 = "0.7.0" 38 | 39 | [features] 40 | default = [] 41 | postcard = ["dep:postcard"] 42 | json = ["dep:serde_json"] 43 | -------------------------------------------------------------------------------- /web-app/Dioxus.toml: -------------------------------------------------------------------------------- 1 | [application] 2 | 3 | # App (Project) Name 4 | name = "web-app" 5 | 6 | # Dioxus App Default Platform 7 | # desktop, web, mobile, ssr 8 | default_platform = "web" 9 | 10 | # `build` & `serve` dist path 11 | out_dir = "dist" 12 | 13 | # resource (public) file folder 14 | asset_dir = "public" 15 | 16 | [web.app] 17 | 18 | # HTML title tag content 19 | title = "🤯" 20 | 21 | [web.watcher] 22 | 23 | # when watcher trigger, regenerate the `index.html` 24 | reload_html = true 25 | 26 | # which files or dirs will be watcher monitoring 27 | watch_path = ["src", "public"] 28 | 29 | # include `assets` in web platform 30 | [web.resource] 31 | 32 | # CSS style file 33 | style = ["style.css"] 34 | 35 | # Javascript code file 36 | script = ["d3.v7.min.js", "chart.js"] 37 | 38 | [web.resource.dev] 39 | 40 | # Javascript code file 41 | # serve: [dev-server] only 42 | script = [] 43 | -------------------------------------------------------------------------------- /web-app/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Dioxus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /web-app/README.md: -------------------------------------------------------------------------------- 1 | # dioxus-template 2 | 3 | > a template for starting a dioxus project to be used with [dioxus-cli](https://github.com/DioxusLabs/cli) 4 | 5 | ## Usage 6 | 7 | #### use `dioxus-cli` init the template: 8 | 9 | ``` 10 | dioxus init hello-dioxus 11 | ``` 12 | 13 | or you can choose the template, for this tempalte: 14 | 15 | ``` 16 | dioxus init hello-dioxus --template=gh:dioxuslabs/dioxus-template 17 | ``` 18 | 19 | #### Start a `dev-server` for the project: 20 | 21 | ``` 22 | cd ./hello-dioxus 23 | dioxus serve 24 | ``` 25 | 26 | or package this project: 27 | 28 | ``` 29 | dioxus build --release 30 | ``` 31 | 32 | ## Project Structure 33 | 34 | ``` 35 | .project 36 | - public # save the assets you want include in your project. 37 | - src # put your code 38 | - - utils # save some public function 39 | - - components # save some custom components 40 | ``` 41 | -------------------------------------------------------------------------------- /web-app/public/chart.js: -------------------------------------------------------------------------------- 1 | 2 | const margin = 10; 3 | // TODO responsive layout 4 | const width = 500 - 2 * margin; 5 | const height = 200 - 2 * margin; 6 | 7 | // TODO can we not hardcode this? 8 | const num_items = 64; 9 | const item_domain = []; 10 | for (let i = 0; i < num_items; i++) { item_domain.push(i) } 11 | 12 | const scales = {}; 13 | const charts = {}; 14 | 15 | // TODO debug code, remove 16 | const sample = [0, 99, 20, 3, 4, 5, 60, 7, 0, 99, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 99, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7]; 17 | 18 | function init_chart(id) { 19 | console.log("init chart", id); 20 | const svg = d3.select('#bar-chart-' + id); 21 | const chart = svg.append('g') 22 | .attr('transform', `translate(${margin}, ${margin})`); 23 | 24 | const xScale = d3.scaleBand() 25 | .range([0, width]) 26 | .domain(item_domain) 27 | .padding(0.4) 28 | 29 | const yScale = d3.scaleLinear() 30 | .range([height, 0]) 31 | .domain([0, 255]); 32 | 33 | scales[id] = { 'x': xScale, 'y': yScale }; 34 | charts[id] = chart; 35 | 36 | } 37 | 38 | 39 | function update(id, data) { 40 | const xScale = scales[id]['x']; 41 | const yScale = scales[id]['y']; 42 | 43 | const chart = charts[id]; 44 | 45 | const barGroups = chart.selectAll('rect') 46 | .data(data); 47 | 48 | barGroups 49 | .join('rect') 50 | .attr('class', 'bar') 51 | .attr('x', (g, i) => xScale(i)) 52 | .attr('y', (v) => yScale(v)) 53 | .attr('height', (g) => height - yScale(g)) 54 | .attr('width', xScale.bandwidth()); 55 | } 56 | -------------------------------------------------------------------------------- /web-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spookyvision/embedded-web-ui/19b51a81424bd6a7003dd67c8ab8b8c18edc57b5/web-app/public/favicon.ico -------------------------------------------------------------------------------- /web-app/public/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #223344; 3 | background-color: #fefefe; 4 | font-family: Helvetica, Arial, sans-serif; 5 | } 6 | 7 | div.chart { 8 | width: 500px; 9 | height: 200px; 10 | margin: 0.5em auto; 11 | } 12 | 13 | svg { 14 | width: 100%; 15 | height: 100%; 16 | background-color: #9cc9f0; 17 | stroke: #6699ff; 18 | border: 1px solid #447799; 19 | } 20 | 21 | button { 22 | margin: 0.2em; 23 | } 24 | 25 | /* 26 | button { 27 | border: 1px solid #3d405b; 28 | color: #e9ff70; 29 | background-color: #ff9770; 30 | padding: 4px 8px; 31 | text-align: center; 32 | text-decoration: none; 33 | margin: 0 auto; 34 | display: block; 35 | transition-duration: 0.4s; 36 | cursor: pointer; 37 | } */ 38 | 39 | 40 | .tick line, 41 | .domain { 42 | stroke: #223366; 43 | } 44 | 45 | 46 | .line { 47 | fill: none; 48 | stroke: #7209b7; 49 | stroke-width: 1.5px; 50 | } 51 | 52 | .line2 { 53 | fill: none; 54 | stroke: #f72585; 55 | stroke-width: 1.5px; 56 | } -------------------------------------------------------------------------------- /web-app/src/components.rs: -------------------------------------------------------------------------------- 1 | use dioxus::prelude::*; 2 | use dioxus_websocket_hooks::{use_ws_context, Message}; 3 | use embedded_web_ui::{Id, Input, SliderVal}; 4 | pub(crate) type SliderVars = im_rc::HashMap; 5 | 6 | use web_app::ser_de::encode; 7 | 8 | #[allow(non_snake_case)] 9 | #[inline_props] 10 | pub(crate) fn UiSlider(cx: Scope, id: Id, name: String, vars: UseState) -> Element { 11 | const SCALE: f32 = 100.0; 12 | let val = vars.get().get(name.as_str()).cloned().unwrap_or_default(); 13 | let ws_cx = use_ws_context(&cx); 14 | cx.render(rsx!( 15 | input { 16 | r#type: "range", 17 | value: "{val * SCALE}", 18 | name: "{name}", 19 | 20 | oninput: move |ev| { 21 | let new_val = ev.value.parse::().unwrap_or_default() / SCALE; 22 | log::debug!("change {name} {new_val}"); 23 | vars.with_mut(|vars| { 24 | vars.insert(name.clone(), new_val); 25 | }); 26 | let input = Input::Slider(*id, (new_val * SliderVal::MAX as f32) as SliderVal); 27 | ws_cx.send(Message::Bytes(encode(&input).unwrap())); 28 | } 29 | } 30 | label { r#for: "{name}", "{name}" } 31 | )) 32 | } 33 | 34 | #[allow(non_snake_case)] 35 | #[inline_props] 36 | pub(crate) fn BarChart(cx: Scope, id: String, name: String) -> Element { 37 | cx.render(rsx!( 38 | div { 39 | div { class: "chart", svg { id: "{id}" } } 40 | label { "{name}" } 41 | } 42 | )) 43 | } 44 | -------------------------------------------------------------------------------- /web-app/src/defmt_handler.rs: -------------------------------------------------------------------------------- 1 | use std::{collections::BTreeMap, path::Path}; 2 | 3 | use anyhow::anyhow; 4 | use defmt_decoder::{DecodeError, Frame, Location, Locations, StreamDecoder, Table}; 5 | use log::{error, warn}; 6 | 7 | type LocationInfo = (Option, Option, Option); 8 | 9 | // TODO unscrew this massive self-referential screwup by fixing `StreamDecoder` 10 | // James: 11 | // I mean I'd probably say it could be AsRef instead of &Table 12 | // then you could give it an arc or box or reference or owned type and it should all work 13 | // https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=907d188ca0b8303b67ef05109b653b7a 14 | 15 | pub(crate) struct DefmtLogger { 16 | inner: DefmtSelfRef, 17 | } 18 | 19 | impl DefmtLogger { 20 | pub(crate) fn new(ELF: &[u8]) -> Option { 21 | match DefmtSelfRef::build(ELF) { 22 | Ok(inner) => Some(Self { inner }), 23 | Err(e) => { 24 | log::error!("could not build logger: {e:?}"); 25 | None 26 | } 27 | } 28 | } 29 | 30 | pub(crate) fn received(&mut self, chunk: &[u8]) -> anyhow::Result<()> { 31 | self.inner.received(chunk) 32 | } 33 | } 34 | 35 | use ouroboros::self_referencing; 36 | #[self_referencing] 37 | struct DefmtSelfRef { 38 | pub table: Table, 39 | 40 | #[borrows(table)] 41 | #[covariant] 42 | pub handler: DefmtHandler<'this>, 43 | } 44 | 45 | impl DefmtSelfRef { 46 | pub(super) fn received(&mut self, chunk: &[u8]) -> anyhow::Result<()> { 47 | self.with_mut(|fields| fields.handler.received(chunk)) 48 | } 49 | pub fn build(ELF: &[u8]) -> anyhow::Result { 50 | let table = match Table::parse(ELF) { 51 | Ok(Some(table)) => table, 52 | Err(e) => { 53 | return Err(anyhow!("could not parse ELF table: {e:?}")); 54 | } 55 | _ => { 56 | return Err(anyhow!("AAAAAAAAAAAAA!")); 57 | } 58 | }; 59 | let locs = table.get_locations(ELF)?; 60 | 61 | let locs = if table.indices().all(|idx| locs.contains_key(&(idx as u64))) { 62 | Some(locs) 63 | } else { 64 | warn!("(BUG) location info is incomplete; it will be omitted from the output"); 65 | None 66 | }; 67 | 68 | Ok(DefmtSelfRef::new(table, |table| { 69 | DefmtHandler::new( 70 | table.new_stream_decoder(), 71 | locs, 72 | table.encoding().can_recover(), 73 | true, 74 | true, 75 | ) 76 | })) 77 | } 78 | } 79 | 80 | struct DefmtHandler<'a> { 81 | decoder: Box, 82 | can_recover: bool, 83 | locs: Option>, 84 | // TODO make configurable again 85 | show_skipped_frames: bool, 86 | verbose: bool, 87 | } 88 | 89 | impl<'a> DefmtHandler<'a> { 90 | fn new( 91 | decoder: Box, 92 | locs: Option>, 93 | can_recover: bool, 94 | show_skipped_frames: bool, 95 | verbose: bool, 96 | ) -> Self { 97 | Self { 98 | decoder, 99 | locs, 100 | can_recover, 101 | show_skipped_frames, 102 | verbose, 103 | } 104 | } 105 | 106 | fn received(&mut self, chunk: &[u8]) -> anyhow::Result<()> { 107 | let decoder = &mut self.decoder; 108 | decoder.received(chunk); 109 | 110 | loop { 111 | match decoder.decode() { 112 | Ok(frame) => { 113 | forward_to_logger(&frame, location_info(&self.locs, &frame, "N/A (todo)")) 114 | } 115 | Err(DecodeError::UnexpectedEof) => { 116 | // error!("log decoder: EOF"); 117 | break; 118 | } 119 | Err(DecodeError::Malformed) => match self.can_recover { 120 | // if recovery is impossible, abort 121 | false => return Err(DecodeError::Malformed.into()), 122 | // if recovery is possible, skip the current frame and continue with new data 123 | true => { 124 | if self.show_skipped_frames || self.verbose { 125 | error!("(HOST) malformed frame skipped"); 126 | error!("└─ {} @ {}:{}", env!("CARGO_PKG_NAME"), file!(), line!()); 127 | } 128 | continue; 129 | } 130 | }, 131 | } 132 | } 133 | Ok(()) 134 | } 135 | } 136 | 137 | fn forward_to_logger(frame: &Frame, location_info: LocationInfo) { 138 | let (file, line, mod_path) = location_info; 139 | defmt_decoder::log::log_defmt(frame, file.as_deref(), line, mod_path.as_deref(), false); 140 | } 141 | 142 | fn location_info( 143 | locs: &Option, 144 | frame: &Frame, 145 | current_dir: impl AsRef, 146 | ) -> LocationInfo { 147 | let (mut file, mut line, mut mod_path) = (None, None, None); 148 | 149 | // NOTE(`[]` indexing) all indices in `table` have been verified to exist in the `locs` map 150 | let loc = locs.as_ref().map(|locs| &locs[&frame.index()]); 151 | 152 | if let Some(loc) = loc { 153 | // try to get the relative path, else the full one 154 | let path = loc.file.strip_prefix(¤t_dir).unwrap_or(&loc.file); 155 | 156 | file = Some(path.display().to_string()); 157 | line = Some(loc.line as u32); 158 | mod_path = Some(loc.module.clone()); 159 | } 160 | 161 | (file, line, mod_path) 162 | } 163 | -------------------------------------------------------------------------------- /web-app/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod ser_de; 2 | -------------------------------------------------------------------------------- /web-app/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | 3 | use components::*; 4 | use defmt_handler::DefmtLogger; 5 | use dioxus::prelude::*; 6 | use dioxus_websocket_hooks::{use_ws_context, use_ws_context_provider, Message}; 7 | use embedded_web_ui::{Command, Id, Input, Log, Widget, WidgetKind, UI}; 8 | use futures::stream::StreamExt; 9 | use im_rc::HashSet; 10 | use log::{debug, error, info, warn}; 11 | use wasm_bindgen::prelude::wasm_bindgen; 12 | use web_app::ser_de::{decode, encode}; 13 | 14 | mod components; 15 | mod defmt_handler; 16 | 17 | fn main() { 18 | wasm_logger::init(wasm_logger::Config::default()); 19 | // suppress dioxus logging - TODO needs more love 20 | // wasm_logger::init(wasm_logger::Config::default().module_prefix("web-app")); 21 | console_error_panic_hook::set_once(); 22 | 23 | dioxus_web::launch(app); 24 | } 25 | 26 | #[wasm_bindgen] 27 | extern "C" { 28 | #[wasm_bindgen] 29 | fn btoa(s: &str) -> String; 30 | } 31 | 32 | #[wasm_bindgen] 33 | extern "C" { 34 | #[wasm_bindgen] 35 | fn init_chart(id: Id); 36 | } 37 | 38 | #[wasm_bindgen] 39 | extern "C" { 40 | #[wasm_bindgen] 41 | fn update(id: Id, data: Vec); 42 | } 43 | 44 | fn use_ws_context_provider_binary(cx: &ScopeState, url: &str, handler: impl Fn(Vec) + 'static) { 45 | let handler = move |msg| { 46 | if let Message::Bytes(data) = msg { 47 | handler(data) 48 | } else { 49 | debug!("no handler for {msg:?}"); 50 | } 51 | }; 52 | 53 | use_ws_context_provider(cx, url, handler) 54 | } 55 | 56 | // TODO UseRef isn't optimal, (probably) `with_mut` causes Dioxus to rerender. What to do… 57 | fn handle_log(logger: &mut Option, log: Log) { 58 | match log { 59 | Log::Elf(elf) => { 60 | log::warn!("table decoder wants 4 byte aligned slice, report bug"); 61 | // clone to enforce alignment 62 | let elf: Vec = elf.into(); 63 | let hash = md5::compute(&elf); 64 | debug!("creating new log handler {} {:?}", elf.len(), hash); 65 | *logger = defmt_handler::DefmtLogger::new(&elf) 66 | } 67 | Log::Packet(chunk) => match logger { 68 | Some(logger) => { 69 | if let Err(e) = logger.received(&chunk) { 70 | error!("logger: {e:?}"); 71 | } 72 | } 73 | None => warn!("received log packet but do not have a logger"), 74 | }, 75 | } 76 | } 77 | 78 | fn app(cx: Scope) -> Element { 79 | // TODO use_ref, remove im_rc 80 | let slider_vars = use_state(&cx, SliderVars::default); 81 | let charts = use_ref(cx, || HashSet::new()); 82 | 83 | let ui_items = use_ref(cx, || { 84 | let res: Vec = vec![UI::Widget(Widget { 85 | kind: WidgetKind::Button, 86 | label: "plz refresh".into(), 87 | id: 0, 88 | })]; 89 | res 90 | }); 91 | 92 | let update_ui = use_coroutine(&cx, |mut rx: UnboundedReceiver| { 93 | to_owned![ui_items]; 94 | async move { 95 | while let Some(ui_elem) = rx.next().await { 96 | debug!("got new UI! {ui_elem:?}"); 97 | ui_items.with_mut(|items| items.push(ui_elem)); 98 | } 99 | } 100 | }) 101 | .to_owned(); 102 | 103 | let _ws = use_ws_context_provider_binary(cx, "ws://localhost:3030", { 104 | to_owned![ui_items, charts]; 105 | move |mut d| { 106 | let mut logger = None; 107 | if let Ok(commands) = decode::>(d.as_mut_slice()) { 108 | for command in commands { 109 | match command { 110 | Command::Log(log) => handle_log(&mut logger, log), 111 | Command::Reset => { 112 | info!("RESET"); 113 | // TODO: dioxus doesn't know we're messing with its nodes 114 | // -> it caches the graph state 115 | // -> graphs stay initialized 116 | // -> must be smarter about this, otherwise there will be leftovers 117 | // interesting corner case: data comes in before the chart has been rendered 118 | charts.with_mut(|charts| charts.clear()); 119 | ui_items.with_mut(|items| items.clear()); 120 | } 121 | Command::UI(ui) => { 122 | update_ui.send(ui.clone()); 123 | } 124 | Command::TimeSeriesData(data) => { 125 | debug!("time series data: {data:?}"); 126 | } 127 | Command::BarData(data) => { 128 | let id = data.id; 129 | // TODO this assumes the chart container is already present, which it might not be 130 | // (see `Command::Reset` comment above) 131 | // -> we can probably queue things up and consume inside useEffect 132 | if !charts.read().contains(&id) { 133 | charts.with_mut(|charts| charts.insert(id)); 134 | init_chart(id); 135 | } 136 | let mut res = vec![]; 137 | res.extend(&data.vals); 138 | update(data.id, res); 139 | } 140 | } 141 | } 142 | } else { 143 | warn!("got garbage") 144 | } 145 | } 146 | }); 147 | 148 | let ws_cx = use_ws_context(&cx); 149 | 150 | let ui_items_it = ui_items.read(); 151 | cx.render(rsx! ( 152 | div { style: "text-align: center;", 153 | h1 { "embedded-web-ui" } 154 | div { 155 | ui_items_it.iter().map(|item| match item { 156 | UI::Widget(widget) => { 157 | to_owned![ws_cx]; 158 | let label = &widget.label; 159 | let id = widget.id; 160 | match widget.kind { 161 | WidgetKind::TimeSeriesChart => rsx!{"TimeSeriesChart"}, 162 | 163 | WidgetKind::BarChart => { 164 | rsx!(BarChart { 165 | id: format!("bar-chart-{id}"), 166 | name: label.to_string() 167 | }) 168 | }, 169 | 170 | WidgetKind::Button => rsx!( button { 171 | //key: "{id}", 172 | onclick: move |ev| { 173 | debug!("click {id}"); 174 | let input = Input::Click(id); 175 | ws_cx.send(Message::Bytes(encode(&input).unwrap())); 176 | ev.stop_propagation(); 177 | }, 178 | "{label}"}), 179 | WidgetKind::Slider => rsx!( 180 | UiSlider { 181 | //key: "{id}", 182 | id: id, 183 | name: label.to_string(), 184 | vars: slider_vars.clone() 185 | } 186 | ), 187 | } 188 | }, 189 | UI::Break => rsx!{ br{} } 190 | }) 191 | } 192 | } 193 | )) 194 | } 195 | -------------------------------------------------------------------------------- /web-app/src/ser_de.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | #[cfg(all(feature = "json", not(feature = "postcard")))] 4 | pub(crate) mod imp { 5 | use super::*; 6 | pub fn encode(value: &T) -> serde_json::Result> 7 | where 8 | T: Serialize + ?Sized, 9 | { 10 | let mut res = serde_json::to_vec(value)?; 11 | res.push(0); 12 | Ok(res) 13 | } 14 | 15 | pub fn decode<'a, T>(s: &'a mut [u8]) -> serde_json::Result 16 | where 17 | T: Deserialize<'a>, 18 | { 19 | serde_json::from_slice(&s[0..s.len() - 1]) 20 | } 21 | } 22 | 23 | #[cfg(all(feature = "postcard", not(feature = "json")))] 24 | pub(crate) mod imp { 25 | use super::*; 26 | 27 | pub fn encode(value: &T) -> postcard::Result> 28 | where 29 | T: Serialize + ?Sized, 30 | { 31 | postcard::to_allocvec_cobs(value) 32 | } 33 | 34 | pub fn decode<'a, T>(s: &'a mut [u8]) -> postcard::Result 35 | where 36 | T: Deserialize<'a>, 37 | { 38 | postcard::from_bytes_cobs(s) 39 | } 40 | } 41 | 42 | pub use imp::*; 43 | -------------------------------------------------------------------------------- /ws-py/.envrc: -------------------------------------------------------------------------------- 1 | source ve/bin/activate 2 | -------------------------------------------------------------------------------- /ws-py/.gitignore: -------------------------------------------------------------------------------- 1 | ve -------------------------------------------------------------------------------- /ws-py/README.md: -------------------------------------------------------------------------------- 1 | dev/debug usage only, send stuff to serial -------------------------------------------------------------------------------- /ws-py/client.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from getkey import getkey, keys 3 | 4 | import asyncio 5 | import websockets 6 | import json 7 | import random 8 | 9 | 10 | from math import pi 11 | from functools import wraps, partial 12 | 13 | 14 | def async_wrap(func): 15 | @wraps(func) 16 | async def run(*args, loop=None, executor=None, **kwargs): 17 | if loop is None: 18 | loop = asyncio.get_event_loop() 19 | pfunc = partial(func, *args, **kwargs) 20 | return await loop.run_in_executor(executor, pfunc) 21 | 22 | return run 23 | 24 | 25 | async_getkey = async_wrap(getkey) 26 | 27 | 28 | async def consumer_handler(websocket, path): 29 | async for message in websocket: 30 | print(f"recv {message}") 31 | try: 32 | decoded = json.loads(message) 33 | bd = "BeatDuration" 34 | if bd in decoded: 35 | print("%.2f bpm" % ((1000 * 60) / int(decoded[bd]))) 36 | else: 37 | print(message) 38 | except: 39 | print("that wasn't JSON") 40 | 41 | 42 | i = 0 43 | 44 | 45 | async def producer_handler(websocket, path): 46 | print("...") 47 | 48 | slerp = 0.05 49 | 50 | quit = False 51 | do_coro = True 52 | 53 | async def psv(data): 54 | await websocket.send(data) 55 | 56 | async def coro(which=0): 57 | gif = [] 58 | while not quit and do_coro: 59 | for frame in gif: 60 | data = bytearray() 61 | try: 62 | await websocket.send(data) 63 | except websockets.exceptions.ConnectionClosed: 64 | print("closed¿") 65 | return 66 | await asyncio.sleep(slerp) 67 | 68 | print("hi") 69 | 70 | while True: 71 | key = await async_getkey() 72 | if key == keys.ESC or key == keys.ENTER or key == keys.Q: 73 | print("bye") 74 | quit = True 75 | break 76 | elif key == keys.SPACE: 77 | await websocket.send('very long Soup') 78 | elif key == keys.X: 79 | await websocket.send('just x') 80 | elif key == keys.I: 81 | do_coro = False 82 | 83 | 84 | async def handler(websocket, path): 85 | consumer_task = asyncio.ensure_future(consumer_handler(websocket, path)) 86 | producer_task = asyncio.ensure_future(producer_handler(websocket, path)) 87 | done, pending = await asyncio.wait( 88 | [consumer_task, producer_task], 89 | return_when=asyncio.FIRST_COMPLETED, 90 | ) 91 | for task in pending: 92 | task.cancel() 93 | 94 | 95 | async def hello(): 96 | import logging 97 | 98 | logger = logging.getLogger("websockets") 99 | # logger.setLevel(logging.DEBUG) 100 | # logger.addHandler(logging.StreamHandler()) 101 | 102 | import os 103 | 104 | uri = os.environ.get("WS_ENDPOINT") or "ws://localhost:3030/" 105 | print(f"connecting to {uri}") 106 | async with websockets.connect(uri) as websocket: 107 | await handler(websocket, "wat") 108 | 109 | 110 | asyncio.get_event_loop().run_until_complete(hello()) 111 | -------------------------------------------------------------------------------- /ws-py/requirements.txt: -------------------------------------------------------------------------------- 1 | getkey 2 | websockets 3 | asyncio 4 | --------------------------------------------------------------------------------