forked from M-Labs/artiq
firmware: simplify drtioaux function names
This commit is contained in:
parent
ae72e3a51e
commit
d19550daf8
@ -80,7 +80,7 @@ fn receive<F, T>(linkno: u8, f: F) -> Result<Option<T>, Error<!>>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn recv_link(linkno: u8) -> Result<Option<Packet>, Error<!>> {
|
||||
pub fn recv(linkno: u8) -> Result<Option<Packet>, Error<!>> {
|
||||
if has_rx_error(linkno) {
|
||||
return Err(Error::GatewareError)
|
||||
}
|
||||
@ -104,11 +104,11 @@ pub fn recv_link(linkno: u8) -> Result<Option<Packet>, Error<!>> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn recv_timeout_link(linkno: u8, timeout_ms: Option<u64>) -> Result<Packet, Error<!>> {
|
||||
pub fn recv_timeout(linkno: u8, timeout_ms: Option<u64>) -> Result<Packet, Error<!>> {
|
||||
let timeout_ms = timeout_ms.unwrap_or(10);
|
||||
let limit = clock::get_ms() + timeout_ms;
|
||||
while clock::get_ms() < limit {
|
||||
match recv_link(linkno)? {
|
||||
match recv(linkno)? {
|
||||
None => (),
|
||||
Some(packet) => return Ok(packet),
|
||||
}
|
||||
@ -131,7 +131,7 @@ fn transmit<F>(linkno: u8, f: F) -> Result<(), Error<!>>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_link(linkno: u8, packet: &Packet) -> Result<(), Error<!>> {
|
||||
pub fn send(linkno: u8, packet: &Packet) -> Result<(), Error<!>> {
|
||||
transmit(linkno, |buffer| {
|
||||
let mut writer = Cursor::new(buffer);
|
||||
|
||||
|
@ -11,7 +11,7 @@ mod remote_i2c {
|
||||
use drtioaux;
|
||||
|
||||
fn basic_reply(linkno: u8) -> Result<(), ()> {
|
||||
match drtioaux::recv_timeout_link(linkno, None) {
|
||||
match drtioaux::recv_timeout(linkno, None) {
|
||||
Ok(drtioaux::Packet::I2cBasicReply { succeeded }) => {
|
||||
if succeeded { Ok(()) } else { Err(()) }
|
||||
}
|
||||
@ -31,7 +31,7 @@ mod remote_i2c {
|
||||
destination: destination,
|
||||
busno: busno
|
||||
};
|
||||
if drtioaux::send_link(linkno, &request).is_err() {
|
||||
if drtioaux::send(linkno, &request).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
basic_reply(linkno)
|
||||
@ -42,7 +42,7 @@ mod remote_i2c {
|
||||
destination: destination,
|
||||
busno: busno
|
||||
};
|
||||
if drtioaux::send_link(linkno, &request).is_err() {
|
||||
if drtioaux::send(linkno, &request).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
basic_reply(linkno)
|
||||
@ -53,7 +53,7 @@ mod remote_i2c {
|
||||
destination: destination,
|
||||
busno: busno
|
||||
};
|
||||
if drtioaux::send_link(linkno, &request).is_err() {
|
||||
if drtioaux::send(linkno, &request).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
basic_reply(linkno)
|
||||
@ -65,10 +65,10 @@ mod remote_i2c {
|
||||
busno: busno,
|
||||
data: data
|
||||
};
|
||||
if drtioaux::send_link(linkno, &request).is_err() {
|
||||
if drtioaux::send(linkno, &request).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
match drtioaux::recv_timeout_link(linkno, None) {
|
||||
match drtioaux::recv_timeout(linkno, None) {
|
||||
Ok(drtioaux::Packet::I2cWriteReply { succeeded, ack }) => {
|
||||
if succeeded { Ok(ack) } else { Err(()) }
|
||||
}
|
||||
@ -89,10 +89,10 @@ mod remote_i2c {
|
||||
busno: busno,
|
||||
ack: ack
|
||||
};
|
||||
if drtioaux::send_link(linkno, &request).is_err() {
|
||||
if drtioaux::send(linkno, &request).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
match drtioaux::recv_timeout_link(linkno, None) {
|
||||
match drtioaux::recv_timeout(linkno, None) {
|
||||
Ok(drtioaux::Packet::I2cReadReply { succeeded, data }) => {
|
||||
if succeeded { Ok(data) } else { Err(()) }
|
||||
}
|
||||
@ -113,7 +113,7 @@ mod remote_spi {
|
||||
use drtioaux;
|
||||
|
||||
fn basic_reply(linkno: u8) -> Result<(), ()> {
|
||||
match drtioaux::recv_timeout_link(linkno, None) {
|
||||
match drtioaux::recv_timeout(linkno, None) {
|
||||
Ok(drtioaux::Packet::SpiBasicReply { succeeded }) => {
|
||||
if succeeded { Ok(()) } else { Err(()) }
|
||||
}
|
||||
@ -137,7 +137,7 @@ mod remote_spi {
|
||||
div: div,
|
||||
cs: cs
|
||||
};
|
||||
if drtioaux::send_link(linkno, &request).is_err() {
|
||||
if drtioaux::send(linkno, &request).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
basic_reply(linkno)
|
||||
@ -149,7 +149,7 @@ mod remote_spi {
|
||||
busno: busno,
|
||||
data: data
|
||||
};
|
||||
if drtioaux::send_link(linkno, &request).is_err() {
|
||||
if drtioaux::send(linkno, &request).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
basic_reply(linkno)
|
||||
@ -160,10 +160,10 @@ mod remote_spi {
|
||||
destination: destination,
|
||||
busno: busno
|
||||
};
|
||||
if drtioaux::send_link(linkno, &request).is_err() {
|
||||
if drtioaux::send(linkno, &request).is_err() {
|
||||
return Err(())
|
||||
}
|
||||
match drtioaux::recv_timeout_link(linkno, None) {
|
||||
match drtioaux::recv_timeout(linkno, None) {
|
||||
Ok(drtioaux::Packet::SpiReadReply { succeeded, data }) => {
|
||||
if succeeded { Ok(data) } else { Err(()) }
|
||||
}
|
||||
|
@ -57,14 +57,14 @@ mod remote_moninj {
|
||||
channel: channel,
|
||||
probe: probe
|
||||
};
|
||||
match drtioaux::send_link(linkno, &request) {
|
||||
match drtioaux::send(linkno, &request) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
match drtioaux::recv_timeout_link(linkno, None) {
|
||||
match drtioaux::recv_timeout(linkno, None) {
|
||||
Ok(drtioaux::Packet::MonitorReply { value }) => return value,
|
||||
Ok(_) => error!("received unexpected aux packet"),
|
||||
Err(e) => error!("aux packet error ({})", e)
|
||||
@ -79,7 +79,7 @@ mod remote_moninj {
|
||||
overrd: overrd,
|
||||
value: value
|
||||
};
|
||||
match drtioaux::send_link(linkno, &request) {
|
||||
match drtioaux::send(linkno, &request) {
|
||||
Ok(_) => (),
|
||||
Err(e) => error!("aux packet error ({})", e)
|
||||
}
|
||||
@ -91,14 +91,14 @@ mod remote_moninj {
|
||||
channel: channel,
|
||||
overrd: overrd
|
||||
};
|
||||
match drtioaux::send_link(linkno, &request) {
|
||||
match drtioaux::send(linkno, &request) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
error!("aux packet error ({})", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
match drtioaux::recv_timeout_link(linkno, None) {
|
||||
match drtioaux::recv_timeout(linkno, None) {
|
||||
Ok(drtioaux::Packet::InjectionStatusReply { value }) => return value,
|
||||
Ok(_) => error!("received unexpected aux packet"),
|
||||
Err(e) => error!("aux packet error ({})", e)
|
||||
|
@ -93,9 +93,9 @@ pub mod drtio {
|
||||
if count > 200 {
|
||||
return 0;
|
||||
}
|
||||
drtioaux::send_link(linkno, &drtioaux::Packet::EchoRequest).unwrap();
|
||||
drtioaux::send(linkno, &drtioaux::Packet::EchoRequest).unwrap();
|
||||
io.sleep(100).unwrap();
|
||||
let pr = drtioaux::recv_link(linkno);
|
||||
let pr = drtioaux::recv(linkno);
|
||||
match pr {
|
||||
Ok(Some(drtioaux::Packet::EchoReply)) => return count,
|
||||
_ => {}
|
||||
@ -112,7 +112,7 @@ pub mod drtio {
|
||||
if clock::get_ms() > max_time {
|
||||
return Err("timeout");
|
||||
}
|
||||
match drtioaux::recv_link(linkno) {
|
||||
match drtioaux::recv(linkno) {
|
||||
Ok(Some(packet)) => return Ok(packet),
|
||||
Ok(None) => (),
|
||||
Err(_) => return Err("aux packet error")
|
||||
@ -139,7 +139,7 @@ pub mod drtio {
|
||||
fn load_routing_table(io: &Io, linkno: u8, routing_table: &drtio_routing::RoutingTable)
|
||||
-> Result<(), &'static str> {
|
||||
for i in 0..drtio_routing::DEST_COUNT {
|
||||
drtioaux::send_link(linkno, &drtioaux::Packet::RoutingSetPath {
|
||||
drtioaux::send(linkno, &drtioaux::Packet::RoutingSetPath {
|
||||
destination: i as u8,
|
||||
hops: routing_table.0[i]
|
||||
}).unwrap();
|
||||
@ -152,7 +152,7 @@ pub mod drtio {
|
||||
}
|
||||
|
||||
fn set_rank(io: &Io, linkno: u8, rank: u8) -> Result<(), &'static str> {
|
||||
drtioaux::send_link(linkno, &drtioaux::Packet::RoutingSetRank {
|
||||
drtioaux::send(linkno, &drtioaux::Packet::RoutingSetRank {
|
||||
rank: rank
|
||||
}).unwrap();
|
||||
let reply = recv_aux_timeout(io, linkno, 200)?;
|
||||
@ -176,7 +176,7 @@ pub mod drtio {
|
||||
}
|
||||
|
||||
fn process_unsolicited_aux(linkno: u8) {
|
||||
match drtioaux::recv_link(linkno) {
|
||||
match drtioaux::recv(linkno) {
|
||||
Ok(Some(packet)) => warn!("[LINK#{}] unsolicited aux packet: {:?}", linkno, packet),
|
||||
Ok(None) => (),
|
||||
Err(_) => warn!("[LINK#{}] aux packet error", linkno)
|
||||
@ -219,7 +219,7 @@ pub mod drtio {
|
||||
let linkno = hop - 1;
|
||||
if up_destinations[destination] {
|
||||
if link_up(linkno) {
|
||||
drtioaux::send_link(linkno, &drtioaux::Packet::DestinationStatusRequest {
|
||||
drtioaux::send(linkno, &drtioaux::Packet::DestinationStatusRequest {
|
||||
destination: destination as u8
|
||||
}).unwrap();
|
||||
match recv_aux_timeout(io, linkno, 200) {
|
||||
@ -243,7 +243,7 @@ pub mod drtio {
|
||||
}
|
||||
} else {
|
||||
if link_up(linkno) {
|
||||
drtioaux::send_link(linkno, &drtioaux::Packet::DestinationStatusRequest {
|
||||
drtioaux::send(linkno, &drtioaux::Packet::DestinationStatusRequest {
|
||||
destination: destination as u8
|
||||
}).unwrap();
|
||||
match recv_aux_timeout(io, linkno, 200) {
|
||||
@ -309,9 +309,9 @@ pub mod drtio {
|
||||
for linkno in 0..csr::DRTIO.len() {
|
||||
let linkno = linkno as u8;
|
||||
if link_up(linkno) {
|
||||
drtioaux::send_link(linkno,
|
||||
drtioaux::send(linkno,
|
||||
&drtioaux::Packet::ResetRequest { phy: false }).unwrap();
|
||||
match drtioaux::recv_timeout_link(linkno, None) {
|
||||
match drtioaux::recv_timeout(linkno, None) {
|
||||
Ok(drtioaux::Packet::ResetAck) => (),
|
||||
Ok(_) => error!("[LINK#{}] reset failed, received unexpected aux packet", linkno),
|
||||
Err(e) => error!("[LINK#{}] reset failed, aux packet error ({})", linkno, e)
|
||||
|
@ -74,7 +74,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
// and u16 otherwise; hence the `as _` conversion.
|
||||
match packet {
|
||||
drtioaux::Packet::EchoRequest =>
|
||||
drtioaux::send_link(0, &drtioaux::Packet::EchoReply),
|
||||
drtioaux::send(0, &drtioaux::Packet::EchoReply),
|
||||
drtioaux::Packet::ResetRequest { phy } => {
|
||||
info!("resetting RTIO");
|
||||
if phy {
|
||||
@ -89,7 +89,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
error!("failed to issue RTIO reset ({})", e);
|
||||
}
|
||||
}
|
||||
drtioaux::send_link(0, &drtioaux::Packet::ResetAck)
|
||||
drtioaux::send(0, &drtioaux::Packet::ResetAck)
|
||||
},
|
||||
|
||||
drtioaux::Packet::DestinationStatusRequest { destination } => {
|
||||
@ -109,7 +109,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
channel = csr::drtiosat::sequence_error_channel_read();
|
||||
csr::drtiosat::rtio_error_write(1);
|
||||
}
|
||||
drtioaux::send_link(0,
|
||||
drtioaux::send(0,
|
||||
&drtioaux::Packet::DestinationSequenceErrorReply { channel })?;
|
||||
} else if errors & 2 != 0 {
|
||||
let channel;
|
||||
@ -117,7 +117,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
channel = csr::drtiosat::collision_channel_read();
|
||||
csr::drtiosat::rtio_error_write(2);
|
||||
}
|
||||
drtioaux::send_link(0,
|
||||
drtioaux::send(0,
|
||||
&drtioaux::Packet::DestinationCollisionReply { channel })?;
|
||||
} else if errors & 4 != 0 {
|
||||
let channel;
|
||||
@ -125,11 +125,11 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
channel = csr::drtiosat::busy_channel_read();
|
||||
csr::drtiosat::rtio_error_write(4);
|
||||
}
|
||||
drtioaux::send_link(0,
|
||||
drtioaux::send(0,
|
||||
&drtioaux::Packet::DestinationBusyReply { channel })?;
|
||||
}
|
||||
else {
|
||||
drtioaux::send_link(0, &drtioaux::Packet::DestinationOkReply)?;
|
||||
drtioaux::send(0, &drtioaux::Packet::DestinationOkReply)?;
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,14 +143,14 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
destination: destination
|
||||
}) {
|
||||
Ok(()) => (),
|
||||
Err(drtioaux::Error::LinkDown) => drtioaux::send_link(0, &drtioaux::Packet::DestinationDownReply)?,
|
||||
Err(drtioaux::Error::LinkDown) => drtioaux::send(0, &drtioaux::Packet::DestinationDownReply)?,
|
||||
Err(e) => {
|
||||
drtioaux::send_link(0, &drtioaux::Packet::DestinationDownReply)?;
|
||||
drtioaux::send(0, &drtioaux::Packet::DestinationDownReply)?;
|
||||
error!("aux error when handling destination status request: {}", e);
|
||||
},
|
||||
}
|
||||
} else {
|
||||
drtioaux::send_link(0, &drtioaux::Packet::DestinationDownReply)?;
|
||||
drtioaux::send(0, &drtioaux::Packet::DestinationDownReply)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
error!("failed to set path ({})", e);
|
||||
}
|
||||
}
|
||||
drtioaux::send_link(0, &drtioaux::Packet::RoutingAck)
|
||||
drtioaux::send(0, &drtioaux::Packet::RoutingAck)
|
||||
}
|
||||
#[cfg(has_drtio_routing)]
|
||||
drtioaux::Packet::RoutingSetRank { rank } => {
|
||||
@ -183,16 +183,16 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
info!("rank: {}", rank);
|
||||
info!("routing table: {}", _routing_table);
|
||||
|
||||
drtioaux::send_link(0, &drtioaux::Packet::RoutingAck)
|
||||
drtioaux::send(0, &drtioaux::Packet::RoutingAck)
|
||||
}
|
||||
|
||||
#[cfg(not(has_drtio_routing))]
|
||||
drtioaux::Packet::RoutingSetPath { destination, hops } => {
|
||||
drtioaux::send_link(0, &drtioaux::Packet::RoutingAck)
|
||||
drtioaux::send(0, &drtioaux::Packet::RoutingAck)
|
||||
}
|
||||
#[cfg(not(has_drtio_routing))]
|
||||
drtioaux::Packet::RoutingSetRank { rank } => {
|
||||
drtioaux::send_link(0, &drtioaux::Packet::RoutingAck)
|
||||
drtioaux::send(0, &drtioaux::Packet::RoutingAck)
|
||||
}
|
||||
|
||||
drtioaux::Packet::MonitorRequest { destination, channel, probe } => {
|
||||
@ -210,7 +210,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
value = 0;
|
||||
}
|
||||
let reply = drtioaux::Packet::MonitorReply { value: value as u32 };
|
||||
drtioaux::send_link(0, &reply)
|
||||
drtioaux::send(0, &reply)
|
||||
},
|
||||
drtioaux::Packet::InjectionRequest { destination, channel, overrd, value } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
@ -235,39 +235,39 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
drtioaux::send_link(0, &drtioaux::Packet::InjectionStatusReply { value: value })
|
||||
drtioaux::send(0, &drtioaux::Packet::InjectionStatusReply { value: value })
|
||||
},
|
||||
|
||||
drtioaux::Packet::I2cStartRequest { destination, busno } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
let succeeded = i2c::start(busno).is_ok();
|
||||
drtioaux::send_link(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||
drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||
}
|
||||
drtioaux::Packet::I2cRestartRequest { destination, busno } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
let succeeded = i2c::restart(busno).is_ok();
|
||||
drtioaux::send_link(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||
drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||
}
|
||||
drtioaux::Packet::I2cStopRequest { destination, busno } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
let succeeded = i2c::stop(busno).is_ok();
|
||||
drtioaux::send_link(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||
drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||
}
|
||||
drtioaux::Packet::I2cWriteRequest { destination, busno, data } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
match i2c::write(busno, data) {
|
||||
Ok(ack) => drtioaux::send_link(0,
|
||||
Ok(ack) => drtioaux::send(0,
|
||||
&drtioaux::Packet::I2cWriteReply { succeeded: true, ack: ack }),
|
||||
Err(_) => drtioaux::send_link(0,
|
||||
Err(_) => drtioaux::send(0,
|
||||
&drtioaux::Packet::I2cWriteReply { succeeded: false, ack: false })
|
||||
}
|
||||
}
|
||||
drtioaux::Packet::I2cReadRequest { destination, busno, ack } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
match i2c::read(busno, ack) {
|
||||
Ok(data) => drtioaux::send_link(0,
|
||||
Ok(data) => drtioaux::send(0,
|
||||
&drtioaux::Packet::I2cReadReply { succeeded: true, data: data }),
|
||||
Err(_) => drtioaux::send_link(0,
|
||||
Err(_) => drtioaux::send(0,
|
||||
&drtioaux::Packet::I2cReadReply { succeeded: false, data: 0xff })
|
||||
}
|
||||
}
|
||||
@ -275,21 +275,21 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
drtioaux::Packet::SpiSetConfigRequest { destination, busno, flags, length, div, cs } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
let succeeded = spi::set_config(busno, flags, length, div, cs).is_ok();
|
||||
drtioaux::send_link(0,
|
||||
drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiBasicReply { succeeded: succeeded })
|
||||
},
|
||||
drtioaux::Packet::SpiWriteRequest { destination, busno, data } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
let succeeded = spi::write(busno, data).is_ok();
|
||||
drtioaux::send_link(0,
|
||||
drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiBasicReply { succeeded: succeeded })
|
||||
}
|
||||
drtioaux::Packet::SpiReadRequest { destination, busno } => {
|
||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||
match spi::read(busno) {
|
||||
Ok(data) => drtioaux::send_link(0,
|
||||
Ok(data) => drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiReadReply { succeeded: true, data: data }),
|
||||
Err(_) => drtioaux::send_link(0,
|
||||
Err(_) => drtioaux::send(0,
|
||||
&drtioaux::Packet::SpiReadReply { succeeded: false, data: 0 })
|
||||
}
|
||||
}
|
||||
@ -304,7 +304,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||
fn process_aux_packets(repeaters: &mut [repeater::Repeater],
|
||||
routing_table: &mut drtio_routing::RoutingTable, rank: &mut u8) {
|
||||
let result =
|
||||
drtioaux::recv_link(0).and_then(|packet| {
|
||||
drtioaux::recv(0).and_then(|packet| {
|
||||
if let Some(packet) = packet {
|
||||
process_aux_packet(repeaters, routing_table, rank, packet)
|
||||
} else {
|
||||
@ -463,7 +463,7 @@ pub extern fn main() -> i32 {
|
||||
error!("failed to sync TSC ({})", e);
|
||||
}
|
||||
}
|
||||
if let Err(e) = drtioaux::send_link(0, &drtioaux::Packet::TSCAck) {
|
||||
if let Err(e) = drtioaux::send(0, &drtioaux::Packet::TSCAck) {
|
||||
error!("aux packet error: {}", e);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ impl Repeater {
|
||||
}
|
||||
RepeaterState::SendPing { ping_count } => {
|
||||
if rep_link_rx_up(self.repno) {
|
||||
drtioaux::send_link(self.auxno, &drtioaux::Packet::EchoRequest).unwrap();
|
||||
drtioaux::send(self.auxno, &drtioaux::Packet::EchoRequest).unwrap();
|
||||
self.state = RepeaterState::WaitPingReply {
|
||||
ping_count: ping_count + 1,
|
||||
timeout: clock::get_ms() + 100
|
||||
@ -63,7 +63,7 @@ impl Repeater {
|
||||
}
|
||||
RepeaterState::WaitPingReply { ping_count, timeout } => {
|
||||
if rep_link_rx_up(self.repno) {
|
||||
if let Ok(Some(drtioaux::Packet::EchoReply)) = drtioaux::recv_link(self.auxno) {
|
||||
if let Ok(Some(drtioaux::Packet::EchoReply)) = drtioaux::recv(self.auxno) {
|
||||
info!("[REP#{}] remote replied after {} packets", self.repno, ping_count);
|
||||
self.state = RepeaterState::Up;
|
||||
if let Err(e) = self.sync_tsc() {
|
||||
@ -113,7 +113,7 @@ impl Repeater {
|
||||
}
|
||||
|
||||
fn process_unsolicited_aux(&self) {
|
||||
match drtioaux::recv_link(self.auxno) {
|
||||
match drtioaux::recv(self.auxno) {
|
||||
Ok(Some(packet)) => warn!("[REP#{}] unsolicited aux packet: {:?}", self.repno, packet),
|
||||
Ok(None) => (),
|
||||
Err(_) => warn!("[REP#{}] aux packet error", self.repno)
|
||||
@ -162,7 +162,7 @@ impl Repeater {
|
||||
if clock::get_ms() > max_time {
|
||||
return Err(drtioaux::Error::TimedOut);
|
||||
}
|
||||
match drtioaux::recv_link(self.auxno) {
|
||||
match drtioaux::recv(self.auxno) {
|
||||
Ok(Some(packet)) => return Ok(packet),
|
||||
Ok(None) => (),
|
||||
Err(e) => return Err(e)
|
||||
@ -174,9 +174,9 @@ impl Repeater {
|
||||
if self.state != RepeaterState::Up {
|
||||
return Err(drtioaux::Error::LinkDown);
|
||||
}
|
||||
drtioaux::send_link(self.auxno, request).unwrap();
|
||||
drtioaux::send(self.auxno, request).unwrap();
|
||||
let reply = self.recv_aux_timeout(200)?;
|
||||
drtioaux::send_link(0, &reply).unwrap();
|
||||
drtioaux::send(0, &reply).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ impl Repeater {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
drtioaux::send_link(self.auxno, &drtioaux::Packet::RoutingSetPath {
|
||||
drtioaux::send(self.auxno, &drtioaux::Packet::RoutingSetPath {
|
||||
destination: destination,
|
||||
hops: *hops
|
||||
}).unwrap();
|
||||
@ -228,7 +228,7 @@ impl Repeater {
|
||||
if self.state != RepeaterState::Up {
|
||||
return Ok(());
|
||||
}
|
||||
drtioaux::send_link(self.auxno, &drtioaux::Packet::RoutingSetRank {
|
||||
drtioaux::send(self.auxno, &drtioaux::Packet::RoutingSetRank {
|
||||
rank: rank
|
||||
}).unwrap();
|
||||
let reply = self.recv_aux_timeout(200)?;
|
||||
@ -242,7 +242,7 @@ impl Repeater {
|
||||
if self.state != RepeaterState::Up {
|
||||
return Ok(());
|
||||
}
|
||||
drtioaux::send_link(self.auxno, &drtioaux::Packet::ResetRequest {
|
||||
drtioaux::send(self.auxno, &drtioaux::Packet::ResetRequest {
|
||||
phy: phy
|
||||
}).unwrap();
|
||||
let reply = self.recv_aux_timeout(200)?;
|
||||
|
Loading…
Reference in New Issue
Block a user