pub struct IPBus {
pub socket: UdpSocket,
pub packet_type: IPBusPacketType,
pub pid: u16,
pub expected_pid: u16,
pub last_pid: u16,
pub buffer: [u8; 128],
}
Expand description
Implementation of an IPBus control packet
Fields§
§socket: UdpSocket
§packet_type: IPBusPacketType
§pid: u16
IPBus Packet ID - this is then NEXT pid which will be sent
expected_pid: u16
§last_pid: u16
§buffer: [u8; 128]
Implementations§
Source§impl IPBus
impl IPBus
pub fn new(target_address: &str) -> Result<Self>
Sourcepub fn connect(target_address: &str) -> Result<UdpSocket>
pub fn connect(target_address: &str) -> Result<UdpSocket>
Connect to MTB Utp socket
This will try a number of options to bind to the local port.
§Arguments
- target_address : IP/port of the target probably some kind of FPGA
Sourcepub fn receive(&mut self) -> Result<usize>
pub fn receive(&mut self) -> Result<usize>
Receive number_of_bytes from UdpSocket and sleep after to avoid too many queries
Sourcepub fn send(&mut self, data: &Vec<u8>) -> Result<()>
pub fn send(&mut self, data: &Vec<u8>) -> Result<()>
Receive number_of_bytes from UdpSocket and sleep after to avoid too many queries
Sourcepub fn get_status(&mut self) -> Result<(), Box<dyn Error>>
pub fn get_status(&mut self) -> Result<(), Box<dyn Error>>
Send a ipbus status packet and receive the response
Inspect self.buffer after the call if interested in the result.
pub fn get_pid_from_current_buffer(&self) -> u16
Sourcepub fn realign_packet_id(&mut self) -> Result<(), Box<dyn Error>>
pub fn realign_packet_id(&mut self) -> Result<(), Box<dyn Error>>
Set the packet id to that what is expected from the targetr
pub fn buffer_is_status(&self) -> bool
Sourcepub fn get_target_next_expected_packet_id(
&mut self,
) -> Result<u16, Box<dyn Error>>
pub fn get_target_next_expected_packet_id( &mut self, ) -> Result<u16, Box<dyn Error>>
Get the packet id which is expected by the target
Sourcepub fn read_multiple(
&mut self,
addr: u32,
nwords: usize,
increment_addr: bool,
) -> Result<Vec<u32>, Box<dyn Error>>
pub fn read_multiple( &mut self, addr: u32, nwords: usize, increment_addr: bool, ) -> Result<Vec<u32>, Box<dyn Error>>
Multiple read operations with a single UDP request
Read either the same register multiple times or read from incrementing register addresses
§Arguments:
- addr : register addresss to read from
- nwords : number of read operations
- increment_addr : if true, increment the register address after each read operation
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IPBus
impl RefUnwindSafe for IPBus
impl Send for IPBus
impl Sync for IPBus
impl Unpin for IPBus
impl UnwindSafe for IPBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self
to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self
to an expression for Diesel’s query builder. Read more