修改命令处理

This commit is contained in:
lbl8603
2024-06-06 21:39:46 +08:00
parent cb6101a835
commit a5a43e762d
+12 -4
View File
@@ -7,7 +7,7 @@ use std::time::Duration;
use crate::command::entity::{DeviceItem, Info, RouteItem}; use crate::command::entity::{DeviceItem, Info, RouteItem};
pub struct CommandClient { pub struct CommandClient {
buf: [u8; 10240], buf: Vec<u8>,
udp: UdpSocket, udp: UdpSocket,
} }
@@ -25,7 +25,7 @@ impl CommandClient {
)))?; )))?;
Ok(Self { Ok(Self {
udp, udp,
buf: [0; 10240], buf: vec![0; 65536 * 8],
}) })
} }
} }
@@ -59,8 +59,16 @@ impl CommandClient {
match serde_yaml::from_slice::<V>(&self.buf[..len]) { match serde_yaml::from_slice::<V>(&self.buf[..len]) {
Ok(val) => Ok(val), Ok(val) => Ok(val),
Err(e) => { Err(e) => {
log::error!("{:?},{:?}", &self.buf[..len], e); log::error!(
Err(io::Error::new(io::ErrorKind::Other, "data error")) "send_cmd {:?} {:?},{:?}",
std::str::from_utf8(cmd),
std::str::from_utf8(&self.buf[..len]),
e
);
Err(io::Error::new(
io::ErrorKind::Other,
format!("data error {:?} buf_len={}", e, len),
))
} }
} }
} }