Skip to content

Commit

Permalink
Trace log for Linux block read/write
Browse files Browse the repository at this point in the history
  • Loading branch information
thejpster committed Oct 11, 2024
1 parent fa52c8a commit 17576a8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use chrono::Timelike;
use embedded_sdmmc::{Block, BlockCount, BlockDevice, BlockIdx, TimeSource, Timestamp};
use log::trace;
use std::cell::RefCell;
use std::fs::{File, OpenOptions};
use std::io::prelude::*;
Expand Down Expand Up @@ -35,6 +36,12 @@ impl BlockDevice for LinuxBlockDevice {
type Error = std::io::Error;

fn read(&self, blocks: &mut [Block], start_block_idx: BlockIdx) -> Result<(), Self::Error> {
trace!(
"Read {} block{} at {:#08x}",
blocks.len(),
if blocks.len() == 1 { "" } else { "s" },
start_block_idx.into_bytes()
);
self.file
.borrow_mut()
.seek(SeekFrom::Start(start_block_idx.into_bytes()))?;
Expand All @@ -48,6 +55,12 @@ impl BlockDevice for LinuxBlockDevice {
}

fn write(&self, blocks: &[Block], start_block_idx: BlockIdx) -> Result<(), Self::Error> {
trace!(
"Write {} block{} at {:#08x}",
blocks.len(),
if blocks.len() == 1 { "" } else { "s" },
start_block_idx.into_bytes()
);
self.file
.borrow_mut()
.seek(SeekFrom::Start(start_block_idx.into_bytes()))?;
Expand Down

0 comments on commit 17576a8

Please sign in to comment.