forked from M-Labs/artiq-zynq
moninj: decode host messages
This commit is contained in:
parent
b310e068d4
commit
531dd956d3
@ -59,6 +59,27 @@ async fn handle_connection(stream: &TcpStream) -> Result<()> {
|
||||
let message: HostMessage = FromPrimitive::from_i8(read_i8(&stream).await?)
|
||||
.ok_or(Error::UnrecognizedPacket)?;
|
||||
info!("{:?}", message);
|
||||
match message {
|
||||
HostMessage::MonitorProbe => {
|
||||
let enable = read_bool(&stream).await?;
|
||||
let channel = read_i32(&stream).await?;
|
||||
let probe = read_i8(&stream).await?;
|
||||
},
|
||||
HostMessage::Inject => {
|
||||
let channel = read_i32(&stream).await?;
|
||||
let overrd = read_i8(&stream).await?;
|
||||
let value = read_i8(&stream).await?;
|
||||
},
|
||||
HostMessage::GetInjectionStatus => {
|
||||
let channel = read_i32(&stream).await?;
|
||||
let overrd = read_i8(&stream).await?;
|
||||
},
|
||||
HostMessage::MonitorInjection => {
|
||||
let enable = read_bool(&stream).await?;
|
||||
let channel = read_i32(&stream).await?;
|
||||
let overrd = read_i8(&stream).await?;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,12 @@ pub async fn expect(stream: &TcpStream, pattern: &[u8]) -> Result<bool> {
|
||||
}).await?
|
||||
}
|
||||
|
||||
pub async fn read_bool(stream: &TcpStream) -> Result<bool> {
|
||||
Ok(stream.recv(|buf| {
|
||||
Poll::Ready((1, buf[0] != 0))
|
||||
}).await?)
|
||||
}
|
||||
|
||||
pub async fn read_i8(stream: &TcpStream) -> Result<i8> {
|
||||
Ok(stream.recv(|buf| {
|
||||
Poll::Ready((1, buf[0] as i8))
|
||||
|
Loading…
Reference in New Issue
Block a user