make serial core functions public
This commit is contained in:
@@ -45,7 +45,7 @@ impl PacketTransportSerialCobs {
|
|||||||
/// Send a packet.
|
/// Send a packet.
|
||||||
///
|
///
|
||||||
/// It encodes the packet using COBS encoding before sending it over the serial port.
|
/// It encodes the packet using COBS encoding before sending it over the serial port.
|
||||||
fn send(&mut self, packet: &[u8]) -> Result<(), super::SendError> {
|
pub fn send(&mut self, packet: &[u8]) -> Result<(), super::SendError> {
|
||||||
let encoded = cobs::encode_vec_including_sentinels(packet);
|
let encoded = cobs::encode_vec_including_sentinels(packet);
|
||||||
log::debug!("sending COBS encoded packet: {:?}", encoded);
|
log::debug!("sending COBS encoded packet: {:?}", encoded);
|
||||||
self.serial.write_all(&encoded)?;
|
self.serial.write_all(&encoded)?;
|
||||||
@@ -57,7 +57,7 @@ impl PacketTransportSerialCobs {
|
|||||||
/// This function pulls bytes from the serial port and feeds them into the COBS decoder.
|
/// This function pulls bytes from the serial port and feeds them into the COBS decoder.
|
||||||
/// For each received packet, the closure will be called with the decoded packet as an argument.
|
/// For each received packet, the closure will be called with the decoded packet as an argument.
|
||||||
/// The function will return the number of received packets.
|
/// The function will return the number of received packets.
|
||||||
fn receive<F: FnMut(&[u8])>(&mut self, mut f: F) -> Result<usize, super::ReceiveError> {
|
pub fn receive<F: FnMut(&[u8])>(&mut self, mut f: F) -> Result<usize, super::ReceiveError> {
|
||||||
let mut decoded_packets = 0;
|
let mut decoded_packets = 0;
|
||||||
loop {
|
loop {
|
||||||
let read_bytes = self.serial.read(&mut self.reception_buffer)?;
|
let read_bytes = self.serial.read(&mut self.reception_buffer)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user