Skip to content
Snippets Groups Projects
Verified Commit 9f698929 authored by Jana Dönszelmann's avatar Jana Dönszelmann :sparkling_heart:
Browse files

Version 2.0 with raw fd fixes

parent 6fbc7a69
Branches main
No related tags found
No related merge requests found
Pipeline #993145 failed
......@@ -85,9 +85,9 @@ dependencies = [
[[package]]
name = "crossterm"
version = "0.25.0"
version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13"
dependencies = [
"bitflags",
"crossterm_winapi",
......@@ -154,9 +154,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.138"
version = "0.2.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
[[package]]
name = "lock_api"
......@@ -293,9 +293,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serial2"
version = "0.1.7"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa2370e12745a20d3dcd07438fc72f399c74f59537a35863a1a7a9ff2482040"
checksum = "a5bc2c5cf48d8cda6db38f75897deaa68d0eefded51f5b51f7e01a0929411806"
dependencies = [
"cfg-if",
"libc",
......@@ -410,7 +410,7 @@ dependencies = [
[[package]]
name = "tudelft-serial-upload"
version = "1.0.0"
version = "2.0.0"
dependencies = [
"color-eyre",
"crossterm",
......
[package]
name = "tudelft-serial-upload"
version = "1.0.1"
version = "2.0.0"
edition = "2021"
license = "MIT"
description = "library to automatically upload to quadrupel drone boards"
authors = ["Jonathan Dönszelmann <jonabent@gmail.com>", "Victor Roest <victor@xirion.net>"]
authors = ["Jonathan Dönszelmann <jonabent@gmail.com>", "Vivian Roest <victor@xirion.net>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serial2 = "0.2.1"
serial2 = "=0.2.16"
serial_enumerator = "0.2"
color-eyre = "0.6"
crossterm = "0.26.1"
......
......@@ -10,5 +10,6 @@ use std::time::Duration;
pub use color_eyre;
pub use selector::PortSelector;
pub use upload::{upload, upload_file, upload_file_or_stop, upload_or_stop};
pub use serial2;
const SERIAL_TIMEOUT: Duration = Duration::from_secs(1);
const SERIAL_TIMEOUT: Duration = Duration::from_secs(5);
use color_eyre::eyre::{bail, WrapErr};
use serial2::{FlowControl, SerialPort, Settings};
use std::io::{stdout, Read, Write};
use std::io::{stdout, Write};
use std::path::PathBuf;
use std::sync::mpsc::channel;
use std::thread::{sleep, spawn};
......@@ -27,16 +27,19 @@ pub struct Serial {
impl Serial {
pub fn open(path: PathBuf) -> Result<Self> {
let mut port = SerialPort::open(&path, |mut s: Settings| {
s.set_flow_control(FlowControl::RtsCts);
s.set_raw();
s.set_baud_rate(921_600)?;
s.set_flow_control(FlowControl::RtsCts);
Ok(s)
})
.wrap_err("failed to open serial port")?;
// port.set_read_timeout(SERIAL_TIMEOUT).wrap_err("failed to set read timeout")?;
port.set_read_timeout(SERIAL_TIMEOUT).wrap_err("failed to set read timeout")?;
port.set_write_timeout(SERIAL_TIMEOUT)
.wrap_err("failed to set write timeout")?;
port.discard_buffers().wrap_err("flush")?;
Ok(Self {
port,
path,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment