-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.rs
More file actions
35 lines (29 loc) · 1.33 KB
/
main.rs
File metadata and controls
35 lines (29 loc) · 1.33 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
use rustecal::{Ecal, EcalComponents, TypedSubscriber};
use rustecal::pubsub::typed_subscriber::Received;
use rustecal_types_string::StringMessage;
fn main() {
Ecal::initialize(Some("hello receive rust"), EcalComponents::DEFAULT)
.expect("eCAL initialization failed");
let mut subscriber = TypedSubscriber::<StringMessage>::new("hello")
.expect("Failed to create subscriber");
subscriber.set_callback(|msg: Received<StringMessage>| {
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!("message : {}", msg.payload.data);
println!("------------------------------------------\n");
});
println!("Waiting for messages on topic 'hello'...");
while Ecal::ok() {
std::thread::sleep(std::time::Duration::from_millis(100));
}
Ecal::finalize();
}