Crates.io | calamp-rs |
lib.rs | calamp-rs |
version | 0.2.4 |
source | src |
created_at | 2021-07-03 04:37:10.928939 |
updated_at | 2021-07-10 15:48:03.085025 |
description | Parser for the Calamp LMDirect message protocol |
homepage | https://git.sr.ht/~mbsd/calamp-rs |
repository | https://git.sr.ht/~mbsd/calamp-rs |
max_upload_size | |
id | 418097 |
size | 70,863 |
To start with calamp-rs, add the following to your Cargo.toml
file:
[dependencies]
calamp-rs= "0.2.4"
Next, parse message:
use calamp_rs::Message;
fn main() {
let data: [u8; 117] = [
0x83, 0x05, 0x46, 0x34, 0x66, 0x32, 0x35, 0x01, 0x01, 0x01, 0x02, 0x3a,
0x86, 0x5f, 0xf1, 0x3a, 0x54, 0x5f, 0xf1, 0x3a, 0x57, 0xf1, 0xe2, 0x85,
0x78, 0xe4, 0x22, 0xd6, 0x40, 0x00, 0x01, 0x36, 0xf8, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x00, 0x06, 0x20, 0x00, 0x00, 0xff, 0x8d, 0x02, 0x1e, 0x1e,
0x00, 0x7b, 0x21, 0x10, 0x00, 0x00, 0x00, 0x31, 0xe0, 0x00, 0x00, 0x10,
0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x2a, 0x32, 0x00, 0x00, 0x03,
0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc8, 0x2d,
0x3f, 0x01, 0xc8, 0x2d, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];
let msg = Message::parse(&data);
println!("Message Type: {}", msg.message_header.message_type);
}
Finally, run this benchmark with cargo run
. You should see output similar to
the following:
Message Type: MessageType::EventReport
To see some examples just run them via cargo run --examples
.
cargo run --example srv_udp
Another terminal:
cargo run --example cli_udp
First, thank you for contributing.
One great way to contribute to calamp-rs is to use it for your own benchmarking needs and report your experiences, file and comment on issues, etc.
Code or documentation improvements in the form of pull requests are also welcome. If you're not sure what to work on, try checking the Beginner label.
If your issues or pull requests have no response after a few days, feel free to ping me (@muriloijanc).
For more details, see the CONTRIBUTING.md file.
Calamp-rs is distributed under the terms of the BSD2 license.
See LICENSE