forked from M-Labs/zynq-rs
core_io -> core2::io
This commit is contained in:
parent
313662b196
commit
26bde04a19
|
@ -6,9 +6,8 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libboard_zynq = { path = "../libboard_zynq" }
|
libboard_zynq = { path = "../libboard_zynq" }
|
||||||
<<<<<<< HEAD
|
core2 = { version = "=0.3.2", features = ["alloc", "nightly"], default-features = false }
|
||||||
core_io = { version = "0.1", features = ["collections"] }
|
fatfs = { git = "https://github.com/SimonRenblad/rust-fatfs", branch = "stable-0.3", features = ["core2", "alloc"], default-features = false }
|
||||||
fatfs = { version = "0.3", features = ["core_io"], default-features = false }
|
|
||||||
log = "=0.4.14"
|
log = "=0.4.14"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -17,4 +16,3 @@ target_coraz7 = []
|
||||||
target_redpitaya = []
|
target_redpitaya = []
|
||||||
target_kasli_soc = []
|
target_kasli_soc = []
|
||||||
ipv6 = []
|
ipv6 = []
|
||||||
fat_lfn = [ "fatfs/alloc" ]
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core_io::{Error, Read, Seek, SeekFrom};
|
use core2::io::{Error, Read, Seek, SeekFrom};
|
||||||
use libboard_zynq::devc;
|
use libboard_zynq::devc;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ extern crate alloc;
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use alloc::{string::FromUtf8Error, string::String, vec::Vec, rc::Rc};
|
use alloc::{string::FromUtf8Error, string::String, vec::Vec, rc::Rc};
|
||||||
use core_io::{self as io, BufRead, BufReader, Read, Write, Seek, SeekFrom};
|
use core2::io::{self as io, Read, Write, Seek, SeekFrom};
|
||||||
use libboard_zynq::sdio;
|
use libboard_zynq::sdio;
|
||||||
|
|
||||||
pub mod sd_reader;
|
pub mod sd_reader;
|
||||||
|
@ -54,11 +54,13 @@ impl<'a> From<FromUtf8Error> for Error<'a> {
|
||||||
fn parse_config<'a>(
|
fn parse_config<'a>(
|
||||||
key: &'a str,
|
key: &'a str,
|
||||||
buffer: &mut Vec<u8>,
|
buffer: &mut Vec<u8>,
|
||||||
file: fatfs::File<sd_reader::SdReader>,
|
file: &mut fatfs::File<sd_reader::SdReader>,
|
||||||
) -> Result<'a, ()> {
|
) -> Result<'a, ()> {
|
||||||
let prefix = [key, "="].concat().to_ascii_lowercase();
|
let prefix = [key, "="].concat().to_ascii_lowercase();
|
||||||
for line in BufReader::new(file).lines() {
|
let mut read_buf = Vec::new();
|
||||||
let line = line?.to_ascii_lowercase();
|
file.read_to_end(&mut read_buf)?;
|
||||||
|
for line in String::from_utf8(read_buf)?.lines() {
|
||||||
|
let line = line.to_ascii_lowercase();
|
||||||
if line.starts_with(&prefix) {
|
if line.starts_with(&prefix) {
|
||||||
buffer.extend(line[prefix.len()..].as_bytes());
|
buffer.extend(line[prefix.len()..].as_bytes());
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -101,7 +103,7 @@ impl Config {
|
||||||
match root_dir.open_file(&["/CONFIG/", key, ".BIN"].concat()) {
|
match root_dir.open_file(&["/CONFIG/", key, ".BIN"].concat()) {
|
||||||
Ok(mut f) => f.read_to_end(&mut buffer).map(|_| ())?,
|
Ok(mut f) => f.read_to_end(&mut buffer).map(|_| ())?,
|
||||||
Err(_) => match root_dir.open_file("/CONFIG.TXT") {
|
Err(_) => match root_dir.open_file("/CONFIG.TXT") {
|
||||||
Ok(f) => parse_config(key, &mut buffer, f)?,
|
Ok(mut f) => parse_config(key, &mut buffer, &mut f)?,
|
||||||
Err(_) => return Err(Error::KeyNotFoundError(key)),
|
Err(_) => return Err(Error::KeyNotFoundError(key)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -124,11 +126,11 @@ impl Config {
|
||||||
let prefix = [key, "="].concat().to_ascii_lowercase();
|
let prefix = [key, "="].concat().to_ascii_lowercase();
|
||||||
match root_dir.create_file("/CONFIG.TXT") {
|
match root_dir.create_file("/CONFIG.TXT") {
|
||||||
Ok(mut f) => {
|
Ok(mut f) => {
|
||||||
let mut buffer = String::new();
|
let mut buffer = Vec::new();
|
||||||
f.read_to_string(&mut buffer)?;
|
f.read_to_end(&mut buffer)?;
|
||||||
f.seek(SeekFrom::Start(0))?;
|
f.seek(SeekFrom::Start(0))?;
|
||||||
f.truncate()?;
|
f.truncate()?;
|
||||||
for line in buffer.lines() {
|
for line in String::from_utf8(buffer)?.lines() {
|
||||||
if line.len() > 0 && !line.to_ascii_lowercase().starts_with(&prefix) {
|
if line.len() > 0 && !line.to_ascii_lowercase().starts_with(&prefix) {
|
||||||
f.write(line.as_bytes())?;
|
f.write(line.as_bytes())?;
|
||||||
f.write(NEWLINE)?;
|
f.write(NEWLINE)?;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use core_io::{BufRead, Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write};
|
use core2::io::{BufRead, Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write};
|
||||||
use fatfs;
|
use fatfs;
|
||||||
use libboard_zynq::sdio::{sd_card::SdCard, CmdTransferError};
|
use libboard_zynq::sdio::{sd_card::SdCard, CmdTransferError};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
|
@ -13,9 +13,9 @@ target_kasli_soc = ["libboard_zynq/target_kasli_soc", "libsupport_zynq/target_ka
|
||||||
default = ["target_zc706"]
|
default = ["target_zc706"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
log = "=0.4.14"
|
||||||
byteorder = { version = "1.3", default-features = false }
|
byteorder = { version = "=1.3", default-features = false }
|
||||||
core_io = { version = "0.1", features = ["collections"] }
|
core2 = { version = "=0.3.2", default-features = false, features = ["alloc", "nightly"] }
|
||||||
|
|
||||||
libboard_zynq = { path = "../libboard_zynq" }
|
libboard_zynq = { path = "../libboard_zynq" }
|
||||||
libsupport_zynq = { path = "../libsupport_zynq" }
|
libsupport_zynq = { path = "../libsupport_zynq" }
|
||||||
|
|
|
@ -8,7 +8,7 @@ mod netboot;
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use core_io::{Read, Seek};
|
use core2::io::{Read, Seek};
|
||||||
use libboard_zynq::{
|
use libboard_zynq::{
|
||||||
self as zynq,
|
self as zynq,
|
||||||
clocks::source::{ArmPll, ClockSource, IoPll},
|
clocks::source::{ArmPll, ClockSource, IoPll},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use byteorder::{ByteOrder, NetworkEndian};
|
use byteorder::{ByteOrder, NetworkEndian};
|
||||||
use core_io::{Read, Seek};
|
use core2::io::{Read, Seek};
|
||||||
use libboard_zynq::{
|
use libboard_zynq::{
|
||||||
devc,
|
devc,
|
||||||
eth::Eth,
|
eth::Eth,
|
||||||
|
|
Loading…
Reference in New Issue