forked from M-Labs/artiq-zynq
master: moninj supports local and remote with dispatch
This commit is contained in:
parent
241113c6b2
commit
589c4bebe4
@ -131,7 +131,7 @@ mod local_moninj {
|
|||||||
|
|
||||||
#[cfg(has_drtio)]
|
#[cfg(has_drtio)]
|
||||||
macro_rules! dispatch {
|
macro_rules! dispatch {
|
||||||
($routing_table:ident, $channel:expr, $func:ident $(, $param:expr)*) => {{
|
($aux_mutex:ident, $routing_table:ident, $channel:expr, $func:ident $(, $param:expr)*) => {{
|
||||||
let destination = ($channel >> 16) as u8;
|
let destination = ($channel >> 16) as u8;
|
||||||
let channel = $channel as u16;
|
let channel = $channel as u16;
|
||||||
let hop = $routing_table.0[destination as usize][0];
|
let hop = $routing_table.0[destination as usize][0];
|
||||||
@ -139,20 +139,21 @@ macro_rules! dispatch {
|
|||||||
local_moninj::$func(channel, $($param, )*)
|
local_moninj::$func(channel, $($param, )*)
|
||||||
} else {
|
} else {
|
||||||
let linkno = hop - 1;
|
let linkno = hop - 1;
|
||||||
remote_moninj::$func(linkno, destination, channel, $($param, )*)
|
remote_moninj::$func($aux_mutex, linkno, destination, channel, $($param, )*)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(has_drtio))]
|
#[cfg(not(has_drtio))]
|
||||||
macro_rules! dispatch {
|
macro_rules! dispatch {
|
||||||
($routing_table:ident, $channel:expr, $func:ident $(, $param:expr)*) => {{
|
($aux_mutex:ident, $routing_table:ident, $channel:expr, $func:ident $(, $param:expr)*) => {{
|
||||||
let channel = $channel as u16;
|
let channel = $channel as u16;
|
||||||
local_moninj::$func(channel, $($param, )*)
|
local_moninj::$func(channel, $($param, )*)
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_connection(stream: &TcpStream, timer: GlobalTimer) -> Result<()> {
|
async fn handle_connection(stream: &TcpStream, timer: GlobalTimer,
|
||||||
|
_aux_mutex: &Mutex, _routing_table: &drtio_routing::RoutingTable) -> Result<()> {
|
||||||
if !expect(&stream, b"ARTIQ moninj\n").await? {
|
if !expect(&stream, b"ARTIQ moninj\n").await? {
|
||||||
return Err(Error::UnexpectedPattern);
|
return Err(Error::UnexpectedPattern);
|
||||||
}
|
}
|
||||||
@ -208,13 +209,13 @@ async fn handle_connection(stream: &TcpStream, timer: GlobalTimer) -> Result<()>
|
|||||||
let channel = read_i32(&stream).await?;
|
let channel = read_i32(&stream).await?;
|
||||||
let overrd = read_i8(&stream).await?;
|
let overrd = read_i8(&stream).await?;
|
||||||
let value = read_i8(&stream).await?;
|
let value = read_i8(&stream).await?;
|
||||||
inject(channel, overrd, value);
|
dispatch!(_aux_mutex, _routing_table, channel, inject, overrd, value);
|
||||||
debug!("INJECT channel {}, overrd {}, value {}", channel, overrd, value);
|
debug!("INJECT channel {}, overrd {}, value {}", channel, overrd, value);
|
||||||
},
|
},
|
||||||
HostMessage::GetInjectionStatus => {
|
HostMessage::GetInjectionStatus => {
|
||||||
let channel = read_i32(&stream).await?;
|
let channel = read_i32(&stream).await?;
|
||||||
let overrd = read_i8(&stream).await?;
|
let overrd = read_i8(&stream).await?;
|
||||||
let value = read_injection_status(channel, overrd);
|
let value = dispatch!(_aux_mutex, _routing_table, channel, read_injection_status, overrd);
|
||||||
write_i8(&stream, DeviceMessage::InjectionStatus.to_i8().unwrap()).await?;
|
write_i8(&stream, DeviceMessage::InjectionStatus.to_i8().unwrap()).await?;
|
||||||
write_i32(&stream, channel).await?;
|
write_i32(&stream, channel).await?;
|
||||||
write_i8(&stream, overrd).await?;
|
write_i8(&stream, overrd).await?;
|
||||||
@ -224,7 +225,7 @@ async fn handle_connection(stream: &TcpStream, timer: GlobalTimer) -> Result<()>
|
|||||||
},
|
},
|
||||||
_ = timeout_f => {
|
_ = timeout_f => {
|
||||||
for (&(channel, probe), previous) in probe_watch_list.iter_mut() {
|
for (&(channel, probe), previous) in probe_watch_list.iter_mut() {
|
||||||
let current = read_probe(channel, probe);
|
let current = dispatch!(_aux_mutex, _routing_table, channel, read_probe, probe);
|
||||||
if previous.is_none() || previous.unwrap() != current {
|
if previous.is_none() || previous.unwrap() != current {
|
||||||
write_i8(&stream, DeviceMessage::MonitorStatus.to_i8().unwrap()).await?;
|
write_i8(&stream, DeviceMessage::MonitorStatus.to_i8().unwrap()).await?;
|
||||||
write_i32(&stream, channel).await?;
|
write_i32(&stream, channel).await?;
|
||||||
@ -234,7 +235,7 @@ async fn handle_connection(stream: &TcpStream, timer: GlobalTimer) -> Result<()>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (&(channel, overrd), previous) in inject_watch_list.iter_mut() {
|
for (&(channel, overrd), previous) in inject_watch_list.iter_mut() {
|
||||||
let current = read_injection_status(channel, overrd);
|
let current = dispatch!(_aux_mutex, _routing_table, channel, read_injection_status, overrd);
|
||||||
if previous.is_none() || previous.unwrap() != current {
|
if previous.is_none() || previous.unwrap() != current {
|
||||||
write_i8(&stream, DeviceMessage::InjectionStatus.to_i8().unwrap()).await?;
|
write_i8(&stream, DeviceMessage::InjectionStatus.to_i8().unwrap()).await?;
|
||||||
write_i32(&stream, channel).await?;
|
write_i32(&stream, channel).await?;
|
||||||
|
Loading…
Reference in New Issue
Block a user