-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.rs
More file actions
43 lines (35 loc) · 1.5 KB
/
main.rs
File metadata and controls
43 lines (35 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use rustecal::{Ecal, EcalComponents, TypedSubscriber};
use rustecal_types_bytes::BytesMessage;
use rustecal::pubsub::typed_subscriber::Received;
fn main() {
Ecal::initialize(Some("blob receive rust"), EcalComponents::DEFAULT)
.expect("eCAL initialization failed");
let mut subscriber = TypedSubscriber::<BytesMessage>::new("blob")
.expect("Failed to create subscriber");
subscriber.set_callback(|msg: Received<BytesMessage>| {
let buffer = &msg.msg.0;
if buffer.is_empty() {
return;
}
let content = buffer[0] as u8;
println!("------------------------------------------");
println!(" HEAD ");
println!("------------------------------------------");
println!("topic name : {}", msg.topic_name);
println!("encoding : {}", msg.encoding);
println!("type name : {}", msg.type_name);
println!("topic time : {}", msg.timestamp);
println!("topic clock : {}", msg.clock);
println!("------------------------------------------");
println!(" CONTENT ");
println!("------------------------------------------");
println!("binary value : {}", content);
println!("buffer size : {}", buffer.len());
println!("------------------------------------------\n");
});
println!("Waiting for binary blobs on topic 'blob'...");
while Ecal::ok() {
std::thread::sleep(std::time::Duration::from_millis(100));
}
Ecal::finalize();
}