File tree 3 files changed +39
-0
lines changed
3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ fn main() {
26
26
. header ( format ! ( "{}/include/swiftnav/ionosphere.h" , dst. display( ) ) )
27
27
. header ( format ! ( "{}/include/swiftnav/troposphere.h" , dst. display( ) ) )
28
28
. header ( format ! ( "{}/include/swiftnav/ephemeris.h" , dst. display( ) ) )
29
+ . header ( format ! ( "{}/include/swiftnav/edc.h" , dst. display( ) ) )
29
30
// Tell cargo to invalidate the built crate whenever any of the
30
31
// included header files changed.
31
32
. parse_callbacks ( Box :: new ( bindgen:: CargoCallbacks ) )
@@ -80,6 +81,7 @@ fn main() {
80
81
. whitelist_function ( "decode_ephemeris" )
81
82
. whitelist_function ( "decode_bds_d1_ephemeris" )
82
83
. whitelist_function ( "decode_gal_ephemeris" )
84
+ . whitelist_function ( "crc24q" )
83
85
// Finish the builder and generate the bindings.
84
86
. generate ( )
85
87
// Unwrap the Result and panic on failure.
Original file line number Diff line number Diff line change
1
+ use crate :: c_bindings;
2
+
3
+ pub fn compute_crc24q ( buf : & [ u8 ] , initial_value : u32 ) -> u32 {
4
+ unsafe { c_bindings:: crc24q ( buf. as_ptr ( ) , buf. len ( ) as u32 , initial_value) }
5
+ }
6
+
7
+ #[ cfg( test) ]
8
+ mod tests {
9
+ const TEST_DATA : & [ u8 ] = "123456789" . as_bytes ( ) ;
10
+
11
+ #[ test]
12
+ fn crc24q ( ) {
13
+ let crc = super :: compute_crc24q ( & TEST_DATA [ 0 ..0 ] , 0 ) ;
14
+ assert ! (
15
+ crc == 0 ,
16
+ "CRC of empty buffer with starting value 0 should be 0, not {}" ,
17
+ crc
18
+ ) ;
19
+
20
+ let crc = super :: compute_crc24q ( & TEST_DATA [ 0 ..0 ] , 22 ) ;
21
+ assert ! (
22
+ crc == 22 ,
23
+ "CRC of empty buffer with starting value 22 should be 22, not {}" ,
24
+ crc
25
+ ) ;
26
+
27
+ /* Test value taken from python crcmod package tests, see:
28
+ * http://crcmod.sourceforge.net/crcmod.predefined.html */
29
+ let crc = super :: compute_crc24q ( TEST_DATA , 0xB704CE ) ;
30
+ assert ! (
31
+ crc == 0x21CF02 ,
32
+ "CRC of \" 123456789\" with init value 0xB704CE should be {}, not 0x%06X" ,
33
+ crc
34
+ ) ;
35
+ }
36
+ }
Original file line number Diff line number Diff line change 16
16
17
17
mod c_bindings;
18
18
pub mod coords;
19
+ pub mod edc;
19
20
pub mod ephemeris;
20
21
pub mod ionosphere;
21
22
pub mod signal;
You can’t perform that action at this time.
0 commit comments