use common::time::Time;
use common::mx25l::Mx25l;
use common::shell::Shell;
+use common::logger::Logger;
extern {
fn enable_interrupts();
let mut mx25l = Mx25l::new(gpio::GPIOD, 1 << 0);
+ let mut logger = Logger::new(&mut mx25l);
+ logger.init();
+
let mut gps = gps::Gps::new();
let mut gps_has_fix = false;
}
});
- shell.update(&mut mx25l);
+ shell.update(&mut logger);
if reset_requested() {
nvic::system_reset();
*/
use buffer::Buffer;
-use storage::Storage;
+use logger::Logger;
use yencode::Yencode;
use systick;
None
}
-struct Context<'a> {
- storage: &'a mut dyn Storage,
-}
-
impl<'a> Shell<'a> {
pub fn new(tx_buf: &mut Buffer) -> Shell {
Shell {
}
}
- pub fn update(&mut self, storage: &mut dyn Storage) {
- let mut context = Context {
- storage: storage,
- };
-
+ pub fn update(&mut self, logger: &mut Logger) {
while let Some(c) = read_char() {
if c != b'\n' {
if self.command_offset != self.command_buffer.len() {
self.command_buffer[command_length] = b'\0';
if command_length != 0 {
- self.dispatch(command_length, &mut context);
+ self.dispatch(command_length, logger);
}
} else {
self.command_buffer[self.command_offset] = b'\0';
}
}
- fn dispatch(&mut self, command_length: usize, mut context: &mut Context) {
+ fn dispatch(&mut self, command_length: usize, logger: &mut Logger) {
let command : [u8; 32] = self.command_buffer;
let mut args_iter = ArgumentIter {
self.tx_buf.write(usage);
},
- Some(b"clear_storage") => self.run_clear_storage(&mut context),
- Some(b"dump_storage") => self.run_dump_storage(&mut context),
+ Some(b"clear_storage") => self.run_clear_storage(logger),
+ Some(b"dump_storage") => self.run_dump_storage(logger),
Some(ref other) => {
self.tx_buf.write(b"unknown_command: ");
}
}
- fn run_clear_storage(&self, context: &mut Context) {
- context.storage.clear();
+ fn run_clear_storage(&self, logger: &mut Logger) {
+ logger.storage.clear();
}
- fn run_dump_storage(&mut self, context: &mut Context) {
+ fn run_dump_storage(&mut self, logger: &mut Logger) {
self.tx_buf.write(b"waiting for receiver to start...\n");
self.tx_buf.flush();
yenc.start(b"gps-watch-storage.bin");
const CHUNK_SIZE: usize = 1024;
- let num_chunks = context.storage.size() / CHUNK_SIZE;
+ let num_chunks = logger.storage.size() / CHUNK_SIZE;
for i in 0..num_chunks {
let mut buf = [0u8; CHUNK_SIZE];
- context.storage.read(i * CHUNK_SIZE, &mut buf);
+ logger.storage.read(i * CHUNK_SIZE, &mut buf);
yenc.data(&buf);
}