diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2019-01-15 00:21:22 +0100 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2019-01-15 00:21:22 +0100 |
| commit | a1eed373b07d54c534310a5a4cd69d77d3a54350 (patch) | |
| tree | 831fbd48b849101a6c56883118b1611c3215b517 /src/app.rs | |
| parent | 136d9f5a37d5dfd72e6c1486065de4d96611c523 (diff) | |
| download | rspsxserial-a1eed373b07d54c534310a5a4cd69d77d3a54350.tar.gz | |
requested_file is now also modified by send_file().
Packets smaller than 8 bytes are now also sent.
Diffstat (limited to 'src/app.rs')
| -rw-r--r-- | src/app.rs | 48 |
1 files changed, 21 insertions, 27 deletions
@@ -94,7 +94,7 @@ fn serial_comm(addr : Option<&String>, port_name : &String, baud_rate : Option<& TransferState::SendFile => transfer::send_file(&mut port, &folder, &mut sent_bytes, - &requested_file, + &mut requested_file, &mut file_data, &mut file_size), TransferState::Finished => break @@ -127,31 +127,25 @@ fn serial_init(addr : Option<&String>, port_name : &String, baud_rate : Option<& } }; - // This variable will be bound to a SystemPort - // instance if everything could be configured successfully. - let mut port_unwrapped; - match port { - Err(_) => { - return Err(Error::new(ErrorKind::NotFound, "Could not open serial device")); - }, - - Ok(p) => { - port_unwrapped = p; - } - }; - - let settings = - serial::PortSettings { - baud_rate: baud, - char_size: serial::Bits8, - parity: serial::ParityNone, - stop_bits: serial::Stop1, - flow_control: serial::FlowNone - }; - - port_unwrapped.configure(&settings)?; - - // Return SystemPort instance if successful. - Ok(port_unwrapped) + Err(_) => { + Err(Error::new(ErrorKind::NotFound, "Could not open serial device")) + }, + + Ok(mut p) => { + let settings = + serial::PortSettings { + baud_rate: baud, + char_size: serial::Bits8, + parity: serial::ParityNone, + stop_bits: serial::Stop1, + flow_control: serial::FlowNone + }; + + p.configure(&settings)?; + + // Return SystemPort instance if successful. + Ok(p) + } + } } |
