tof_dataclasses::ipbus

Struct IPBus

Source
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

Source

pub fn new(target_address: &str) -> Result<Self>

Source

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
Source

pub fn receive(&mut self) -> Result<usize>

Receive number_of_bytes from UdpSocket and sleep after to avoid too many queries

Source

pub fn send(&mut self, data: &Vec<u8>) -> Result<()>

Receive number_of_bytes from UdpSocket and sleep after to avoid too many queries

Source

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.

Source

pub fn get_pid_from_current_buffer(&self) -> u16

Source

pub fn realign_packet_id(&mut self) -> Result<(), Box<dyn Error>>

Set the packet id to that what is expected from the targetr

Source

pub fn buffer_is_status(&self) -> bool

Source

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

Source

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
Source

pub fn read(&mut self, addr: u32) -> Result<u32, Box<dyn Error>>

Read a single value from a register

§Arguments:
  • addr : register address to be read from
Source

pub fn write(&mut self, addr: u32, data: u32) -> Result<(), Box<dyn Error>>

Write a single value to a register

§Arguments
  • addr : target register address
  • data : word to write in register

Trait Implementations§

Source§

impl Debug for IPBus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for IPBus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V