diff --git a/.gitea/workflows/pull_request.yaml b/.gitea/workflows/pull_request.yaml new file mode 100644 index 0000000..8ba2d08 --- /dev/null +++ b/.gitea/workflows/pull_request.yaml @@ -0,0 +1,41 @@ +name: Gavania Merge Build +run_name: Test successful gavania build on merge request + +on: + pull_request: + types: [opened, reopened, edited, review_requested, synchronize] + +jobs: + Arduino: + steps: + - uses: https://github.com/actions/checkout@v3 + + - uses: https://github.com/dtolnay/rust-toolchain@stable + + - name: Build + run: | + cd rust/arduino + cargo build + + Pico: + steps: + - uses: https://github.com/actions/checkout@v3 + + - uses: https://github.com/dtolnay/rust-toolchain@stable + + - name: Build + run: | + cd rust/pico + cargo build + + Serial Reader: + steps: + - uses: https://github.com/actions/checkout@v3 + + - uses: https://github.com/dtolnay/rust-toolchain@stable + + - name: Build + run: | + cd rust/serial_reader + cargo build + diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e5e23b1..df1c973 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,5 +25,17 @@ "cwd": "rust/pico" } }, + { + "type": "cargo", + "command": "build", + "problemMatcher": [ + "$rustc" + ], + "group": "build", + "label": "SerialReader: cargo build", + "options": { + "cwd": "rust/serial_reader" + } + }, ] } \ No newline at end of file diff --git a/rust/serial_reader/src/main.rs b/rust/serial_reader/src/main.rs index 0a94514..8d571e3 100644 --- a/rust/serial_reader/src/main.rs +++ b/rust/serial_reader/src/main.rs @@ -80,6 +80,8 @@ fn main() { } }); + let buffer = serial_info.buffer().unwrap(); + connect_button.connect_clicked(move |_| { if !CONNECTED.load(SeqCst) { let usb_id = UsbId { @@ -107,6 +109,9 @@ fn main() { if let Ok(port) = Port::open(usb_id, serialport_settings, 50, 1) { CONNECTED.store(true, SeqCst); + let (mut buffer_start, mut buffer_end) = buffer.bounds(); + buffer.delete(&mut buffer_start, &mut buffer_end); + *PORT.lock().unwrap() = Some(port); } }