RoboRio

Struct RoboRio 

Source
pub struct RoboRio {
    pub target_ip: IpAddr,
    /* private fields */
}

Fields§

§target_ip: IpAddr

Implementations§

Source§

impl RoboRio

Source

pub fn new(team_number: u32) -> Result<RoboRio>

Examples found in repository?
examples/simple.rs (line 31)
12fn main() {
13
14    let control = Control::AUTONOMOUS | Control::ENABLED;
15    let request = Request::empty();
16    let alliance = Alliance::Red(1);
17    let tags: Vec<Box<Tag>> = vec!(Box::new(Countdown(35.00001)));//, Box::new(Joystick::new(vec!(-120, 110, 0),vec!(true, false, false, true, true, false, true, false, true, true, true), vec!(-1, 180))));
18
19    let mut buf = [0; 20];
20
21    let mut udp = UdpOutPacket {
22        sequence: 0,
23        comm_version: 0x01,
24        control,
25        request,
26        alliance,
27        tags,
28    };
29
30
31    let rio = RoboRio::new(5119).unwrap();
32    println!("{}", rio.target_ip);
33    loop {
34        rio.send_udp(udp.next()).unwrap();
35        rio.recv_udp(&mut buf).unwrap();
36        println!("{:?}", UdpInPacket::decode(&mut buf));
37        thread::sleep(Duration::from_millis(20));
38    }
39}
Source

pub fn new_from_ip(rio_ip: [u8; 4]) -> Result<RoboRio>

Source

pub fn send_udp(&self, packet: Vec<u8>) -> Result<()>

Examples found in repository?
examples/simple.rs (line 34)
12fn main() {
13
14    let control = Control::AUTONOMOUS | Control::ENABLED;
15    let request = Request::empty();
16    let alliance = Alliance::Red(1);
17    let tags: Vec<Box<Tag>> = vec!(Box::new(Countdown(35.00001)));//, Box::new(Joystick::new(vec!(-120, 110, 0),vec!(true, false, false, true, true, false, true, false, true, true, true), vec!(-1, 180))));
18
19    let mut buf = [0; 20];
20
21    let mut udp = UdpOutPacket {
22        sequence: 0,
23        comm_version: 0x01,
24        control,
25        request,
26        alliance,
27        tags,
28    };
29
30
31    let rio = RoboRio::new(5119).unwrap();
32    println!("{}", rio.target_ip);
33    loop {
34        rio.send_udp(udp.next()).unwrap();
35        rio.recv_udp(&mut buf).unwrap();
36        println!("{:?}", UdpInPacket::decode(&mut buf));
37        thread::sleep(Duration::from_millis(20));
38    }
39}
Source

pub fn recv_udp(&self, buf: &mut [u8]) -> Result<()>

Examples found in repository?
examples/simple.rs (line 35)
12fn main() {
13
14    let control = Control::AUTONOMOUS | Control::ENABLED;
15    let request = Request::empty();
16    let alliance = Alliance::Red(1);
17    let tags: Vec<Box<Tag>> = vec!(Box::new(Countdown(35.00001)));//, Box::new(Joystick::new(vec!(-120, 110, 0),vec!(true, false, false, true, true, false, true, false, true, true, true), vec!(-1, 180))));
18
19    let mut buf = [0; 20];
20
21    let mut udp = UdpOutPacket {
22        sequence: 0,
23        comm_version: 0x01,
24        control,
25        request,
26        alliance,
27        tags,
28    };
29
30
31    let rio = RoboRio::new(5119).unwrap();
32    println!("{}", rio.target_ip);
33    loop {
34        rio.send_udp(udp.next()).unwrap();
35        rio.recv_udp(&mut buf).unwrap();
36        println!("{:?}", UdpInPacket::decode(&mut buf));
37        thread::sleep(Duration::from_millis(20));
38    }
39}

Auto Trait Implementations§

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, 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.