first commit

This commit is contained in:
Lucas Schumacher 2023-11-27 15:11:56 -05:00
commit 7825a2e883
4 changed files with 67 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

14
Cargo.lock generated Normal file
View File

@ -0,0 +1,14 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aisdump"
version = "0.1.0"
dependencies = [
"nmea-ais",
]
[[package]]
name = "nmea-ais"
version = "0.1.0"

9
Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "aisdump"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nmea-ais = { version = "0.1.0", path = "../nmea-ais" }

43
src/main.rs Normal file
View File

@ -0,0 +1,43 @@
use std::io::{BufRead, BufReader};
use std::net::TcpStream;
//const REQUEST: &str = "GET /sse HTTP/1.1\x0d\x0aHost: 192.168.1.10:8100\x0d\x0aUser-Agent: curl/8.4.0\x0d\x0aAccept: */*\x0d\x0a\x0d\x0a";
fn main() -> std::io::Result<()> {
//println!("Hello, world!");
//println!("str: {}", REQUEST);
//let mut stdout = std::io::stdout();
let stream = TcpStream::connect("192.168.1.10:10110")?;
//let mut buffer = vec![0_u8; 1024];
let mut buffer = BufReader::new(stream);
let mut current_line = String::new();
while let Ok(n) = buffer.read_line(&mut current_line) {
if n == 0 {
break;
}
println!("{}", current_line);
current_line.clear();
}
//stream.write_all(REQUEST.as_bytes())?;
//let header_end = u32::from_ne_bytes(*b"\r\n\r\n");
//while let Ok(n) = stream.read(&mut buffer[4..]) {
// stdout.write_all(&buffer[4..4 + n])?;
//for i in (0..n).into_iter().step_by(2) {
// for i in 0..n {
// let value = u32::from_ne_bytes(buffer[i..i + 4].try_into().unwrap());
// if value == header_end {
// buffer.copy_within(i + 4..n, 0);
// break;
// }
// }
// buffer.copy_within(n..n + 4, 0);
//}
//stream.read(&mut buffer)
Ok(())
}