Fixed SimpleVector push
This commit is contained in:
22
src/webee.rs
22
src/webee.rs
@@ -1,16 +1,11 @@
|
||||
use arduino_hal::clock::Clock;
|
||||
use arduino_hal::hal::Atmega;
|
||||
use arduino_hal::port::{Pin, PinOps};
|
||||
use arduino_hal::port::mode::{Input, Output, PullUp};
|
||||
use arduino_hal::port::mode::{Input, Output};
|
||||
use arduino_hal::usart::{Usart, UsartOps};
|
||||
use arduino_hal::prelude::*;
|
||||
use avr_device::atmega2560::usart0::ucsr0c::USBS0_A::STOP1;
|
||||
|
||||
use embedded_hal::serial::{Read};
|
||||
|
||||
mod vector;
|
||||
|
||||
pub use vector::Vector;
|
||||
mod simple_vector;
|
||||
pub use simple_vector::SimpleVec;
|
||||
|
||||
|
||||
pub struct Webee<USART: UsartOps<Atmega, RX, TX>, RX, TX>
|
||||
@@ -39,20 +34,21 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send(&mut self, data: Vector<u8>) -> Vector<u8> {
|
||||
pub fn send(&mut self, data: &[u8]) -> SimpleVec {
|
||||
for byte in data {
|
||||
self.webee.write_byte(byte);
|
||||
self.webee.write_byte(*byte);
|
||||
}
|
||||
|
||||
return self.recv();
|
||||
}
|
||||
|
||||
fn recv(&mut self) -> Vector<u8> {
|
||||
let mut buffer: Vector<u8> = Vector::new(0, &mut []);
|
||||
let byte: u8 = self.webee.read_byte();
|
||||
fn recv(&mut self) -> SimpleVec {
|
||||
let mut byte: u8 = self.webee.read_byte();
|
||||
let mut buffer = SimpleVec::new();
|
||||
|
||||
while byte != STOP {
|
||||
buffer.push(byte);
|
||||
byte = self.webee.read_byte();
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
||||
Reference in New Issue
Block a user