forked from M-Labs/artiq-zynq
Compare commits
3 Commits
6590084a1f
...
dd32b6fe3f
Author | SHA1 | Date |
---|---|---|
occheung | dd32b6fe3f | |
occheung | 246ba6795e | |
occheung | bfa9327a8e |
|
@ -154,7 +154,7 @@ mod remote_coremgmt {
|
|||
) -> Result<()> {
|
||||
let mut buffer = Vec::new();
|
||||
loop {
|
||||
match drtio::aux_transact(
|
||||
let reply = drtio::aux_transact(
|
||||
aux_mutex,
|
||||
linkno,
|
||||
routing_table,
|
||||
|
@ -164,9 +164,10 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?
|
||||
{
|
||||
Packet::CoreMgmtGetLogReply { last, length, data } => {
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Ok(Packet::CoreMgmtGetLogReply { last, length, data }) => {
|
||||
buffer.extend(&data[..length as usize]);
|
||||
if last {
|
||||
write_i8(stream, Reply::LogContent as i8).await?;
|
||||
|
@ -174,10 +175,16 @@ mod remote_coremgmt {
|
|||
return Ok(());
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
return Err(drtio::Error::UnexpectedReply.into());
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -197,16 +204,22 @@ mod remote_coremgmt {
|
|||
&Packet::CoreMgmtClearLogRequest { destination },
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Packet::CoreMgmtAck => {
|
||||
Ok(Packet::CoreMgmtAck) => {
|
||||
write_i8(stream, Reply::Success as i8).await?;
|
||||
Ok(())
|
||||
}
|
||||
_ => {
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
return Err(drtio::Error::UnexpectedReply.into());
|
||||
Err(drtio::Error::UnexpectedReply.into())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +245,7 @@ mod remote_coremgmt {
|
|||
break;
|
||||
}
|
||||
|
||||
match drtio::aux_transact(
|
||||
let reply = drtio::aux_transact(
|
||||
aux_mutex,
|
||||
linkno,
|
||||
routing_table,
|
||||
|
@ -242,13 +255,20 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await
|
||||
{
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Ok(Packet::CoreMgmtGetLogReply { last: _, length, data }) => {
|
||||
write_chunk(stream, &data[..length as usize]).await?;
|
||||
}
|
||||
|
||||
_ => return Err(drtio::Error::UnexpectedReply.into()),
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
return Err(drtio::Error::UnexpectedReply.into());
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,16 +294,22 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Packet::CoreMgmtAck => {
|
||||
Ok(Packet::CoreMgmtAck) => {
|
||||
write_i8(stream, Reply::Success as i8).await?;
|
||||
Ok(())
|
||||
}
|
||||
_ => {
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
return Err(drtio::Error::UnexpectedReply.into());
|
||||
Err(drtio::Error::UnexpectedReply.into())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -307,16 +333,22 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Packet::CoreMgmtAck => {
|
||||
Ok(Packet::CoreMgmtAck) => {
|
||||
write_i8(stream, Reply::Success as i8).await?;
|
||||
Ok(())
|
||||
}
|
||||
_ => {
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
return Err(drtio::Error::UnexpectedReply.into());
|
||||
Err(drtio::Error::UnexpectedReply.into())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,12 +378,12 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
let mut buffer = Vec::<u8>::new();
|
||||
loop {
|
||||
match reply {
|
||||
Packet::CoreMgmtConfigReadReply { last, length, value } => {
|
||||
Ok(Packet::CoreMgmtConfigReadReply { last, length, value }) => {
|
||||
buffer.extend(&value[..length as usize]);
|
||||
|
||||
if last {
|
||||
|
@ -369,13 +401,18 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
}
|
||||
|
||||
_ => {
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
return Err(drtio::Error::UnexpectedReply.into());
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -409,9 +446,9 @@ mod remote_coremgmt {
|
|||
},
|
||||
|reply| match reply {
|
||||
Packet::CoreMgmtAck => Ok(()),
|
||||
_ => {
|
||||
error!("received unknown packet");
|
||||
Err(drtio::Error::UnexpectedReply.into())
|
||||
packet => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
Err(drtio::Error::UnexpectedReply)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@ -421,9 +458,10 @@ mod remote_coremgmt {
|
|||
write_i8(stream, Reply::Success as i8).await?;
|
||||
Ok(())
|
||||
}
|
||||
error => {
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
error
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -453,17 +491,23 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Packet::CoreMgmtAck => {
|
||||
Ok(Packet::CoreMgmtAck) => {
|
||||
write_i8(stream, Reply::Success as i8).await?;
|
||||
Ok(())
|
||||
}
|
||||
_ => {
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(drtio::Error::UnexpectedReply.into())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,17 +528,23 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Packet::CoreMgmtAck => {
|
||||
Ok(Packet::CoreMgmtAck) => {
|
||||
write_i8(stream, Reply::Success as i8).await?;
|
||||
Ok(())
|
||||
}
|
||||
_ => {
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(drtio::Error::UnexpectedReply.into())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,18 +566,23 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Packet::CoreMgmtAck => {
|
||||
Ok(Packet::CoreMgmtAck) => {
|
||||
write_i8(stream, Reply::RebootImminent as i8).await?;
|
||||
Ok(())
|
||||
}
|
||||
_ => {
|
||||
error!("received unknown packet");
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(drtio::Error::UnexpectedReply.into())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,18 +603,21 @@ mod remote_coremgmt {
|
|||
},
|
||||
timer,
|
||||
)
|
||||
.await?;
|
||||
.await;
|
||||
|
||||
match reply {
|
||||
Packet::CoreMgmtAck => {
|
||||
Ok(Packet::CoreMgmtAck) => {
|
||||
write_i8(stream, Reply::Success as i8).await?;
|
||||
Ok(())
|
||||
}
|
||||
_ => {
|
||||
error!("received unknown packet");
|
||||
write_i8(stream, Reply::Error as i8).await?;
|
||||
Ok(packet) => {
|
||||
error!("received unexpected aux packet: {:?}", packet);
|
||||
Err(drtio::Error::UnexpectedReply.into())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -581,7 +639,7 @@ mod local_coremgmt {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn pull_log<'a>(stream: &'a mut TcpStream, pull_id: &Rc<RefCell<u32>>) -> Result<()> {
|
||||
pub async fn pull_log(stream: &mut TcpStream, pull_id: &Rc<RefCell<u32>>) -> Result<()> {
|
||||
let id = {
|
||||
let mut guard = pull_id.borrow_mut();
|
||||
*guard += 1;
|
||||
|
@ -638,12 +696,7 @@ mod local_coremgmt {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn config_write<'a>(
|
||||
stream: &mut TcpStream,
|
||||
cfg: &Rc<Config>,
|
||||
key: &'a String,
|
||||
value: Vec<u8>,
|
||||
) -> Result<()> {
|
||||
pub async fn config_write(stream: &mut TcpStream, cfg: &Rc<Config>, key: &String, value: Vec<u8>) -> Result<()> {
|
||||
let value = cfg.write(&key, value);
|
||||
if value.is_ok() {
|
||||
debug!("write success");
|
||||
|
@ -656,7 +709,7 @@ mod local_coremgmt {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn config_remove<'a>(stream: &mut TcpStream, cfg: &Rc<Config>, key: &'a String) -> Result<()> {
|
||||
pub async fn config_remove(stream: &mut TcpStream, cfg: &Rc<Config>, key: &String) -> Result<()> {
|
||||
let value = cfg.remove(&key);
|
||||
if value.is_ok() {
|
||||
debug!("erase success");
|
||||
|
|
Loading…
Reference in New Issue