cyw43: log ioctls.

This commit is contained in:
Dario Nieuwenhuis 2024-09-09 01:03:41 +02:00
parent 3ac38e917c
commit 6b21f6d3d1
2 changed files with 13 additions and 5 deletions

View File

@ -481,7 +481,7 @@ impl<'a> Control<'a> {
} }
async fn set_iovar_v<const BUFSIZE: usize>(&mut self, name: &str, val: &[u8]) { async fn set_iovar_v<const BUFSIZE: usize>(&mut self, name: &str, val: &[u8]) {
debug!("set {} = {:02x}", name, Bytes(val)); debug!("iovar set {} = {:02x}", name, Bytes(val));
let mut buf = [0; BUFSIZE]; let mut buf = [0; BUFSIZE];
buf[..name.len()].copy_from_slice(name.as_bytes()); buf[..name.len()].copy_from_slice(name.as_bytes());
@ -489,13 +489,13 @@ impl<'a> Control<'a> {
buf[name.len() + 1..][..val.len()].copy_from_slice(val); buf[name.len() + 1..][..val.len()].copy_from_slice(val);
let total_len = name.len() + 1 + val.len(); let total_len = name.len() + 1 + val.len();
self.ioctl(IoctlType::Set, Ioctl::SetVar, 0, &mut buf[..total_len]) self.ioctl_inner(IoctlType::Set, Ioctl::SetVar, 0, &mut buf[..total_len])
.await; .await;
} }
// TODO this is not really working, it always returns all zeros. // TODO this is not really working, it always returns all zeros.
async fn get_iovar(&mut self, name: &str, res: &mut [u8]) -> usize { async fn get_iovar(&mut self, name: &str, res: &mut [u8]) -> usize {
debug!("get {}", name); debug!("iovar get {}", name);
let mut buf = [0; 64]; let mut buf = [0; 64];
buf[..name.len()].copy_from_slice(name.as_bytes()); buf[..name.len()].copy_from_slice(name.as_bytes());
@ -503,7 +503,7 @@ impl<'a> Control<'a> {
let total_len = max(name.len() + 1, res.len()); let total_len = max(name.len() + 1, res.len());
let res_len = self let res_len = self
.ioctl(IoctlType::Get, Ioctl::GetVar, 0, &mut buf[..total_len]) .ioctl_inner(IoctlType::Get, Ioctl::GetVar, 0, &mut buf[..total_len])
.await; .await;
let out_len = min(res.len(), res_len); let out_len = min(res.len(), res_len);
@ -517,6 +517,14 @@ impl<'a> Control<'a> {
} }
async fn ioctl(&mut self, kind: IoctlType, cmd: Ioctl, iface: u32, buf: &mut [u8]) -> usize { async fn ioctl(&mut self, kind: IoctlType, cmd: Ioctl, iface: u32, buf: &mut [u8]) -> usize {
if kind == IoctlType::Set {
debug!("ioctl set {:?} iface {} = {:02x}", cmd, iface, Bytes(buf));
}
let n = self.ioctl_inner(kind, cmd, iface, buf).await;
n
}
async fn ioctl_inner(&mut self, kind: IoctlType, cmd: Ioctl, iface: u32, buf: &mut [u8]) -> usize {
struct CancelOnDrop<'a>(&'a IoctlState); struct CancelOnDrop<'a>(&'a IoctlState);
impl CancelOnDrop<'_> { impl CancelOnDrop<'_> {

View File

@ -7,7 +7,7 @@ use embassy_sync::waitqueue::WakerRegistration;
use crate::consts::Ioctl; use crate::consts::Ioctl;
use crate::fmt::Bytes; use crate::fmt::Bytes;
#[derive(Clone, Copy)] #[derive(Clone, Copy, PartialEq, Eq)]
pub enum IoctlType { pub enum IoctlType {
Get = 0, Get = 0,
Set = 2, Set = 2,