update micodus_server

This commit is contained in:
Paul 2024-12-27 16:10:07 +01:00
parent 65461f6f9e
commit d54a73244a
6 changed files with 72 additions and 2 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.pdf filter=lfs diff=lfs merge=lfs -text

40
Cargo.lock generated
View File

@ -53,6 +53,18 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bitvec"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]]
name = "byteorder"
version = "1.5.0"
@ -80,6 +92,12 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "funty"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
[[package]]
name = "getrandom"
version = "0.2.15"
@ -124,6 +142,7 @@ name = "micodus_server"
version = "0.1.0"
dependencies = [
"bcd-convert",
"bitvec",
"encoding_rs",
"rand",
"tokio",
@ -214,6 +233,12 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "radium"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
[[package]]
name = "rand"
version = "0.8.5"
@ -301,6 +326,12 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "thiserror"
version = "1.0.69"
@ -435,6 +466,15 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "wyz"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
dependencies = [
"tap",
]
[[package]]
name = "zerocopy"
version = "0.7.35"

View File

@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
bcd-convert = { version = "0.1" }
bitvec = { version = "1.0.1" }
encoding_rs = { version = "0.8" }
rand = { version = "0.8" }
tokio = { version = "1.42", features = ["full", "sync"] }

BIN
doc/MiCODUS OBD Data Protocol for MV55G MV66--20230612.pdf (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -144,6 +144,7 @@ impl TerminalRegistration {
res.answer_serial_no = serial;
res.result = TerminalRegistrationResult::Success as u8;
//res.authentication_code = String::from_utf8(terminal_id).unwrap();
println!("{:?}", terminal_id);
res.authentication_code = vec![0x36, 0x31, 0x33, 0x32, 0x31, 0x31, 0x38];
res
}
@ -208,6 +209,14 @@ impl TerminalLogout {
pub const ID: u16 = 0x0003;
pub fn parse(&mut self, rawbody: &Vec<u8>) {}
pub fn generate_reply(&self, answer_id: u16, serial: u16) -> PlatformUniversalResponse {
let mut res = PlatformUniversalResponse::default();
res.answer_serial_no = serial;
res.answer_id = answer_id;
res.result = TerminalRegistrationResult::Success as u8;
res
}
}
impl std::fmt::Display for TerminalLogout {
@ -309,7 +318,7 @@ pub struct LocationInformationReport {
pub height: u16,
pub speed: u16,
pub direction: u16,
pub time: u64,
pub time: String,
}
impl LocationInformationReport {
@ -377,7 +386,7 @@ impl LocationInformationReport {
tmptime[i] = *bd.next().unwrap();
}
let code = BcdNumber::try_from(&tmptime as &[u8]).unwrap();
self.time = code.to_u64().unwrap();
self.time = format!("{}", code.to_u64().unwrap());
}
pub fn generate_reply(&self, answer_id: u16, serial: u16) -> PlatformUniversalResponse {
@ -405,6 +414,14 @@ impl EndOfTrip {
pub fn parse(&mut self, rawbody: &Vec<u8>) {}
}
struct BCDTime {
pub time: String,
}
impl BCDTime {
pub fn parse() {}
}
generate_impl!(
TerminalUniversalResponse,
PlatformUniversalResponse,

View File

@ -284,6 +284,14 @@ impl Message {
reply.header.serial_number = rng.gen();
reply.content = MessageType::PlatformUniversalResponse(cnt);
}
MessageType::TerminalLogout(t) => {
let cnt = t.generate_reply(TerminalHeartbeat::ID, inmsg.header.serial_number);
reply.header.id = PlatformUniversalResponse::ID;
reply.header.raw_terminal_id = inmsg.header.raw_terminal_id;
reply.header.properties = cnt.to_raw().len() as u16;
reply.header.serial_number = rng.gen();
reply.content = MessageType::PlatformUniversalResponse(cnt);
}
_ => {
println!("no type");
return None;