File tree 2 files changed +28
-7
lines changed
2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change 1
1
extern crate log;
2
2
extern crate px4;
3
3
4
- use log:: { warn, info} ;
5
- use px4:: { info_raw, px4_module_main} ;
4
+ use log:: info;
5
+ use px4:: { info_raw, px4_message, px4_module_main} ;
6
+
7
+ use px4:: uorb:: { Publish , Subscribe } ;
8
+
9
+ #[ px4_message( "example/msg/debug_value.msg" ) ]
10
+ pub struct debug_value ;
6
11
7
12
#[ px4_module_main]
8
- pub fn main ( args : & [ & str ] ) -> i32 {
13
+ fn main ( args : & [ & str ] ) -> i32 {
9
14
info ! ( "Hello World!" ) ;
10
15
11
16
info_raw ! ( "\n |> \\ / /_| |> | | /_ |_" ) ;
12
17
info_raw ! ( "\n | /\\ | |\\ |_| / |_\n \n " ) ;
13
18
14
19
info ! ( "Arguments: {:?}" , & args[ 1 ..] ) ;
15
20
16
- if args. get ( 1 ) == Some ( & "panic" ) {
17
- panic ! ( "A disaster happened!" ) ;
18
- }
21
+ info ! ( "Publishing data..." ) ;
22
+
23
+ let mut d = debug_value {
24
+ timestamp : 123 ,
25
+ value : 1.0f32 ,
26
+ ind : 13 ,
27
+ } ;
28
+ let p = d. advertise ( ) . unwrap ( ) ;
29
+
30
+ d. timestamp = 456 ;
31
+ p. publish ( & d) . unwrap ( ) ;
32
+
33
+ info ! ( "debug_value exists: {}" , debug_value:: exists( 0 ) ) ;
34
+ info ! ( "debug_value group_count: {}" , debug_value:: group_count( ) ) ;
19
35
20
- warn ! ( "The end is near!" ) ;
36
+ let sub = debug_value:: subscribe ( ) . unwrap ( ) ;
37
+ info ! ( "Subscribed and read: {:?}" , sub. get( ) ) ;
21
38
22
39
0
23
40
}
Original file line number Diff line number Diff line change
1
+ # Test message
2
+ uint64 timestamp
3
+ float32 value
4
+ int8 ind
You can’t perform that action at this time.
0 commit comments