Debugging

This commit is contained in:
Bastian Gruber 2023-05-21 15:15:16 +02:00
parent 66b9850ed6
commit 7812743369
No known key found for this signature in database
GPG key ID: BE9F8C772B188CBF
2 changed files with 6 additions and 2 deletions

View file

@ -13,7 +13,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let (mut read, mut write) = stream.split();
// test_all_different_messages(&mut write).await?;
test_camera_connection(&mut write).await?;
// test_camera_connection(&mut write).await?;
test_dipatcher_connection(&mut write).await?;
let mut buf: [u8; 4] = [0; 4];

View file

@ -1,7 +1,7 @@
use std::{fmt, io::Cursor, num::TryFromIntError, string::FromUtf8Error};
use bytes::{Buf, BufMut, BytesMut};
use tracing::{debug, error};
use tracing::{debug, error, info};
#[derive(Clone, Debug)]
pub enum ClientFrames {
@ -77,8 +77,10 @@ impl ClientFrames {
}
// IAmDispatcher: numroads: u8, roads: [u16]
0x81 => {
info!("Checking IAmDispatcher message: {src:?}");
// numroads
let amount = get_u8(src)? * 2;
info!("amount of roads: {amount:?}");
// roads
skip(src, amount as usize)?;
Ok(())
@ -221,6 +223,7 @@ fn get_u16_vec<'a>(src: &mut Cursor<&'a [u8]>, len: usize) -> Result<Vec<u16>, E
}
fn skip(src: &mut Cursor<&[u8]>, n: usize) -> Result<(), Error> {
info!("Check if message is long enouhg: {src:?}, {n:?}");
if src.remaining() < n {
return Err(Error::Incomplete);
}