Skip to content

Commit

Permalink
More changes that haven't made TCP sending work yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
grebneerg committed Dec 25, 2018
1 parent 355a7e2 commit bc073b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ fn main() {

ds.set_mode(RobotMode::Auto);
ds.set_alliance(Alliance::Blue(2));
ds.set_game_data("lll".to_string());
ds.set_game_data("LLL".to_string());
ds.set_match_info(MatchInfo {
competition: "jack's super fun and definitely real frc competition".to_owned(),
match_type: MatchType::Elimination,
});

println!("we connected");
thread::sleep(time::Duration::from_millis(2000));
thread::sleep(time::Duration::from_millis(20000));
ds.set_enabled(true);
println!("we enabled");
ds.set_game_data("rrr".to_string());
thread::sleep(time::Duration::from_millis(2000));
ds.set_game_data("RRR".to_string());
thread::sleep(time::Duration::from_millis(20000));
ds.set_enabled(false);
println!("we disabled");
thread::sleep(time::Duration::from_millis(2000));
thread::sleep(time::Duration::from_millis(20000));
println!("we done");
}
8 changes: 4 additions & 4 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ impl DSConnection {

let t = thread::spawn(move || {
println!("udp start");
let udp = UdpSocket::bind("169.254.65.205:1149").unwrap();
let udp = UdpSocket::bind("0.0.0.0:1149").unwrap();

udp.connect(SocketAddr::new(addr.clone(), 1110)).unwrap();
println!("udp 2");
let udp_recv = UdpSocket::bind("169.254.65.205:1150").unwrap();
let udp_recv = UdpSocket::bind("0.0.0.0:1150").unwrap();
udp_recv.set_nonblocking(true).unwrap();
println!("udp started");

Expand Down Expand Up @@ -63,7 +63,7 @@ impl DSConnection {
Ok(Signal::Disconnect) | Err(mpsc::TryRecvError::Disconnected) => break,
Ok(Signal::Tcp(tag)) => {
match tcp.write(tag.to_packet().as_slice()) {
Ok(n) => println!("wrote"),
Ok(n) => println!("wrote {}", n),
Err(e) => {} //TODO
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ impl DSConnection {
last = Instant::now();
let packet = state.lock().unwrap().udp_packet();
match udp.send(packet.as_ref()) {
Ok(s) => println!("udp sent {:?}", packet),
Ok(s) => {}, // println!("udp sent {:?}", packet),
Err(e) => {
if e.kind() != io::ErrorKind::WouldBlock {
if let Err(e) = sender_res.send(Err(e)) {
Expand Down

0 comments on commit bc073b6

Please sign in to comment.