mirror of
https://github.com/spacemeowx2/blflash.git
synced 2024-11-19 11:10:07 +00:00
fix: set serial settings
This commit is contained in:
parent
a373f055fc
commit
e6ddfd0857
@ -9,7 +9,7 @@ use blflash::{
|
|||||||
};
|
};
|
||||||
use env_logger::Env;
|
use env_logger::Env;
|
||||||
use main_error::MainError;
|
use main_error::MainError;
|
||||||
use serial::{BaudRate, SerialPort};
|
use serial::{BaudRate, CharSize, FlowControl, Parity, SerialPort, SerialPortSettings, StopBits};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
@ -95,7 +95,14 @@ enum Opt {
|
|||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
fn open_serial(&self) -> Result<impl SerialPort, Error> {
|
fn open_serial(&self) -> Result<impl SerialPort, Error> {
|
||||||
let serial = serial::open(&self.port)?;
|
let mut serial = serial::open(&self.port)?;
|
||||||
|
serial.reconfigure(&|setup: &mut dyn SerialPortSettings| {
|
||||||
|
setup.set_char_size(CharSize::Bits8);
|
||||||
|
setup.set_stop_bits(StopBits::Stop1);
|
||||||
|
setup.set_parity(Parity::ParityNone);
|
||||||
|
setup.set_flow_control(FlowControl::FlowNone);
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
Ok(serial)
|
Ok(serial)
|
||||||
}
|
}
|
||||||
fn create_flasher(&self, chip: impl Chip + 'static) -> Result<Flasher, Error> {
|
fn create_flasher(&self, chip: impl Chip + 'static) -> Result<Flasher, Error> {
|
||||||
|
Loading…
Reference in New Issue
Block a user