From ccdc7679eeeb701b7d5185023ffecca90e8d1ad9 Mon Sep 17 00:00:00 2001 From: Joseph Angelo Date: Wed, 30 Oct 2019 12:37:59 -0700 Subject: [PATCH 1/6] Added generator for rust tests --- Makefile | 8 ++ generator/sbpg/generator.py | 10 +- .../targets/resources/sbp_tests_template.rs | 76 +++++++++++++++ generator/sbpg/targets/test_rust.py | 92 +++++++++++++++++++ 4 files changed, 184 insertions(+), 2 deletions(-) create mode 100644 generator/sbpg/targets/resources/sbp_tests_template.rs create mode 100644 generator/sbpg/targets/test_rust.py diff --git a/Makefile b/Makefile index b791a1f470..2e8fa15327 100644 --- a/Makefile +++ b/Makefile @@ -229,6 +229,14 @@ gen-rust: -o $(SWIFTNAV_ROOT)/rust/ \ -r $(SBP_MAJOR_VERSION).$(SBP_MINOR_VERSION).$(SBP_PATCH_VERSION) \ --rust + + $(call announce-begin,"Generating Rust tests") + cd $(SWIFTNAV_ROOT)/generator; \ + $(SBP_GEN_BIN) -i $(SBP_TESTS_SPEC_DIR) \ + -o $(SWIFTNAV_ROOT)/rust/sbp/tests/ \ + -r $(SBP_MAJOR_VERSION).$(SBP_MINOR_VERSION).$(SBP_PATCH_VERSION) \ + --test-rust + cd $(SWIFTNAV_ROOT)/rust/sbp && cargo fmt $(call announce-begin,"Finished generating Rust bindings") diff --git a/generator/sbpg/generator.py b/generator/sbpg/generator.py index d0b4a5704a..b47b98d00e 100755 --- a/generator/sbpg/generator.py +++ b/generator/sbpg/generator.py @@ -55,6 +55,9 @@ def get_args(): parser.add_argument('--rust', action="store_true", help='Target language: Rust.') + parser.add_argument('--test-rust', + action="store_true", + help='Target language: Rust tests.') parser.add_argument('--latex', action="store_true", help='Target language: LaTeX.') @@ -81,7 +84,7 @@ def main(): # Parse and validate arguments. args = get_args().parse_args() verbose = args.verbose - assert args.jsonschema or args.pythonNG or args.python or args.javascript or args.c or args.test_c or args.haskell or args.latex or args.protobuf or args.java or args.rust, \ + assert args.jsonschema or args.pythonNG or args.python or args.javascript or args.c or args.test_c or args.haskell or args.latex or args.protobuf or args.java or args.rust or args.test_rust, \ "Please specify a target language." input_file = os.path.abspath(args.input_file[0]) assert len(args.input_file) == 1 @@ -92,7 +95,7 @@ def main(): assert os.path.exists(output_dir), \ "Invalid output directory: %s. Exiting!" % output_dir # Ingest, parse, and validate. - test_mode = args.test_c + test_mode = args.test_c or args.test_rust if test_mode: file_index = yaml.resolve_test_deps(*yaml.get_files(input_file)) @@ -146,6 +149,9 @@ def main(): elif args.rust: import sbpg.targets.rust as rs rs.render_source(output_dir, parsed) + elif args.test_rust: + import sbpg.targets.test_rust as test_rs + test_rs.render_source(output_dir, parsed) elif args.protobuf: import sbpg.targets.protobuf as pb pb.render_source(output_dir, parsed) diff --git a/generator/sbpg/targets/resources/sbp_tests_template.rs b/generator/sbpg/targets/resources/sbp_tests_template.rs new file mode 100644 index 0000000000..787d5d5206 --- /dev/null +++ b/generator/sbpg/targets/resources/sbp_tests_template.rs @@ -0,0 +1,76 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from (((s.src_filename))) by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) || ((self - rhs).abs() < std::f64::MIN) + } +} + +((*- macro compare_value(prefix, value) *)) +((*- if value is stringType *)) +assert_eq!(msg.(((prefix))), (((value|str_escape))), "incorrect value for msg.(((prefix))), expected string '{}', is '{}'", (((value|str_escape))), msg.(((prefix)))); +((*- elif value is arrayType *)) +((*- for ff in value *))((( compare_value( (((prefix))) + '[' + (((loop.index0|toStr))) + ']', (((ff))) ) )))((*- endfor *)) +((*- elif value is dictType *)) +((*- for k in (((value|sorted))) *))((( compare_value( (((prefix))) + '.' + (((k))), (((value[k]))) ) )))((*- endfor *)) +((*- elif value is floatType *))((= + Note: the ("%.17e"|format(value)) filter is intended to preserve float + literal precision accross all value ranges. =)) +assert!(msg.(((prefix))).almost_eq( ((("%.17e"|format(value)))) ), "incorrect value for (((prefix))), expected ((("%.17e"|format(value)))), is {:e}", msg.(((prefix)))); +((*- else *)) +assert_eq!(msg.(((prefix))), (((value))), "incorrect value for (((prefix))), expected (((value))), is {}", msg.(((prefix)))); +((*- endif *)) +((*- endmacro *)) + +#[test] +fn test_(((s.suite_name)))() +{ + ((*- for t in s.tests *)) + { + use sbp::messages::(((t.msg.module|modName)))::(((t.msg.name))); + let payload : Vec = vec![ ((*- for p in t.packet_as_byte_array *))(((p))),((*- endfor *)) ]; + + assert_eq!( (((t.msg.name)))::MSG_ID, (((t.msg_type))), "Incorrect message type, expected (((t.msg_type))), is {}", (((t.msg.name)))::MSG_ID); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::(((t.msg.name)))(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!(sender_id, (((t.sbp.sender))), "incorrect sender id, expected (((t.sbp.sender))), is {}", sender_id); + ((*- for f in t.fieldskeys *))(((compare_value( (((f))), (((t.fields[f]))) ))))((*- endfor *)) + }, + _ => assert!(false, "Invalid message type! Expected a (((t.msg.name)))"), + }; + } + ((*- endfor *)) +} diff --git a/generator/sbpg/targets/test_rust.py b/generator/sbpg/targets/test_rust.py new file mode 100644 index 0000000000..ab76fd72c1 --- /dev/null +++ b/generator/sbpg/targets/test_rust.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +# Copyright (C) 2015 Swift Navigation Inc. +# Contact: Joshua Gross +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +""" +Generator for c tests target. +""" + +from sbpg.targets.templating import * +from sbpg.targets.rust import * +import base64 + +TEST_TEMPLATE_NAME = "sbp_tests_template.rs" +#CHECK_SUITES_TEMPLATE_NAME = "sbp_c_suites.h.j2" +#CHECK_MAIN_TEMPLATE_NAME = "sbp_c_main.c.j2" + +def b64_decode(field): + print("Decoding '{}'".format(field)) + b = base64.standard_b64decode(field) + return [ str(ord(ch)) for ch in b ] + +def stringType(value): + return type(value) == str + +def arrayType(value): + return type(value) == list + +def dictType(value): + return type(value) == dict + +def floatType(value): + return type(value) == float + +def isEmpty(value): + return len(value) == 0 + +def strEscape(value): + return "\"{}\".to_string()".format(value) + +def toStr(value): + return str(value) + +def modName(value): + return value.split('.')[1] + +JENV.filters['b64_decode'] = b64_decode +JENV.filters['toStr'] = toStr +JENV.filters['str_escape'] = strEscape +JENV.filters['sorted'] = sorted +JENV.filters['modName'] = modName + +JENV.tests['stringType'] = stringType +JENV.tests['arrayType'] = arrayType +JENV.tests['dictType'] = dictType +JENV.tests['floatType'] = floatType +JENV.tests['empty'] = isEmpty + +def render_source(output_dir, package_spec): + """ + Render and output to a directory given a package specification. + """ + path, name = package_spec.filepath + destination_filename = "%s/%s.rs" % (output_dir, name) + py_template = JENV.get_template(TEST_TEMPLATE_NAME) + with open(destination_filename, 'w') as f: + f.write(py_template.render(s=package_spec, + description=package_spec.description, + pkg_name=package_spec.package, + include=package_spec.package.split('.')[1], + filepath="/".join(package_spec.filepath) + ".yaml")) + + +#def render_check_suites(output_dir, all_package_specs): +# destination_filename = "%s/%s.h" % (output_dir, "check_suites") +# py_template = JENV.get_template(CHECK_SUITES_TEMPLATE_NAME) +# with open(destination_filename, 'w') as f: +# f.write(py_template.render(package_suites=all_package_specs)) + + +#def render_check_main(output_dir, all_package_specs): +# destination_filename = "%s/%s.c" % (output_dir, "check_main") +# py_template = JENV.get_template(CHECK_MAIN_TEMPLATE_NAME) +# with open(destination_filename, 'w') as f: +# f.write(py_template.render(package_suites=all_package_specs)) + From 79c344278f726c92604922dc8fefdcac2e942100 Mon Sep 17 00:00:00 2001 From: Joseph Angelo Date: Wed, 30 Oct 2019 12:38:56 -0700 Subject: [PATCH 2/6] Fixed issue with a trait not being public --- generator/sbpg/targets/resources/sbp_messages_mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/sbpg/targets/resources/sbp_messages_mod.rs b/generator/sbpg/targets/resources/sbp_messages_mod.rs index b0da99a4c9..13d3fff6cf 100644 --- a/generator/sbpg/targets/resources/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/sbp_messages_mod.rs @@ -20,7 +20,7 @@ use self::(((p.identifier|mod_name)))::(((m.identifier|camel_case))); ((*- endfor *)) ((*- endfor *)) -trait SBPMessage { +pub trait SBPMessage { const MSG_ID: u16; fn get_sender_id(&self) -> Option; From 80a76e13b4d4deb72e4312bc672645f7c7c2f545 Mon Sep 17 00:00:00 2001 From: Joseph Angelo Date: Wed, 30 Oct 2019 12:39:33 -0700 Subject: [PATCH 3/6] Changed test specifications to have float expected values --- .../swiftnav/sbp/navigation/test_MsgPosECEFCov.yaml | 4 ++-- .../swiftnav/sbp/navigation/test_MsgPosLLHCov.yaml | 4 ++-- .../swiftnav/sbp/navigation/test_MsgVelBody.yaml | 2 +- .../swiftnav/sbp/navigation/test_MsgVelECEFCov.yaml | 4 ++-- .../swiftnav/sbp/navigation/test_MsgVelNEDCOV.yaml | 12 ++++++------ .../sbp/orientation/test_MsgOrientEuler.yaml | 2 +- .../swiftnav/sbp/orientation/test_MsgOrientQuat.yaml | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFCov.yaml b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFCov.yaml index 025c626274..34bbc11a7f 100644 --- a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFCov.yaml +++ b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFCov.yaml @@ -3,8 +3,8 @@ generated_on: 2017-11-18 22:05:54.486797 package: sbp.navigation tests: - msg: - fields: {cov_x_x: 8, cov_x_y: 7, cov_x_z: 2, cov_y_y: 6, cov_y_z: 8, cov_z_z: 5, - flags: 5, n_sats: 4, tow: 7, x: 6, y: 1, z: 4} + fields: {cov_x_x: 8.0, cov_x_y: 7.0, cov_x_z: 2.0, cov_y_y: 6.0, cov_y_z: 8.0, cov_z_z: 5.0, + flags: 5, n_sats: 4, tow: 7, x: 6.0, y: 1.0, z: 4.0} module: sbp.navigation name: MsgPosECEFCov msg_type: '0x214' diff --git a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLHCov.yaml b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLHCov.yaml index 5aa932f804..1398708d41 100644 --- a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLHCov.yaml +++ b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLHCov.yaml @@ -3,8 +3,8 @@ generated_on: 2017-11-18 22:05:54.483784 package: sbp.navigation tests: - msg: - fields: {cov_d_d: 2, cov_e_d: 1, cov_e_e: 6, cov_n_d: 8, cov_n_e: 5, cov_n_n: 7, - flags: 5, height: 0, lat: 0, lon: 7, n_sats: 5, tow: 7} + fields: {cov_d_d: 2.0, cov_e_d: 1.0, cov_e_e: 6.0, cov_n_d: 8.0, cov_n_e: 5.0, cov_n_n: 7.0, + flags: 5, height: 0.0, lat: 0.0, lon: 7.0, n_sats: 5, tow: 7} module: sbp.navigation name: MsgPosLLHCov msg_type: '0x211' diff --git a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelBody.yaml b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelBody.yaml index 5abfcbc418..2b5f71b93b 100644 --- a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelBody.yaml +++ b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelBody.yaml @@ -3,7 +3,7 @@ generated_on: 2017-11-18 22:05:54.479105 package: sbp.navigation tests: - msg: - fields: {cov_x_x: 0, cov_x_y: 5, cov_x_z: 7, cov_y_y: 7, cov_y_z: 3, cov_z_z: 2, + fields: {cov_x_x: 0.0, cov_x_y: 5.0, cov_x_z: 7.0, cov_y_y: 7.0, cov_y_z: 3.0, cov_z_z: 2.0, flags: 8, n_sats: 3, tow: 1, x: 4, y: 2, z: 1} module: sbp.navigation name: MsgVelBody diff --git a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEFCov.yaml b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEFCov.yaml index 4ee6564997..10c5586305 100644 --- a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEFCov.yaml +++ b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEFCov.yaml @@ -3,8 +3,8 @@ generated_on: 2017-11-18 22:05:54.482621 package: sbp.navigation tests: - msg: - fields: {cov_x_x: 2, cov_x_y: 2, cov_x_z: 2, cov_y_y: 2, cov_y_z: 1, cov_z_z: 3, - flags: 4, n_sats: 3, tow: 2, x: 0, y: 0, z: 6} + fields: {cov_x_x: 2.0, cov_x_y: 2.0, cov_x_z: 2.0, cov_y_y: 2.0, cov_y_z: 1.0, cov_z_z: 3.0, + flags: 4, n_sats: 3, tow: 2, x: 0, y: 0, z: 6} module: sbp.navigation name: MsgVelECEFCov msg_type: '0x215' diff --git a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNEDCOV.yaml b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNEDCOV.yaml index 60641559c7..6492460017 100644 --- a/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNEDCOV.yaml +++ b/spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNEDCOV.yaml @@ -6,17 +6,17 @@ tests: - msg: fields: - cov_e_d: 1 - cov_e_e: 1 + cov_e_d: 1.0 + cov_e_e: 1.0 n_sats: 10 - cov_n_n: 1 - cov_n_e: 1 + cov_n_n: 1.0 + cov_n_e: 1.0 tow: 100 n: 1 - cov_n_d: 1 + cov_n_d: 1.0 flags: 0 e: 1 - cov_d_d: 1 + cov_d_d: 1.0 module: sbp.navigation name: MsgVelNEDCov msg_type: '0x212' diff --git a/spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientEuler.yaml b/spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientEuler.yaml index dc16a2a53b..7af45f87ac 100644 --- a/spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientEuler.yaml +++ b/spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientEuler.yaml @@ -3,7 +3,7 @@ generated_on: 2017-12-11 15:00:35.829852 package: sbp.orientation tests: - msg: - fields: {flags: 3, pitch: 2, roll: 1, tow: 1, pitch_accuracy: 3, roll_accuracy: 7, yaw_accuracy: 7, + fields: {flags: 3, pitch: 2, roll: 1, tow: 1, pitch_accuracy: 3.0, roll_accuracy: 7.0, yaw_accuracy: 7.0, yaw: 8} module: sbp.orientation name: MsgOrientEuler diff --git a/spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientQuat.yaml b/spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientQuat.yaml index 09ed94e560..fe2fd173de 100644 --- a/spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientQuat.yaml +++ b/spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientQuat.yaml @@ -3,7 +3,7 @@ generated_on: 2017-12-11 15:00:35.827076 package: sbp.orientation tests: - msg: - fields: {w_accuracy: 3, x_accuracy: 4, y_accuracy: 8, z_accuracy: 3, flags: 1, tow: 0, w: 3, x: 7, + fields: {w_accuracy: 3.0, x_accuracy: 4.0, y_accuracy: 8.0, z_accuracy: 3.0, flags: 1, tow: 0, w: 3, x: 7, y: 8, z: 4} module: sbp.orientation name: MsgOrientQuat From fc18533940784f17a488bf9eb14534232ec80c85 Mon Sep 17 00:00:00 2001 From: Joseph Angelo Date: Wed, 30 Oct 2019 12:40:25 -0700 Subject: [PATCH 4/6] Generated new tests --- rust/sbp/src/messages/mod.rs | 2 +- .../sbp/tests/auto_check_sbp_acquisition_1.rs | 344 ++ .../sbp/tests/auto_check_sbp_acquisition_2.rs | 344 ++ .../tests/auto_check_sbp_acquisition_38.rs | 340 ++ rust/sbp/tests/auto_check_sbp_bootload_39.rs | 137 + .../sbp/tests/auto_check_sbp_ext_events_40.rs | 94 + rust/sbp/tests/auto_check_sbp_logging_41.rs | 297 ++ rust/sbp/tests/auto_check_sbp_logging_42.rs | 87 + .../sbp/tests/auto_check_sbp_navigation_10.rs | 289 ++ .../sbp/tests/auto_check_sbp_navigation_11.rs | 289 ++ .../sbp/tests/auto_check_sbp_navigation_12.rs | 305 ++ .../sbp/tests/auto_check_sbp_navigation_13.rs | 131 + .../sbp/tests/auto_check_sbp_navigation_14.rs | 369 ++ .../sbp/tests/auto_check_sbp_navigation_15.rs | 399 +++ .../sbp/tests/auto_check_sbp_navigation_16.rs | 131 + .../sbp/tests/auto_check_sbp_navigation_17.rs | 398 +++ .../sbp/tests/auto_check_sbp_navigation_18.rs | 118 + .../sbp/tests/auto_check_sbp_navigation_19.rs | 365 ++ .../sbp/tests/auto_check_sbp_navigation_20.rs | 118 + .../sbp/tests/auto_check_sbp_navigation_21.rs | 369 ++ .../sbp/tests/auto_check_sbp_navigation_22.rs | 370 ++ .../sbp/tests/auto_check_sbp_navigation_23.rs | 118 + .../sbp/tests/auto_check_sbp_navigation_24.rs | 374 ++ rust/sbp/tests/auto_check_sbp_navigation_3.rs | 77 + rust/sbp/tests/auto_check_sbp_navigation_4.rs | 369 ++ .../sbp/tests/auto_check_sbp_navigation_43.rs | 3159 +++++++++++++++++ rust/sbp/tests/auto_check_sbp_navigation_5.rs | 384 ++ rust/sbp/tests/auto_check_sbp_navigation_6.rs | 394 ++ rust/sbp/tests/auto_check_sbp_navigation_7.rs | 374 ++ rust/sbp/tests/auto_check_sbp_navigation_8.rs | 104 + rust/sbp/tests/auto_check_sbp_navigation_9.rs | 219 ++ .../tests/auto_check_sbp_observation_25.rs | 1120 ++++++ .../tests/auto_check_sbp_observation_26.rs | 1243 +++++++ .../tests/auto_check_sbp_observation_44.rs | 2147 +++++++++++ .../tests/auto_check_sbp_orientation_27.rs | 82 + .../tests/auto_check_sbp_orientation_28.rs | 110 + .../tests/auto_check_sbp_orientation_29.rs | 104 + rust/sbp/tests/auto_check_sbp_piksi_30.rs | 72 + rust/sbp/tests/auto_check_sbp_piksi_31.rs | Bin 0 -> 10187 bytes rust/sbp/tests/auto_check_sbp_piksi_32.rs | 275 ++ rust/sbp/tests/auto_check_sbp_piksi_45.rs | Bin 0 -> 55358 bytes rust/sbp/tests/auto_check_sbp_settings_33.rs | 70 + rust/sbp/tests/auto_check_sbp_settings_34.rs | Bin 0 -> 10629 bytes rust/sbp/tests/auto_check_sbp_system_35.rs | 91 + rust/sbp/tests/auto_check_sbp_system_36.rs | 72 + rust/sbp/tests/auto_check_sbp_system_37.rs | 82 + rust/sbp/tests/auto_check_sbp_system_46.rs | 105 + rust/sbp/tests/auto_check_sbp_tracking_47.rs | 1233 +++++++ rust/sbp/tests/auto_check_sbp_tracking_48.rs | 1579 ++++++++ rust/sbp/tests/auto_check_sbp_tracking_49.rs | 819 +++++ rust/sbp/tests/auto_check_sbp_vehicle_50.rs | 82 + 51 files changed, 20153 insertions(+), 1 deletion(-) create mode 100644 rust/sbp/tests/auto_check_sbp_acquisition_1.rs create mode 100644 rust/sbp/tests/auto_check_sbp_acquisition_2.rs create mode 100644 rust/sbp/tests/auto_check_sbp_acquisition_38.rs create mode 100644 rust/sbp/tests/auto_check_sbp_bootload_39.rs create mode 100644 rust/sbp/tests/auto_check_sbp_ext_events_40.rs create mode 100644 rust/sbp/tests/auto_check_sbp_logging_41.rs create mode 100644 rust/sbp/tests/auto_check_sbp_logging_42.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_10.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_11.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_12.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_13.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_14.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_15.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_16.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_17.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_18.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_19.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_20.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_21.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_22.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_23.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_24.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_3.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_4.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_43.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_5.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_6.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_7.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_8.rs create mode 100644 rust/sbp/tests/auto_check_sbp_navigation_9.rs create mode 100644 rust/sbp/tests/auto_check_sbp_observation_25.rs create mode 100644 rust/sbp/tests/auto_check_sbp_observation_26.rs create mode 100644 rust/sbp/tests/auto_check_sbp_observation_44.rs create mode 100644 rust/sbp/tests/auto_check_sbp_orientation_27.rs create mode 100644 rust/sbp/tests/auto_check_sbp_orientation_28.rs create mode 100644 rust/sbp/tests/auto_check_sbp_orientation_29.rs create mode 100644 rust/sbp/tests/auto_check_sbp_piksi_30.rs create mode 100644 rust/sbp/tests/auto_check_sbp_piksi_31.rs create mode 100644 rust/sbp/tests/auto_check_sbp_piksi_32.rs create mode 100644 rust/sbp/tests/auto_check_sbp_piksi_45.rs create mode 100644 rust/sbp/tests/auto_check_sbp_settings_33.rs create mode 100644 rust/sbp/tests/auto_check_sbp_settings_34.rs create mode 100644 rust/sbp/tests/auto_check_sbp_system_35.rs create mode 100644 rust/sbp/tests/auto_check_sbp_system_36.rs create mode 100644 rust/sbp/tests/auto_check_sbp_system_37.rs create mode 100644 rust/sbp/tests/auto_check_sbp_system_46.rs create mode 100644 rust/sbp/tests/auto_check_sbp_tracking_47.rs create mode 100644 rust/sbp/tests/auto_check_sbp_tracking_48.rs create mode 100644 rust/sbp/tests/auto_check_sbp_tracking_49.rs create mode 100644 rust/sbp/tests/auto_check_sbp_vehicle_50.rs diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index 666eafe0d7..ed4ec3eff1 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -204,7 +204,7 @@ use self::tracking::MsgTrackingStateDetailedDepA; use self::user::MsgUserData; use self::vehicle::MsgOdometry; -trait SBPMessage { +pub trait SBPMessage { const MSG_ID: u16; fn get_sender_id(&self) -> Option; diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_1.rs b/rust/sbp/tests/auto_check_sbp_acquisition_1.rs new file mode 100644 index 0000000000..1943174ebf --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_acquisition_1.rs @@ -0,0 +1,344 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/acquisition/test_MsgAcqResultDepB.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_acquisition_1() { + { + use sbp::messages::acquisition::MsgAcqResultDepB; + let payload: Vec = vec![ + 85, 20, 0, 246, 215, 16, 137, 167, 18, 66, 0, 0, 161, 67, 240, 24, 156, 69, 9, 0, 0, 0, + 80, 195, + ]; + + assert_eq!( + MsgAcqResultDepB::MSG_ID, + 0x14, + "Incorrect message type, expected 0x14, is {}", + MsgAcqResultDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(4.99511718750000000e+03), + "incorrect value for cf, expected 4.99511718750000000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(3.22000000000000000e+02), + "incorrect value for cp, expected 3.22000000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 9, + "incorrect value for sid.sat, expected 9, is {}", + msg.sid.sat + ); + assert!( + msg.snr.almost_eq(3.66636085510253906e+01), + "incorrect value for snr, expected 3.66636085510253906e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepB"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepB; + let payload: Vec = vec![ + 85, 20, 0, 246, 215, 16, 206, 172, 16, 66, 0, 192, 82, 68, 198, 199, 0, 198, 3, 0, 0, + 0, 149, 143, + ]; + + assert_eq!( + MsgAcqResultDepB::MSG_ID, + 0x14, + "Incorrect message type, expected 0x14, is {}", + MsgAcqResultDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(-8.24194335937500000e+03), + "incorrect value for cf, expected -8.24194335937500000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(8.43000000000000000e+02), + "incorrect value for cp, expected 8.43000000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 3, + "incorrect value for sid.sat, expected 3, is {}", + msg.sid.sat + ); + assert!( + msg.snr.almost_eq(3.61687545776367188e+01), + "incorrect value for snr, expected 3.61687545776367188e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepB"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepB; + let payload: Vec = vec![ + 85, 20, 0, 246, 215, 16, 228, 27, 15, 66, 0, 128, 70, 68, 228, 74, 148, 69, 18, 0, 0, + 0, 179, 155, + ]; + + assert_eq!( + MsgAcqResultDepB::MSG_ID, + 0x14, + "Incorrect message type, expected 0x14, is {}", + MsgAcqResultDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(4.74536132812500000e+03), + "incorrect value for cf, expected 4.74536132812500000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(7.94000000000000000e+02), + "incorrect value for cp, expected 7.94000000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 18, + "incorrect value for sid.sat, expected 18, is {}", + msg.sid.sat + ); + assert!( + msg.snr.almost_eq(3.57772369384765625e+01), + "incorrect value for snr, expected 3.57772369384765625e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepB"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepB; + let payload: Vec = vec![ + 85, 20, 0, 246, 215, 16, 46, 199, 14, 66, 0, 64, 129, 67, 240, 24, 28, 69, 17, 0, 0, 0, + 18, 181, + ]; + + assert_eq!( + MsgAcqResultDepB::MSG_ID, + 0x14, + "Incorrect message type, expected 0x14, is {}", + MsgAcqResultDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(2.49755859375000000e+03), + "incorrect value for cf, expected 2.49755859375000000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(2.58500000000000000e+02), + "incorrect value for cp, expected 2.58500000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 17, + "incorrect value for sid.sat, expected 17, is {}", + msg.sid.sat + ); + assert!( + msg.snr.almost_eq(3.56945114135742188e+01), + "incorrect value for snr, expected 3.56945114135742188e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepB"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepB; + let payload: Vec = vec![ + 85, 20, 0, 246, 215, 16, 194, 24, 14, 66, 0, 128, 2, 68, 129, 193, 249, 195, 5, 0, 0, + 0, 35, 203, + ]; + + assert_eq!( + MsgAcqResultDepB::MSG_ID, + 0x14, + "Incorrect message type, expected 0x14, is {}", + MsgAcqResultDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(-4.99511749267578125e+02), + "incorrect value for cf, expected -4.99511749267578125e+02, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(5.22000000000000000e+02), + "incorrect value for cp, expected 5.22000000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 5, + "incorrect value for sid.sat, expected 5, is {}", + msg.sid.sat + ); + assert!( + msg.snr.almost_eq(3.55241775512695312e+01), + "incorrect value for snr, expected 3.55241775512695312e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepB"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_2.rs b/rust/sbp/tests/auto_check_sbp_acquisition_2.rs new file mode 100644 index 0000000000..fdea28615b --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_acquisition_2.rs @@ -0,0 +1,344 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/acquisition/test_MsgAcqResultDepC.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_acquisition_2() { + { + use sbp::messages::acquisition::MsgAcqResultDepC; + let payload: Vec = vec![ + 85, 31, 0, 40, 12, 16, 72, 9, 34, 66, 155, 152, 228, 67, 28, 34, 221, 68, 10, 0, 0, 0, + 9, 189, + ]; + + assert_eq!( + MsgAcqResultDepC::MSG_ID, + 0x1f, + "Incorrect message type, expected 0x1f, is {}", + MsgAcqResultDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xc28, + "incorrect sender id, expected 0xc28, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(1.76906591796875000e+03), + "incorrect value for cf, expected 1.76906591796875000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cn0.almost_eq(4.05090637207031250e+01), + "incorrect value for cn0, expected 4.05090637207031250e+01, is {:e}", + msg.cn0 + ); + assert!( + msg.cp.almost_eq(4.57192230224609375e+02), + "incorrect value for cp, expected 4.57192230224609375e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 10, + "incorrect value for sid.sat, expected 10, is {}", + msg.sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepC"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepC; + let payload: Vec = vec![ + 85, 31, 0, 40, 12, 16, 132, 250, 45, 66, 207, 93, 88, 68, 68, 185, 252, 195, 6, 0, 0, + 0, 136, 185, + ]; + + assert_eq!( + MsgAcqResultDepC::MSG_ID, + 0x1f, + "Incorrect message type, expected 0x1f, is {}", + MsgAcqResultDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xc28, + "incorrect sender id, expected 0xc28, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(-5.05447387695312500e+02), + "incorrect value for cf, expected -5.05447387695312500e+02, is {:e}", + msg.cf + ); + assert!( + msg.cn0.almost_eq(4.34946441650390625e+01), + "incorrect value for cn0, expected 4.34946441650390625e+01, is {:e}", + msg.cn0 + ); + assert!( + msg.cp.almost_eq(8.65465759277343750e+02), + "incorrect value for cp, expected 8.65465759277343750e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 6, + "incorrect value for sid.sat, expected 6, is {}", + msg.sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepC"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepC; + let payload: Vec = vec![ + 85, 31, 0, 40, 12, 16, 163, 223, 24, 66, 64, 91, 102, 67, 202, 243, 157, 196, 13, 0, 0, + 0, 150, 161, + ]; + + assert_eq!( + MsgAcqResultDepC::MSG_ID, + 0x1f, + "Incorrect message type, expected 0x1f, is {}", + MsgAcqResultDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xc28, + "incorrect sender id, expected 0xc28, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(-1.26361840820312500e+03), + "incorrect value for cf, expected -1.26361840820312500e+03, is {:e}", + msg.cf + ); + assert!( + msg.cn0.almost_eq(3.82183952331542969e+01), + "incorrect value for cn0, expected 3.82183952331542969e+01, is {:e}", + msg.cn0 + ); + assert!( + msg.cp.almost_eq(2.30356445312500000e+02), + "incorrect value for cp, expected 2.30356445312500000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 13, + "incorrect value for sid.sat, expected 13, is {}", + msg.sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepC"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepC; + let payload: Vec = vec![ + 85, 31, 0, 40, 12, 16, 129, 65, 21, 66, 224, 214, 124, 67, 243, 138, 61, 69, 1, 0, 0, + 0, 109, 209, + ]; + + assert_eq!( + MsgAcqResultDepC::MSG_ID, + 0x1f, + "Incorrect message type, expected 0x1f, is {}", + MsgAcqResultDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xc28, + "incorrect sender id, expected 0xc28, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(3.03268432617187500e+03), + "incorrect value for cf, expected 3.03268432617187500e+03, is {:e}", + msg.cf + ); + assert!( + msg.cn0.almost_eq(3.73139686584472656e+01), + "incorrect value for cn0, expected 3.73139686584472656e+01, is {:e}", + msg.cn0 + ); + assert!( + msg.cp.almost_eq(2.52839355468750000e+02), + "incorrect value for cp, expected 2.52839355468750000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 1, + "incorrect value for sid.sat, expected 1, is {}", + msg.sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepC"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepC; + let payload: Vec = vec![ + 85, 31, 0, 40, 12, 16, 126, 35, 62, 66, 226, 37, 102, 68, 202, 243, 29, 69, 27, 0, 0, + 0, 91, 67, + ]; + + assert_eq!( + MsgAcqResultDepC::MSG_ID, + 0x1f, + "Incorrect message type, expected 0x1f, is {}", + MsgAcqResultDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xc28, + "incorrect sender id, expected 0xc28, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(2.52723681640625000e+03), + "incorrect value for cf, expected 2.52723681640625000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cn0.almost_eq(4.75346603393554688e+01), + "incorrect value for cn0, expected 4.75346603393554688e+01, is {:e}", + msg.cn0 + ); + assert!( + msg.cp.almost_eq(9.20591918945312500e+02), + "incorrect value for cp, expected 9.20591918945312500e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 27, + "incorrect value for sid.sat, expected 27, is {}", + msg.sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepC"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_38.rs b/rust/sbp/tests/auto_check_sbp_acquisition_38.rs new file mode 100644 index 0000000000..92b8be33af --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_acquisition_38.rs @@ -0,0 +1,340 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_acquisition.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_acquisition_38() { + { + use sbp::messages::acquisition::MsgAcqResultDepA; + let payload: Vec = vec![ + 85, 21, 0, 195, 4, 13, 0, 0, 104, 65, 0, 192, 53, 68, 198, 199, 0, 70, 8, 2, 68, + ]; + + assert_eq!( + MsgAcqResultDepA::MSG_ID, + 0x15, + "Incorrect message type, expected 0x15, is {}", + MsgAcqResultDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(8.24194335937500000e+03), + "incorrect value for cf, expected 8.24194335937500000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(7.27000000000000000e+02), + "incorrect value for cp, expected 7.27000000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.prn, 8, + "incorrect value for prn, expected 8, is {}", + msg.prn + ); + assert!( + msg.snr.almost_eq(1.45000000000000000e+01), + "incorrect value for snr, expected 1.45000000000000000e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepA"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepA; + let payload: Vec = vec![ + 85, 21, 0, 195, 4, 13, 205, 204, 116, 65, 0, 192, 179, 67, 33, 81, 59, 68, 9, 219, 27, + ]; + + assert_eq!( + MsgAcqResultDepA::MSG_ID, + 0x15, + "Incorrect message type, expected 0x15, is {}", + MsgAcqResultDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(7.49267639160156250e+02), + "incorrect value for cf, expected 7.49267639160156250e+02, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(3.59500000000000000e+02), + "incorrect value for cp, expected 3.59500000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.prn, 9, + "incorrect value for prn, expected 9, is {}", + msg.prn + ); + assert!( + msg.snr.almost_eq(1.53000001907348633e+01), + "incorrect value for snr, expected 1.53000001907348633e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepA"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepA; + let payload: Vec = vec![ + 85, 21, 0, 195, 4, 13, 205, 204, 144, 65, 0, 0, 34, 66, 57, 237, 202, 197, 11, 150, 35, + ]; + + assert_eq!( + MsgAcqResultDepA::MSG_ID, + 0x15, + "Incorrect message type, expected 0x15, is {}", + MsgAcqResultDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(-6.49365283203125000e+03), + "incorrect value for cf, expected -6.49365283203125000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(4.05000000000000000e+01), + "incorrect value for cp, expected 4.05000000000000000e+01, is {:e}", + msg.cp + ); + assert_eq!( + msg.prn, 11, + "incorrect value for prn, expected 11, is {}", + msg.prn + ); + assert!( + msg.snr.almost_eq(1.81000003814697266e+01), + "incorrect value for snr, expected 1.81000003814697266e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepA"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepA; + let payload: Vec = vec![ + 85, 21, 0, 195, 4, 13, 205, 204, 116, 65, 0, 32, 9, 68, 129, 193, 121, 196, 12, 146, + 118, + ]; + + assert_eq!( + MsgAcqResultDepA::MSG_ID, + 0x15, + "Incorrect message type, expected 0x15, is {}", + MsgAcqResultDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(-9.99023498535156250e+02), + "incorrect value for cf, expected -9.99023498535156250e+02, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(5.48500000000000000e+02), + "incorrect value for cp, expected 5.48500000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.prn, 12, + "incorrect value for prn, expected 12, is {}", + msg.prn + ); + assert!( + msg.snr.almost_eq(1.53000001907348633e+01), + "incorrect value for snr, expected 1.53000001907348633e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepA"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepA; + let payload: Vec = vec![ + 85, 21, 0, 195, 4, 13, 205, 204, 116, 65, 0, 32, 67, 68, 228, 74, 148, 69, 14, 23, 75, + ]; + + assert_eq!( + MsgAcqResultDepA::MSG_ID, + 0x15, + "Incorrect message type, expected 0x15, is {}", + MsgAcqResultDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(4.74536132812500000e+03), + "incorrect value for cf, expected 4.74536132812500000e+03, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(7.80500000000000000e+02), + "incorrect value for cp, expected 7.80500000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.prn, 14, + "incorrect value for prn, expected 14, is {}", + msg.prn + ); + assert!( + msg.snr.almost_eq(1.53000001907348633e+01), + "incorrect value for snr, expected 1.53000001907348633e+01, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepA"), + }; + } + { + use sbp::messages::acquisition::MsgAcqResultDepA; + let payload: Vec = vec![ + 85, 21, 0, 195, 4, 13, 228, 56, 35, 67, 0, 32, 18, 68, 129, 193, 249, 195, 0, 204, 207, + ]; + + assert_eq!( + MsgAcqResultDepA::MSG_ID, + 0x15, + "Incorrect message type, expected 0x15, is {}", + MsgAcqResultDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAcqResultDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.cf.almost_eq(-4.99511749267578125e+02), + "incorrect value for cf, expected -4.99511749267578125e+02, is {:e}", + msg.cf + ); + assert!( + msg.cp.almost_eq(5.84500000000000000e+02), + "incorrect value for cp, expected 5.84500000000000000e+02, is {:e}", + msg.cp + ); + assert_eq!( + msg.prn, 0, + "incorrect value for prn, expected 0, is {}", + msg.prn + ); + assert!( + msg.snr.almost_eq(1.63222229003906250e+02), + "incorrect value for snr, expected 1.63222229003906250e+02, is {:e}", + msg.snr + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAcqResultDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_bootload_39.rs b/rust/sbp/tests/auto_check_sbp_bootload_39.rs new file mode 100644 index 0000000000..d43b541675 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_bootload_39.rs @@ -0,0 +1,137 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_bootload.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_bootload_39() { + { + use sbp::messages::bootload::MsgBootloaderHandshakeResp; + let payload: Vec = vec![85, 180, 0, 0, 0, 9, 0, 0, 0, 0, 118, 49, 46, 50, 10, 201, 1]; + + assert_eq!( + MsgBootloaderHandshakeResp::MSG_ID, + 0xb4, + "Incorrect message type, expected 0xb4, is {}", + MsgBootloaderHandshakeResp::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBootloaderHandshakeResp(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x0, + "incorrect sender id, expected 0x0, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.version, + "v1.2 +" + .to_string(), + "incorrect value for msg.version, expected string '{}', is '{}'", + "v1.2 +" + .to_string(), + msg.version + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBootloaderHandshakeResp" + ), + }; + } + { + use sbp::messages::bootload::MsgBootloaderHandshakeDepA; + let payload: Vec = vec![85, 176, 0, 195, 4, 4, 118, 49, 46, 50, 1, 206]; + + assert_eq!( + MsgBootloaderHandshakeDepA::MSG_ID, + 0xb0, + "Incorrect message type, expected 0xb0, is {}", + MsgBootloaderHandshakeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBootloaderHandshakeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.handshake[0], 118, + "incorrect value for handshake[0], expected 118, is {}", + msg.handshake[0] + ); + assert_eq!( + msg.handshake[1], 49, + "incorrect value for handshake[1], expected 49, is {}", + msg.handshake[1] + ); + assert_eq!( + msg.handshake[2], 46, + "incorrect value for handshake[2], expected 46, is {}", + msg.handshake[2] + ); + assert_eq!( + msg.handshake[3], 50, + "incorrect value for handshake[3], expected 50, is {}", + msg.handshake[3] + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBootloaderHandshakeDepA" + ), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_ext_events_40.rs b/rust/sbp/tests/auto_check_sbp_ext_events_40.rs new file mode 100644 index 0000000000..08ef2639de --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_ext_events_40.rs @@ -0,0 +1,94 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_ext_events.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_ext_events_40() { + { + use sbp::messages::ext_events::MsgExtEvent; + let payload: Vec = vec![ + 85, 1, 1, 245, 6, 12, 48, 7, 199, 216, 49, 15, 202, 65, 15, 0, 3, 0, 62, 204, + ]; + + assert_eq!( + MsgExtEvent::MSG_ID, + 0x101, + "Incorrect message type, expected 0x101, is {}", + MsgExtEvent::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgExtEvent(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x6f5, + "incorrect sender id, expected 0x6f5, is {}", + sender_id + ); + assert_eq!( + msg.flags, 3, + "incorrect value for flags, expected 3, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 999882, + "incorrect value for ns_residual, expected 999882, is {}", + msg.ns_residual + ); + assert_eq!( + msg.pin, 0, + "incorrect value for pin, expected 0, is {}", + msg.pin + ); + assert_eq!( + msg.tow, 254924999, + "incorrect value for tow, expected 254924999, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1840, + "incorrect value for wn, expected 1840, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgExtEvent"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_logging_41.rs b/rust/sbp/tests/auto_check_sbp_logging_41.rs new file mode 100644 index 0000000000..4163e3ed76 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_logging_41.rs @@ -0,0 +1,297 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_logging.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_logging_41() { + { + use sbp::messages::logging::MsgPrintDep; + let payload: Vec = vec![ + 85, 16, 0, 34, 34, 43, 73, 78, 70, 79, 58, 32, 97, 99, 113, 58, 32, 80, 82, 78, 32, 49, + 53, 32, 102, 111, 117, 110, 100, 32, 64, 32, 45, 50, 52, 57, 55, 32, 72, 122, 44, 32, + 50, 48, 32, 83, 78, 82, 10, 116, 103, + ]; + + assert_eq!( + MsgPrintDep::MSG_ID, + 0x10, + "Incorrect message type, expected 0x10, is {}", + MsgPrintDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPrintDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x2222, + "incorrect sender id, expected 0x2222, is {}", + sender_id + ); + assert_eq!( + msg.text, + "INFO: acq: PRN 15 found @ -2497 Hz, 20 SNR +" + .to_string(), + "incorrect value for msg.text, expected string '{}', is '{}'", + "INFO: acq: PRN 15 found @ -2497 Hz, 20 SNR +" + .to_string(), + msg.text + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPrintDep"), + }; + } + { + use sbp::messages::logging::MsgPrintDep; + let payload: Vec = vec![ + 85, 16, 0, 34, 34, 42, 73, 78, 70, 79, 58, 32, 97, 99, 113, 58, 32, 80, 82, 78, 32, 51, + 49, 32, 102, 111, 117, 110, 100, 32, 64, 32, 52, 50, 52, 53, 32, 72, 122, 44, 32, 50, + 49, 32, 83, 78, 82, 10, 140, 43, + ]; + + assert_eq!( + MsgPrintDep::MSG_ID, + 0x10, + "Incorrect message type, expected 0x10, is {}", + MsgPrintDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPrintDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x2222, + "incorrect sender id, expected 0x2222, is {}", + sender_id + ); + assert_eq!( + msg.text, + "INFO: acq: PRN 31 found @ 4245 Hz, 21 SNR +" + .to_string(), + "incorrect value for msg.text, expected string '{}', is '{}'", + "INFO: acq: PRN 31 found @ 4245 Hz, 21 SNR +" + .to_string(), + msg.text + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPrintDep"), + }; + } + { + use sbp::messages::logging::MsgPrintDep; + let payload: Vec = vec![ + 85, 16, 0, 34, 34, 35, 73, 78, 70, 79, 58, 32, 68, 105, 115, 97, 98, 108, 105, 110, + 103, 32, 99, 104, 97, 110, 110, 101, 108, 32, 48, 32, 40, 80, 82, 78, 32, 49, 49, 41, + 10, 23, 143, + ]; + + assert_eq!( + MsgPrintDep::MSG_ID, + 0x10, + "Incorrect message type, expected 0x10, is {}", + MsgPrintDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPrintDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x2222, + "incorrect sender id, expected 0x2222, is {}", + sender_id + ); + assert_eq!( + msg.text, + "INFO: Disabling channel 0 (PRN 11) +" + .to_string(), + "incorrect value for msg.text, expected string '{}', is '{}'", + "INFO: Disabling channel 0 (PRN 11) +" + .to_string(), + msg.text + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPrintDep"), + }; + } + { + use sbp::messages::logging::MsgPrintDep; + let payload: Vec = vec![ + 85, 16, 0, 34, 34, 41, 73, 78, 70, 79, 58, 32, 97, 99, 113, 58, 32, 80, 82, 78, 32, 50, + 32, 102, 111, 117, 110, 100, 32, 64, 32, 51, 57, 57, 54, 32, 72, 122, 44, 32, 50, 48, + 32, 83, 78, 82, 10, 239, 48, + ]; + + assert_eq!( + MsgPrintDep::MSG_ID, + 0x10, + "Incorrect message type, expected 0x10, is {}", + MsgPrintDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPrintDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x2222, + "incorrect sender id, expected 0x2222, is {}", + sender_id + ); + assert_eq!( + msg.text, + "INFO: acq: PRN 2 found @ 3996 Hz, 20 SNR +" + .to_string(), + "incorrect value for msg.text, expected string '{}', is '{}'", + "INFO: acq: PRN 2 found @ 3996 Hz, 20 SNR +" + .to_string(), + msg.text + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPrintDep"), + }; + } + { + use sbp::messages::logging::MsgPrintDep; + let payload: Vec = vec![ + 85, 16, 0, 34, 34, 42, 73, 78, 70, 79, 58, 32, 97, 99, 113, 58, 32, 80, 82, 78, 32, 52, + 32, 102, 111, 117, 110, 100, 32, 64, 32, 45, 55, 52, 57, 50, 32, 72, 122, 44, 32, 50, + 48, 32, 83, 78, 82, 10, 47, 248, + ]; + + assert_eq!( + MsgPrintDep::MSG_ID, + 0x10, + "Incorrect message type, expected 0x10, is {}", + MsgPrintDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPrintDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x2222, + "incorrect sender id, expected 0x2222, is {}", + sender_id + ); + assert_eq!( + msg.text, + "INFO: acq: PRN 4 found @ -7492 Hz, 20 SNR +" + .to_string(), + "incorrect value for msg.text, expected string '{}', is '{}'", + "INFO: acq: PRN 4 found @ -7492 Hz, 20 SNR +" + .to_string(), + msg.text + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPrintDep"), + }; + } + { + use sbp::messages::logging::MsgPrintDep; + let payload: Vec = vec![ + 85, 16, 0, 34, 34, 35, 73, 78, 70, 79, 58, 32, 68, 105, 115, 97, 98, 108, 105, 110, + 103, 32, 99, 104, 97, 110, 110, 101, 108, 32, 49, 32, 40, 80, 82, 78, 32, 49, 53, 41, + 10, 158, 139, + ]; + + assert_eq!( + MsgPrintDep::MSG_ID, + 0x10, + "Incorrect message type, expected 0x10, is {}", + MsgPrintDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPrintDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x2222, + "incorrect sender id, expected 0x2222, is {}", + sender_id + ); + assert_eq!( + msg.text, + "INFO: Disabling channel 1 (PRN 15) +" + .to_string(), + "incorrect value for msg.text, expected string '{}', is '{}'", + "INFO: Disabling channel 1 (PRN 15) +" + .to_string(), + msg.text + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPrintDep"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_logging_42.rs b/rust/sbp/tests/auto_check_sbp_logging_42.rs new file mode 100644 index 0000000000..4aaeedf819 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_logging_42.rs @@ -0,0 +1,87 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_msgFwd.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_logging_42() { + { + use sbp::messages::logging::MsgFwd; + let payload: Vec = vec![ + 85, 2, 4, 66, 0, 18, 0, 0, 86, 81, 68, 47, 81, 103, 65, 69, 65, 65, 65, 65, 65, 69, 97, + 103, 125, 95, + ]; + + assert_eq!( + MsgFwd::MSG_ID, + 0x402, + "Incorrect message type, expected 0x402, is {}", + MsgFwd::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgFwd(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.fwd_payload, + "VQD/QgAEAAAAAEag".to_string(), + "incorrect value for msg.fwd_payload, expected string '{}', is '{}'", + "VQD/QgAEAAAAAEag".to_string(), + msg.fwd_payload + ); + assert_eq!( + msg.protocol, 0, + "incorrect value for protocol, expected 0, is {}", + msg.protocol + ); + assert_eq!( + msg.source, 0, + "incorrect value for source, expected 0, is {}", + msg.source + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgFwd"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_10.rs b/rust/sbp/tests/auto_check_sbp_navigation_10.rs new file mode 100644 index 0000000000..96b15ce250 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_10.rs @@ -0,0 +1,289 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgGPSTime.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_10() { + { + use sbp::messages::navigation::MsgGPSTime; + let payload: Vec = vec![ + 85, 2, 1, 211, 136, 11, 128, 7, 40, 244, 122, 19, 244, 139, 2, 0, 0, 34, 152, + ]; + + assert_eq!( + MsgGPSTime::MSG_ID, + 0x102, + "Incorrect message type, expected 0x102, is {}", + MsgGPSTime::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTime(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 166900, + "incorrect value for ns_residual, expected 166900, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 326825000, + "incorrect value for tow, expected 326825000, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1920, + "incorrect value for wn, expected 1920, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTime"), + }; + } + { + use sbp::messages::navigation::MsgGPSTime; + let payload: Vec = vec![ + 85, 2, 1, 211, 136, 11, 128, 7, 28, 246, 122, 19, 126, 234, 3, 0, 0, 65, 3, + ]; + + assert_eq!( + MsgGPSTime::MSG_ID, + 0x102, + "Incorrect message type, expected 0x102, is {}", + MsgGPSTime::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTime(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 256638, + "incorrect value for ns_residual, expected 256638, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 326825500, + "incorrect value for tow, expected 326825500, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1920, + "incorrect value for wn, expected 1920, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTime"), + }; + } + { + use sbp::messages::navigation::MsgGPSTime; + let payload: Vec = vec![ + 85, 2, 1, 211, 136, 11, 128, 7, 16, 248, 122, 19, 129, 12, 4, 0, 0, 12, 84, + ]; + + assert_eq!( + MsgGPSTime::MSG_ID, + 0x102, + "Incorrect message type, expected 0x102, is {}", + MsgGPSTime::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTime(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 265345, + "incorrect value for ns_residual, expected 265345, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 326826000, + "incorrect value for tow, expected 326826000, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1920, + "incorrect value for wn, expected 1920, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTime"), + }; + } + { + use sbp::messages::navigation::MsgGPSTime; + let payload: Vec = vec![ + 85, 2, 1, 211, 136, 11, 128, 7, 4, 250, 122, 19, 137, 204, 4, 0, 0, 50, 165, + ]; + + assert_eq!( + MsgGPSTime::MSG_ID, + 0x102, + "Incorrect message type, expected 0x102, is {}", + MsgGPSTime::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTime(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 314505, + "incorrect value for ns_residual, expected 314505, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 326826500, + "incorrect value for tow, expected 326826500, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1920, + "incorrect value for wn, expected 1920, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTime"), + }; + } + { + use sbp::messages::navigation::MsgGPSTime; + let payload: Vec = vec![ + 85, 2, 1, 211, 136, 11, 128, 7, 248, 251, 122, 19, 181, 137, 5, 0, 0, 180, 33, + ]; + + assert_eq!( + MsgGPSTime::MSG_ID, + 0x102, + "Incorrect message type, expected 0x102, is {}", + MsgGPSTime::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTime(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 362933, + "incorrect value for ns_residual, expected 362933, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 326827000, + "incorrect value for tow, expected 326827000, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1920, + "incorrect value for wn, expected 1920, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTime"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_11.rs b/rust/sbp/tests/auto_check_sbp_navigation_11.rs new file mode 100644 index 0000000000..da36325b67 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_11.rs @@ -0,0 +1,289 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgGPSTimeDepA.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_11() { + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 246, 215, 11, 251, 6, 120, 46, 39, 0, 0, 0, 0, 0, 0, 133, 36, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 0, + "incorrect value for ns_residual, expected 0, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1787, + "incorrect value for wn, expected 1787, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 246, 215, 11, 251, 6, 220, 46, 39, 0, 0, 0, 0, 0, 0, 36, 160, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 0, + "incorrect value for ns_residual, expected 0, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 2567900, + "incorrect value for tow, expected 2567900, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1787, + "incorrect value for wn, expected 1787, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 246, 215, 11, 251, 6, 64, 47, 39, 0, 0, 0, 0, 0, 0, 171, 190, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 0, + "incorrect value for ns_residual, expected 0, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 2568000, + "incorrect value for tow, expected 2568000, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1787, + "incorrect value for wn, expected 1787, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 246, 215, 11, 251, 6, 164, 47, 39, 0, 0, 0, 0, 0, 0, 211, 101, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 0, + "incorrect value for ns_residual, expected 0, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 2568100, + "incorrect value for tow, expected 2568100, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1787, + "incorrect value for wn, expected 1787, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 246, 215, 11, 251, 6, 8, 48, 39, 0, 0, 0, 0, 0, 0, 251, 44, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 0, + "incorrect value for ns_residual, expected 0, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 2568200, + "incorrect value for tow, expected 2568200, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1787, + "incorrect value for wn, expected 1787, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_12.rs b/rust/sbp/tests/auto_check_sbp_navigation_12.rs new file mode 100644 index 0000000000..2813afce09 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_12.rs @@ -0,0 +1,305 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEF.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_12() { + { + use sbp::messages::navigation::MsgPosECEF; + let payload: Vec = vec![ + 85, 9, 2, 211, 136, 32, 16, 248, 122, 19, 73, 29, 46, 132, 182, 122, 68, 193, 219, 192, + 29, 176, 121, 119, 80, 193, 83, 11, 210, 90, 79, 75, 77, 65, 0, 0, 15, 2, 84, 6, + ]; + + assert_eq!( + MsgPosECEF::MSG_ID, + 0x209, + "Incorrect message type, expected 0x209, is {}", + MsgPosECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326826000, + "incorrect value for tow, expected 326826000, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.68426903265729966e+06), + "incorrect value for x, expected -2.68426903265729966e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.31664675181599986e+06), + "incorrect value for y, expected -4.31664675181599986e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.83964670953504136e+06), + "incorrect value for z, expected 3.83964670953504136e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEF"), + }; + } + { + use sbp::messages::navigation::MsgPosECEF; + let payload: Vec = vec![ + 85, 9, 2, 211, 136, 32, 248, 251, 122, 19, 103, 106, 57, 136, 182, 122, 68, 193, 176, + 242, 200, 176, 121, 119, 80, 193, 244, 135, 97, 59, 79, 75, 77, 65, 0, 0, 15, 2, 147, + 216, + ]; + + assert_eq!( + MsgPosECEF::MSG_ID, + 0x209, + "Incorrect message type, expected 0x209, is {}", + MsgPosECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326827000, + "incorrect value for tow, expected 326827000, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.68426906425218610e+06), + "incorrect value for x, expected -2.68426906425218610e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.31664676226489246e+06), + "incorrect value for y, expected -4.31664676226489246e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.83964646391391195e+06), + "incorrect value for z, expected 3.83964646391391195e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEF"), + }; + } + { + use sbp::messages::navigation::MsgPosECEF; + let payload: Vec = vec![ + 85, 9, 2, 211, 136, 32, 224, 255, 122, 19, 101, 179, 242, 182, 182, 122, 68, 193, 130, + 196, 145, 199, 121, 119, 80, 193, 212, 10, 253, 15, 79, 75, 77, 65, 0, 0, 15, 2, 40, + 201, + ]; + + assert_eq!( + MsgPosECEF::MSG_ID, + 0x209, + "Incorrect message type, expected 0x209, is {}", + MsgPosECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326828000, + "incorrect value for tow, expected 326828000, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.68426942928163940e+06), + "incorrect value for x, expected -2.68426942928163940e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.31664711827194877e+06), + "incorrect value for y, expected -4.31664711827194877e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.83964612490973808e+06), + "incorrect value for z, expected 3.83964612490973808e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEF"), + }; + } + { + use sbp::messages::navigation::MsgPosECEF; + let payload: Vec = vec![ + 85, 9, 2, 211, 136, 32, 200, 3, 123, 19, 146, 214, 132, 215, 182, 122, 68, 193, 213, + 68, 49, 215, 121, 119, 80, 193, 71, 34, 110, 243, 78, 75, 77, 65, 0, 0, 15, 2, 187, 86, + ]; + + assert_eq!( + MsgPosECEF::MSG_ID, + 0x209, + "Incorrect message type, expected 0x209, is {}", + MsgPosECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326829000, + "incorrect value for tow, expected 326829000, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.68426968374139909e+06), + "incorrect value for x, expected -2.68426968374139909e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.31664736238213349e+06), + "incorrect value for y, expected -4.31664736238213349e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.83964590179851977e+06), + "incorrect value for z, expected 3.83964590179851977e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEF"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_13.rs b/rust/sbp/tests/auto_check_sbp_navigation_13.rs new file mode 100644 index 0000000000..0537eb27ac --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_13.rs @@ -0,0 +1,131 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFCov.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_13() { + { + use sbp::messages::navigation::MsgPosECEFCov; + let payload: Vec = vec![ + 85, 20, 2, 66, 0, 54, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 64, 0, 0, 0, 0, 0, 0, 240, 63, + 0, 0, 0, 0, 0, 0, 16, 64, 0, 0, 0, 65, 0, 0, 224, 64, 0, 0, 0, 64, 0, 0, 192, 64, 0, 0, + 0, 65, 0, 0, 160, 64, 4, 5, 249, 167, + ]; + + assert_eq!( + MsgPosECEFCov::MSG_ID, + 0x214, + "Incorrect message type, expected 0x214, is {}", + MsgPosECEFCov::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFCov(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert!( + msg.cov_x_x.almost_eq(8.00000000000000000e+00), + "incorrect value for cov_x_x, expected 8.00000000000000000e+00, is {:e}", + msg.cov_x_x + ); + assert!( + msg.cov_x_y.almost_eq(7.00000000000000000e+00), + "incorrect value for cov_x_y, expected 7.00000000000000000e+00, is {:e}", + msg.cov_x_y + ); + assert!( + msg.cov_x_z.almost_eq(2.00000000000000000e+00), + "incorrect value for cov_x_z, expected 2.00000000000000000e+00, is {:e}", + msg.cov_x_z + ); + assert!( + msg.cov_y_y.almost_eq(6.00000000000000000e+00), + "incorrect value for cov_y_y, expected 6.00000000000000000e+00, is {:e}", + msg.cov_y_y + ); + assert!( + msg.cov_y_z.almost_eq(8.00000000000000000e+00), + "incorrect value for cov_y_z, expected 8.00000000000000000e+00, is {:e}", + msg.cov_y_z + ); + assert!( + msg.cov_z_z.almost_eq(5.00000000000000000e+00), + "incorrect value for cov_z_z, expected 5.00000000000000000e+00, is {:e}", + msg.cov_z_z + ); + assert_eq!( + msg.flags, 5, + "incorrect value for flags, expected 5, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 4, + "incorrect value for n_sats, expected 4, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 7, + "incorrect value for tow, expected 7, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(6.00000000000000000e+00), + "incorrect value for x, expected 6.00000000000000000e+00, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(1.00000000000000000e+00), + "incorrect value for y, expected 1.00000000000000000e+00, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(4.00000000000000000e+00), + "incorrect value for z, expected 4.00000000000000000e+00, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFCov"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_14.rs b/rust/sbp/tests/auto_check_sbp_navigation_14.rs new file mode 100644 index 0000000000..e287e46b74 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_14.rs @@ -0,0 +1,369 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFDepA.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_14() { + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 246, 215, 32, 20, 46, 39, 0, 195, 122, 175, 75, 33, 154, 68, 193, 164, 14, + 230, 176, 231, 95, 80, 193, 78, 220, 22, 253, 254, 105, 77, 65, 0, 0, 9, 0, 13, 86, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567700, + "incorrect value for tow, expected 2567700, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70035459129271051e+06), + "incorrect value for x, expected -2.70035459129271051e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.29251076404157653e+06), + "incorrect value for y, expected -4.29251076404157653e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.85535797726014908e+06), + "incorrect value for z, expected 3.85535797726014908e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 246, 215, 32, 20, 46, 39, 0, 212, 196, 12, 42, 34, 154, 68, 193, 9, 113, 112, + 123, 231, 95, 80, 193, 54, 97, 38, 192, 254, 105, 77, 65, 0, 0, 9, 1, 75, 143, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567700, + "incorrect value for tow, expected 2567700, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70035632851467468e+06), + "incorrect value for x, expected -2.70035632851467468e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.29250992873788718e+06), + "incorrect value for y, expected -4.29250992873788718e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.85535750117125642e+06), + "incorrect value for z, expected 3.85535750117125642e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 246, 215, 32, 120, 46, 39, 0, 112, 97, 39, 190, 34, 154, 68, 193, 230, 43, + 119, 115, 231, 95, 80, 193, 50, 199, 76, 66, 254, 105, 77, 65, 0, 0, 9, 0, 204, 113, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70035748557680100e+06), + "incorrect value for x, expected -2.70035748557680100e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.29250980414864980e+06), + "incorrect value for y, expected -4.29250980414864980e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.85535651796808187e+06), + "incorrect value for z, expected 3.85535651796808187e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 246, 215, 32, 120, 46, 39, 0, 194, 82, 121, 4, 34, 154, 68, 193, 223, 186, 1, + 140, 231, 95, 80, 193, 176, 152, 147, 181, 254, 105, 77, 65, 0, 0, 9, 1, 97, 71, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70035603495249245e+06), + "incorrect value for x, expected -2.70035603495249245e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.29251018760558870e+06), + "incorrect value for y, expected -4.29251018760558870e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.85535741856678575e+06), + "incorrect value for z, expected 3.85535741856678575e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 246, 215, 32, 220, 46, 39, 0, 216, 41, 227, 254, 33, 154, 68, 193, 9, 151, + 154, 124, 231, 95, 80, 193, 1, 183, 214, 139, 255, 105, 77, 65, 0, 0, 9, 0, 7, 98, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567900, + "incorrect value for tow, expected 2567900, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70035599130747840e+06), + "incorrect value for x, expected -2.70035599130747840e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.29250994693542365e+06), + "incorrect value for y, expected -4.29250994693542365e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.85535909249007748e+06), + "incorrect value for z, expected 3.85535909249007748e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_15.rs b/rust/sbp/tests/auto_check_sbp_navigation_15.rs new file mode 100644 index 0000000000..8b76145631 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_15.rs @@ -0,0 +1,399 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLH.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_15() { + { + use sbp::messages::navigation::MsgPosLLH; + let payload: Vec = vec![ + 85, 10, 2, 211, 136, 34, 40, 244, 122, 19, 201, 106, 155, 186, 42, 160, 66, 64, 168, + 109, 26, 225, 0, 120, 94, 192, 130, 102, 237, 230, 43, 54, 60, 64, 0, 0, 0, 0, 14, 2, + 175, 162, + ]; + + assert_eq!( + MsgPosLLH::MSG_ID, + 0x20a, + "Incorrect message type, expected 0x20a, is {}", + MsgPosLLH::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLH(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(2.82116073922720787e+01), + "incorrect value for height, expected 2.82116073922720787e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.72513039835808470e+01), + "incorrect value for lat, expected 3.72513039835808470e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.21875053668793612e+02), + "incorrect value for lon, expected -1.21875053668793612e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 14, + "incorrect value for n_sats, expected 14, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326825000, + "incorrect value for tow, expected 326825000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLH"), + }; + } + { + use sbp::messages::navigation::MsgPosLLH; + let payload: Vec = vec![ + 85, 10, 2, 211, 136, 34, 16, 248, 122, 19, 52, 177, 251, 178, 42, 160, 66, 64, 237, 22, + 97, 224, 0, 120, 94, 192, 107, 188, 109, 90, 247, 189, 59, 64, 0, 0, 0, 0, 15, 2, 38, + 177, + ]; + + assert_eq!( + MsgPosLLH::MSG_ID, + 0x20a, + "Incorrect message type, expected 0x20a, is {}", + MsgPosLLH::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLH(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(2.77420555608663726e+01), + "incorrect value for height, expected 2.77420555608663726e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.72513030747381038e+01), + "incorrect value for lat, expected 3.72513030747381038e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.21875053496183412e+02), + "incorrect value for lon, expected -1.21875053496183412e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326826000, + "incorrect value for tow, expected 326826000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLH"), + }; + } + { + use sbp::messages::navigation::MsgPosLLH; + let payload: Vec = vec![ + 85, 10, 2, 211, 136, 34, 248, 251, 122, 19, 135, 66, 9, 163, 42, 160, 66, 64, 146, 8, + 99, 225, 0, 120, 94, 192, 45, 181, 143, 219, 28, 157, 59, 64, 0, 0, 0, 0, 15, 2, 51, + 40, + ]; + + assert_eq!( + MsgPosLLH::MSG_ID, + 0x20a, + "Incorrect message type, expected 0x20a, is {}", + MsgPosLLH::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLH(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(2.76137215829705163e+01), + "incorrect value for height, expected 2.76137215829705163e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.72513011737074109e+01), + "incorrect value for lat, expected 3.72513011737074109e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.21875053736412411e+02), + "incorrect value for lon, expected -1.21875053736412411e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326827000, + "incorrect value for tow, expected 326827000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLH"), + }; + } + { + use sbp::messages::navigation::MsgPosLLH; + let payload: Vec = vec![ + 85, 10, 2, 211, 136, 34, 224, 255, 122, 19, 18, 44, 253, 119, 42, 160, 66, 64, 48, 109, + 39, 231, 0, 120, 94, 192, 185, 76, 48, 17, 119, 205, 59, 64, 0, 0, 0, 0, 15, 2, 12, + 194, + ]; + + assert_eq!( + MsgPosLLH::MSG_ID, + 0x20a, + "Incorrect message type, expected 0x20a, is {}", + MsgPosLLH::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLH(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(2.78025980704230484e+01), + "incorrect value for height, expected 2.78025980704230484e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.72512960420791757e+01), + "incorrect value for lat, expected 3.72512960420791757e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.21875055111410575e+02), + "incorrect value for lon, expected -1.21875055111410575e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326828000, + "incorrect value for tow, expected 326828000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLH"), + }; + } + { + use sbp::messages::navigation::MsgPosLLH; + let payload: Vec = vec![ + 85, 10, 2, 211, 136, 34, 200, 3, 123, 19, 225, 237, 238, 90, 42, 160, 66, 64, 59, 143, + 70, 235, 0, 120, 94, 192, 101, 106, 249, 224, 131, 240, 59, 64, 0, 0, 0, 0, 15, 2, 34, + 103, + ]; + + assert_eq!( + MsgPosLLH::MSG_ID, + 0x20a, + "Incorrect message type, expected 0x20a, is {}", + MsgPosLLH::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLH(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 2, + "incorrect value for flags, expected 2, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(2.79395123108792127e+01), + "incorrect value for height, expected 2.79395123108792127e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.72512925783773952e+01), + "incorrect value for lat, expected 3.72512925783773952e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.21875056094079739e+02), + "incorrect value for lon, expected -1.21875056094079739e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326829000, + "incorrect value for tow, expected 326829000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLH"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_16.rs b/rust/sbp/tests/auto_check_sbp_navigation_16.rs new file mode 100644 index 0000000000..a9421a050d --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_16.rs @@ -0,0 +1,131 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLHCov.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_16() { + { + use sbp::messages::navigation::MsgPosLLHCov; + let payload: Vec = vec![ + 85, 17, 2, 66, 0, 54, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 64, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 64, 0, 0, 160, 64, 0, 0, 0, 65, 0, 0, 192, 64, 0, 0, + 128, 63, 0, 0, 0, 64, 5, 5, 151, 98, + ]; + + assert_eq!( + MsgPosLLHCov::MSG_ID, + 0x211, + "Incorrect message type, expected 0x211, is {}", + MsgPosLLHCov::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHCov(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert!( + msg.cov_d_d.almost_eq(2.00000000000000000e+00), + "incorrect value for cov_d_d, expected 2.00000000000000000e+00, is {:e}", + msg.cov_d_d + ); + assert!( + msg.cov_e_d.almost_eq(1.00000000000000000e+00), + "incorrect value for cov_e_d, expected 1.00000000000000000e+00, is {:e}", + msg.cov_e_d + ); + assert!( + msg.cov_e_e.almost_eq(6.00000000000000000e+00), + "incorrect value for cov_e_e, expected 6.00000000000000000e+00, is {:e}", + msg.cov_e_e + ); + assert!( + msg.cov_n_d.almost_eq(8.00000000000000000e+00), + "incorrect value for cov_n_d, expected 8.00000000000000000e+00, is {:e}", + msg.cov_n_d + ); + assert!( + msg.cov_n_e.almost_eq(5.00000000000000000e+00), + "incorrect value for cov_n_e, expected 5.00000000000000000e+00, is {:e}", + msg.cov_n_e + ); + assert!( + msg.cov_n_n.almost_eq(7.00000000000000000e+00), + "incorrect value for cov_n_n, expected 7.00000000000000000e+00, is {:e}", + msg.cov_n_n + ); + assert_eq!( + msg.flags, 5, + "incorrect value for flags, expected 5, is {}", + msg.flags + ); + assert!( + msg.height.almost_eq(0.00000000000000000e+00), + "incorrect value for height, expected 0.00000000000000000e+00, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(0.00000000000000000e+00), + "incorrect value for lat, expected 0.00000000000000000e+00, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(7.00000000000000000e+00), + "incorrect value for lon, expected 7.00000000000000000e+00, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 5, + "incorrect value for n_sats, expected 5, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 7, + "incorrect value for tow, expected 7, is {}", + msg.tow + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHCov"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_17.rs b/rust/sbp/tests/auto_check_sbp_navigation_17.rs new file mode 100644 index 0000000000..c03b52592b --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_17.rs @@ -0,0 +1,398 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLHDepA.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_17() { + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 246, 215, 34, 20, 46, 39, 0, 250, 29, 226, 186, 235, 182, 66, 64, 19, 203, + 51, 196, 24, 139, 94, 192, 31, 157, 160, 232, 122, 115, 81, 64, 0, 0, 0, 0, 9, 0, 236, + 139, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(6.98043767517560667e+01), + "incorrect value for height, expected 6.98043767517560667e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.74290689090812094e+01), + "incorrect value for lat, expected 3.74290689090812094e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22173386622027735e+02), + "incorrect value for lon, expected -1.22173386622027735e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567700, + "incorrect value for tow, expected 2567700, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 246, 215, 34, 20, 46, 39, 0, 161, 51, 75, 148, 235, 182, 66, 64, 36, 41, 246, + 30, 25, 139, 94, 192, 254, 218, 49, 127, 10, 108, 81, 64, 0, 0, 0, 0, 9, 1, 25, 117, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(6.96881406771535410e+01), + "incorrect value for height, expected 6.96881406771535410e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.74290643088527375e+01), + "incorrect value for lat, expected 3.74290643088527375e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22173408260718645e+02), + "incorrect value for lon, expected -1.22173408260718645e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567700, + "incorrect value for tow, expected 2567700, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 246, 215, 34, 120, 46, 39, 0, 56, 214, 210, 65, 235, 182, 66, 64, 13, 46, + 132, 80, 25, 139, 94, 192, 22, 143, 46, 234, 191, 95, 81, 64, 0, 0, 0, 0, 9, 0, 174, + 105, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(6.94960885481526418e+01), + "incorrect value for height, expected 6.94960885481526418e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.74290544776417278e+01), + "incorrect value for lat, expected 3.74290544776417278e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22173420075494690e+02), + "incorrect value for lon, expected -1.22173420075494690e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 246, 215, 34, 120, 46, 39, 0, 251, 117, 115, 140, 235, 182, 66, 64, 152, 134, + 167, 12, 25, 139, 94, 192, 160, 22, 137, 253, 4, 108, 81, 64, 0, 0, 0, 0, 9, 1, 122, + 127, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(6.96878045881990147e+01), + "incorrect value for height, expected 6.96878045881990147e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.74290633739255654e+01), + "incorrect value for lat, expected 3.74290633739255654e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22173403895949718e+02), + "incorrect value for lon, expected -1.22173403895949718e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 246, 215, 34, 220, 46, 39, 0, 51, 124, 88, 251, 235, 182, 66, 64, 153, 5, + 250, 16, 25, 139, 94, 192, 146, 60, 187, 219, 152, 161, 81, 64, 0, 0, 0, 0, 9, 0, 194, + 158, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(7.05249547317964982e+01), + "incorrect value for height, expected 7.05249547317964982e+01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.74290765935951626e+01), + "incorrect value for lat, expected 3.74290765935951626e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22173404926454523e+02), + "incorrect value for lon, expected -1.22173404926454523e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567900, + "incorrect value for tow, expected 2567900, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_18.rs b/rust/sbp/tests/auto_check_sbp_navigation_18.rs new file mode 100644 index 0000000000..acb897e9b9 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_18.rs @@ -0,0 +1,118 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelBody.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_18() { + { + use sbp::messages::navigation::MsgVelBody; + let payload: Vec = vec![ + 85, 19, 2, 66, 0, 42, 1, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 160, 64, 0, 0, 224, 64, 0, 0, 224, 64, 0, 0, 64, 64, 0, 0, 0, 64, 3, 8, 120, 144, + ]; + + assert_eq!( + MsgVelBody::MSG_ID, + 0x213, + "Incorrect message type, expected 0x213, is {}", + MsgVelBody::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelBody(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert!( + msg.cov_x_x.almost_eq(0.00000000000000000e+00), + "incorrect value for cov_x_x, expected 0.00000000000000000e+00, is {:e}", + msg.cov_x_x + ); + assert!( + msg.cov_x_y.almost_eq(5.00000000000000000e+00), + "incorrect value for cov_x_y, expected 5.00000000000000000e+00, is {:e}", + msg.cov_x_y + ); + assert!( + msg.cov_x_z.almost_eq(7.00000000000000000e+00), + "incorrect value for cov_x_z, expected 7.00000000000000000e+00, is {:e}", + msg.cov_x_z + ); + assert!( + msg.cov_y_y.almost_eq(7.00000000000000000e+00), + "incorrect value for cov_y_y, expected 7.00000000000000000e+00, is {:e}", + msg.cov_y_y + ); + assert!( + msg.cov_y_z.almost_eq(3.00000000000000000e+00), + "incorrect value for cov_y_z, expected 3.00000000000000000e+00, is {:e}", + msg.cov_y_z + ); + assert!( + msg.cov_z_z.almost_eq(2.00000000000000000e+00), + "incorrect value for cov_z_z, expected 2.00000000000000000e+00, is {:e}", + msg.cov_z_z + ); + assert_eq!( + msg.flags, 8, + "incorrect value for flags, expected 8, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 3, + "incorrect value for n_sats, expected 3, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 1, + "incorrect value for tow, expected 1, is {}", + msg.tow + ); + assert_eq!(msg.x, 4, "incorrect value for x, expected 4, is {}", msg.x); + assert_eq!(msg.y, 2, "incorrect value for y, expected 2, is {}", msg.y); + assert_eq!(msg.z, 1, "incorrect value for z, expected 1, is {}", msg.z); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelBody"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_19.rs b/rust/sbp/tests/auto_check_sbp_navigation_19.rs new file mode 100644 index 0000000000..f520ad446e --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_19.rs @@ -0,0 +1,365 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEF.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_19() { + { + use sbp::messages::navigation::MsgVelECEF; + let payload: Vec = vec![ + 85, 13, 2, 211, 136, 20, 40, 244, 122, 19, 248, 255, 255, 255, 251, 255, 255, 255, 10, + 0, 0, 0, 0, 0, 14, 0, 181, 99, + ]; + + assert_eq!( + MsgVelECEF::MSG_ID, + 0x20d, + "Incorrect message type, expected 0x20d, is {}", + MsgVelECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 14, + "incorrect value for n_sats, expected 14, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326825000, + "incorrect value for tow, expected 326825000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -8, + "incorrect value for x, expected -8, is {}", + msg.x + ); + assert_eq!( + msg.y, -5, + "incorrect value for y, expected -5, is {}", + msg.y + ); + assert_eq!( + msg.z, 10, + "incorrect value for z, expected 10, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEF"), + }; + } + { + use sbp::messages::navigation::MsgVelECEF; + let payload: Vec = vec![ + 85, 13, 2, 211, 136, 20, 28, 246, 122, 19, 244, 255, 255, 255, 238, 255, 255, 255, 11, + 0, 0, 0, 0, 0, 15, 0, 215, 120, + ]; + + assert_eq!( + MsgVelECEF::MSG_ID, + 0x20d, + "Incorrect message type, expected 0x20d, is {}", + MsgVelECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326825500, + "incorrect value for tow, expected 326825500, is {}", + msg.tow + ); + assert_eq!( + msg.x, -12, + "incorrect value for x, expected -12, is {}", + msg.x + ); + assert_eq!( + msg.y, -18, + "incorrect value for y, expected -18, is {}", + msg.y + ); + assert_eq!( + msg.z, 11, + "incorrect value for z, expected 11, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEF"), + }; + } + { + use sbp::messages::navigation::MsgVelECEF; + let payload: Vec = vec![ + 85, 13, 2, 211, 136, 20, 16, 248, 122, 19, 248, 255, 255, 255, 250, 255, 255, 255, 7, + 0, 0, 0, 0, 0, 15, 0, 248, 221, + ]; + + assert_eq!( + MsgVelECEF::MSG_ID, + 0x20d, + "Incorrect message type, expected 0x20d, is {}", + MsgVelECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326826000, + "incorrect value for tow, expected 326826000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -8, + "incorrect value for x, expected -8, is {}", + msg.x + ); + assert_eq!( + msg.y, -6, + "incorrect value for y, expected -6, is {}", + msg.y + ); + assert_eq!(msg.z, 7, "incorrect value for z, expected 7, is {}", msg.z); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEF"), + }; + } + { + use sbp::messages::navigation::MsgVelECEF; + let payload: Vec = vec![ + 85, 13, 2, 211, 136, 20, 4, 250, 122, 19, 249, 255, 255, 255, 239, 255, 255, 255, 16, + 0, 0, 0, 0, 0, 15, 0, 1, 167, + ]; + + assert_eq!( + MsgVelECEF::MSG_ID, + 0x20d, + "Incorrect message type, expected 0x20d, is {}", + MsgVelECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326826500, + "incorrect value for tow, expected 326826500, is {}", + msg.tow + ); + assert_eq!( + msg.x, -7, + "incorrect value for x, expected -7, is {}", + msg.x + ); + assert_eq!( + msg.y, -17, + "incorrect value for y, expected -17, is {}", + msg.y + ); + assert_eq!( + msg.z, 16, + "incorrect value for z, expected 16, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEF"), + }; + } + { + use sbp::messages::navigation::MsgVelECEF; + let payload: Vec = vec![ + 85, 13, 2, 211, 136, 20, 248, 251, 122, 19, 247, 255, 255, 255, 243, 255, 255, 255, 14, + 0, 0, 0, 0, 0, 15, 0, 191, 43, + ]; + + assert_eq!( + MsgVelECEF::MSG_ID, + 0x20d, + "Incorrect message type, expected 0x20d, is {}", + MsgVelECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326827000, + "incorrect value for tow, expected 326827000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -9, + "incorrect value for x, expected -9, is {}", + msg.x + ); + assert_eq!( + msg.y, -13, + "incorrect value for y, expected -13, is {}", + msg.y + ); + assert_eq!( + msg.z, 14, + "incorrect value for z, expected 14, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEF"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_20.rs b/rust/sbp/tests/auto_check_sbp_navigation_20.rs new file mode 100644 index 0000000000..06c14b0acf --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_20.rs @@ -0,0 +1,118 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEFCov.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_20() { + { + use sbp::messages::navigation::MsgVelECEFCov; + let payload: Vec = vec![ + 85, 21, 2, 66, 0, 42, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 64, 0, + 0, 0, 64, 0, 0, 0, 64, 0, 0, 0, 64, 0, 0, 128, 63, 0, 0, 64, 64, 3, 4, 91, 254, + ]; + + assert_eq!( + MsgVelECEFCov::MSG_ID, + 0x215, + "Incorrect message type, expected 0x215, is {}", + MsgVelECEFCov::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFCov(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert!( + msg.cov_x_x.almost_eq(2.00000000000000000e+00), + "incorrect value for cov_x_x, expected 2.00000000000000000e+00, is {:e}", + msg.cov_x_x + ); + assert!( + msg.cov_x_y.almost_eq(2.00000000000000000e+00), + "incorrect value for cov_x_y, expected 2.00000000000000000e+00, is {:e}", + msg.cov_x_y + ); + assert!( + msg.cov_x_z.almost_eq(2.00000000000000000e+00), + "incorrect value for cov_x_z, expected 2.00000000000000000e+00, is {:e}", + msg.cov_x_z + ); + assert!( + msg.cov_y_y.almost_eq(2.00000000000000000e+00), + "incorrect value for cov_y_y, expected 2.00000000000000000e+00, is {:e}", + msg.cov_y_y + ); + assert!( + msg.cov_y_z.almost_eq(1.00000000000000000e+00), + "incorrect value for cov_y_z, expected 1.00000000000000000e+00, is {:e}", + msg.cov_y_z + ); + assert!( + msg.cov_z_z.almost_eq(3.00000000000000000e+00), + "incorrect value for cov_z_z, expected 3.00000000000000000e+00, is {:e}", + msg.cov_z_z + ); + assert_eq!( + msg.flags, 4, + "incorrect value for flags, expected 4, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 3, + "incorrect value for n_sats, expected 3, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2, + "incorrect value for tow, expected 2, is {}", + msg.tow + ); + assert_eq!(msg.x, 0, "incorrect value for x, expected 0, is {}", msg.x); + assert_eq!(msg.y, 0, "incorrect value for y, expected 0, is {}", msg.y); + assert_eq!(msg.z, 6, "incorrect value for z, expected 6, is {}", msg.z); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFCov"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_21.rs b/rust/sbp/tests/auto_check_sbp_navigation_21.rs new file mode 100644 index 0000000000..ea845efc5a --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_21.rs @@ -0,0 +1,369 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEFDepA.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_21() { + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 246, 215, 20, 20, 46, 39, 0, 218, 11, 0, 0, 134, 245, 255, 255, 163, 252, + 255, 255, 0, 0, 9, 0, 80, 236, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567700, + "incorrect value for tow, expected 2567700, is {}", + msg.tow + ); + assert_eq!( + msg.x, 3034, + "incorrect value for x, expected 3034, is {}", + msg.x + ); + assert_eq!( + msg.y, -2682, + "incorrect value for y, expected -2682, is {}", + msg.y + ); + assert_eq!( + msg.z, -861, + "incorrect value for z, expected -861, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 246, 215, 20, 120, 46, 39, 0, 68, 11, 0, 0, 24, 246, 255, 255, 220, 252, 255, + 255, 0, 0, 9, 0, 248, 138, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert_eq!( + msg.x, 2884, + "incorrect value for x, expected 2884, is {}", + msg.x + ); + assert_eq!( + msg.y, -2536, + "incorrect value for y, expected -2536, is {}", + msg.y + ); + assert_eq!( + msg.z, -804, + "incorrect value for z, expected -804, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 246, 215, 20, 220, 46, 39, 0, 21, 11, 0, 0, 77, 246, 255, 255, 247, 252, 255, + 255, 0, 0, 9, 0, 25, 174, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567900, + "incorrect value for tow, expected 2567900, is {}", + msg.tow + ); + assert_eq!( + msg.x, 2837, + "incorrect value for x, expected 2837, is {}", + msg.x + ); + assert_eq!( + msg.y, -2483, + "incorrect value for y, expected -2483, is {}", + msg.y + ); + assert_eq!( + msg.z, -777, + "incorrect value for z, expected -777, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 246, 215, 20, 64, 47, 39, 0, 121, 11, 0, 0, 2, 246, 255, 255, 234, 252, 255, + 255, 0, 0, 9, 0, 195, 228, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2568000, + "incorrect value for tow, expected 2568000, is {}", + msg.tow + ); + assert_eq!( + msg.x, 2937, + "incorrect value for x, expected 2937, is {}", + msg.x + ); + assert_eq!( + msg.y, -2558, + "incorrect value for y, expected -2558, is {}", + msg.y + ); + assert_eq!( + msg.z, -790, + "incorrect value for z, expected -790, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 246, 215, 20, 164, 47, 39, 0, 31, 11, 0, 0, 93, 246, 255, 255, 16, 253, 255, + 255, 0, 0, 9, 0, 219, 164, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2568100, + "incorrect value for tow, expected 2568100, is {}", + msg.tow + ); + assert_eq!( + msg.x, 2847, + "incorrect value for x, expected 2847, is {}", + msg.x + ); + assert_eq!( + msg.y, -2467, + "incorrect value for y, expected -2467, is {}", + msg.y + ); + assert_eq!( + msg.z, -752, + "incorrect value for z, expected -752, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_22.rs b/rust/sbp/tests/auto_check_sbp_navigation_22.rs new file mode 100644 index 0000000000..504ef3aa57 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_22.rs @@ -0,0 +1,370 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNED.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_22() { + { + use sbp::messages::navigation::MsgVelNED; + let payload: Vec = vec![ + 85, 14, 2, 211, 136, 22, 40, 244, 122, 19, 3, 0, 0, 0, 252, 255, 255, 255, 243, 255, + 255, 255, 0, 0, 0, 0, 14, 0, 86, 209, + ]; + + assert_eq!( + MsgVelNED::MSG_ID, + 0x20e, + "Incorrect message type, expected 0x20e, is {}", + MsgVelNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, -13, + "incorrect value for d, expected -13, is {}", + msg.d + ); + assert_eq!( + msg.e, -4, + "incorrect value for e, expected -4, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!(msg.n, 3, "incorrect value for n, expected 3, is {}", msg.n); + assert_eq!( + msg.n_sats, 14, + "incorrect value for n_sats, expected 14, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326825000, + "incorrect value for tow, expected 326825000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNED"), + }; + } + { + use sbp::messages::navigation::MsgVelNED; + let payload: Vec = vec![ + 85, 14, 2, 211, 136, 22, 28, 246, 122, 19, 252, 255, 255, 255, 255, 255, 255, 255, 232, + 255, 255, 255, 0, 0, 0, 0, 15, 0, 16, 228, + ]; + + assert_eq!( + MsgVelNED::MSG_ID, + 0x20e, + "Incorrect message type, expected 0x20e, is {}", + MsgVelNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, -24, + "incorrect value for d, expected -24, is {}", + msg.d + ); + assert_eq!( + msg.e, -1, + "incorrect value for e, expected -1, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -4, + "incorrect value for n, expected -4, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326825500, + "incorrect value for tow, expected 326825500, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNED"), + }; + } + { + use sbp::messages::navigation::MsgVelNED; + let payload: Vec = vec![ + 85, 14, 2, 211, 136, 22, 16, 248, 122, 19, 0, 0, 0, 0, 253, 255, 255, 255, 244, 255, + 255, 255, 0, 0, 0, 0, 15, 0, 11, 164, + ]; + + assert_eq!( + MsgVelNED::MSG_ID, + 0x20e, + "Incorrect message type, expected 0x20e, is {}", + MsgVelNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, -12, + "incorrect value for d, expected -12, is {}", + msg.d + ); + assert_eq!( + msg.e, -3, + "incorrect value for e, expected -3, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!(msg.n, 0, "incorrect value for n, expected 0, is {}", msg.n); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326826000, + "incorrect value for tow, expected 326826000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNED"), + }; + } + { + use sbp::messages::navigation::MsgVelNED; + let payload: Vec = vec![ + 85, 14, 2, 211, 136, 22, 4, 250, 122, 19, 2, 0, 0, 0, 3, 0, 0, 0, 232, 255, 255, 255, + 0, 0, 0, 0, 15, 0, 152, 208, + ]; + + assert_eq!( + MsgVelNED::MSG_ID, + 0x20e, + "Incorrect message type, expected 0x20e, is {}", + MsgVelNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, -24, + "incorrect value for d, expected -24, is {}", + msg.d + ); + assert_eq!(msg.e, 3, "incorrect value for e, expected 3, is {}", msg.e); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!(msg.n, 2, "incorrect value for n, expected 2, is {}", msg.n); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326826500, + "incorrect value for tow, expected 326826500, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNED"), + }; + } + { + use sbp::messages::navigation::MsgVelNED; + let payload: Vec = vec![ + 85, 14, 2, 211, 136, 22, 248, 251, 122, 19, 1, 0, 0, 0, 0, 0, 0, 0, 235, 255, 255, 255, + 0, 0, 0, 0, 15, 0, 182, 120, + ]; + + assert_eq!( + MsgVelNED::MSG_ID, + 0x20e, + "Incorrect message type, expected 0x20e, is {}", + MsgVelNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, -21, + "incorrect value for d, expected -21, is {}", + msg.d + ); + assert_eq!(msg.e, 0, "incorrect value for e, expected 0, is {}", msg.e); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!(msg.n, 1, "incorrect value for n, expected 1, is {}", msg.n); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326827000, + "incorrect value for tow, expected 326827000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNED"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_23.rs b/rust/sbp/tests/auto_check_sbp_navigation_23.rs new file mode 100644 index 0000000000..733fc7f5d2 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_23.rs @@ -0,0 +1,118 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNEDCOV.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_23() { + { + use sbp::messages::navigation::MsgVelNEDCov; + let payload: Vec = vec![ + 85, 18, 2, 66, 0, 42, 100, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 10, 0, 88, + 205, + ]; + + assert_eq!( + MsgVelNEDCov::MSG_ID, + 0x212, + "Incorrect message type, expected 0x212, is {}", + MsgVelNEDCov::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDCov(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert!( + msg.cov_d_d.almost_eq(1.00000000000000000e+00), + "incorrect value for cov_d_d, expected 1.00000000000000000e+00, is {:e}", + msg.cov_d_d + ); + assert!( + msg.cov_e_d.almost_eq(1.00000000000000000e+00), + "incorrect value for cov_e_d, expected 1.00000000000000000e+00, is {:e}", + msg.cov_e_d + ); + assert!( + msg.cov_e_e.almost_eq(1.00000000000000000e+00), + "incorrect value for cov_e_e, expected 1.00000000000000000e+00, is {:e}", + msg.cov_e_e + ); + assert!( + msg.cov_n_d.almost_eq(1.00000000000000000e+00), + "incorrect value for cov_n_d, expected 1.00000000000000000e+00, is {:e}", + msg.cov_n_d + ); + assert!( + msg.cov_n_e.almost_eq(1.00000000000000000e+00), + "incorrect value for cov_n_e, expected 1.00000000000000000e+00, is {:e}", + msg.cov_n_e + ); + assert!( + msg.cov_n_n.almost_eq(1.00000000000000000e+00), + "incorrect value for cov_n_n, expected 1.00000000000000000e+00, is {:e}", + msg.cov_n_n + ); + assert_eq!(msg.e, 1, "incorrect value for e, expected 1, is {}", msg.e); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!(msg.n, 1, "incorrect value for n, expected 1, is {}", msg.n); + assert_eq!( + msg.n_sats, 10, + "incorrect value for n_sats, expected 10, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 100, + "incorrect value for tow, expected 100, is {}", + msg.tow + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDCov"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_24.rs b/rust/sbp/tests/auto_check_sbp_navigation_24.rs new file mode 100644 index 0000000000..b8662f1363 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_24.rs @@ -0,0 +1,374 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNEDDepA.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_24() { + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 246, 215, 22, 20, 46, 39, 0, 198, 251, 255, 255, 156, 15, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 161, 92, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, 3996, + "incorrect value for e, expected 3996, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -1082, + "incorrect value for n, expected -1082, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567700, + "incorrect value for tow, expected 2567700, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 246, 215, 22, 120, 46, 39, 0, 14, 252, 255, 255, 207, 14, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 125, 160, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, 3791, + "incorrect value for e, expected 3791, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -1010, + "incorrect value for n, expected -1010, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 246, 215, 22, 220, 46, 39, 0, 48, 252, 255, 255, 140, 14, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 179, 135, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, 3724, + "incorrect value for e, expected 3724, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -976, + "incorrect value for n, expected -976, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567900, + "incorrect value for tow, expected 2567900, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 246, 215, 22, 64, 47, 39, 0, 32, 252, 255, 255, 8, 15, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 0, 51, 177, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, 3848, + "incorrect value for e, expected 3848, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -992, + "incorrect value for n, expected -992, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2568000, + "incorrect value for tow, expected 2568000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 246, 215, 22, 164, 47, 39, 0, 80, 252, 255, 255, 140, 14, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 23, 0, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, 3724, + "incorrect value for e, expected 3724, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -944, + "incorrect value for n, expected -944, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2568100, + "incorrect value for tow, expected 2568100, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_3.rs b/rust/sbp/tests/auto_check_sbp_navigation_3.rs new file mode 100644 index 0000000000..372c6b15d5 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_3.rs @@ -0,0 +1,77 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgAgeCorrections.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_3() { + { + use sbp::messages::navigation::MsgAgeCorrections; + let payload: Vec = vec![85, 16, 2, 66, 0, 6, 100, 0, 0, 0, 30, 0, 233, 202]; + + assert_eq!( + MsgAgeCorrections::MSG_ID, + 0x210, + "Incorrect message type, expected 0x210, is {}", + MsgAgeCorrections::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAgeCorrections(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.age, 30, + "incorrect value for age, expected 30, is {}", + msg.age + ); + assert_eq!( + msg.tow, 100, + "incorrect value for tow, expected 100, is {}", + msg.tow + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgAgeCorrections"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_4.rs b/rust/sbp/tests/auto_check_sbp_navigation_4.rs new file mode 100644 index 0000000000..7b9e41c1df --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_4.rs @@ -0,0 +1,369 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgBaselineECEF.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_4() { + { + use sbp::messages::navigation::MsgBaselineECEF; + let payload: Vec = vec![ + 85, 11, 2, 211, 136, 20, 40, 244, 122, 19, 150, 98, 238, 255, 190, 64, 20, 0, 246, 163, + 9, 0, 0, 0, 14, 0, 219, 191, + ]; + + assert_eq!( + MsgBaselineECEF::MSG_ID, + 0x20b, + "Incorrect message type, expected 0x20b, is {}", + MsgBaselineECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 14, + "incorrect value for n_sats, expected 14, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326825000, + "incorrect value for tow, expected 326825000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -1154410, + "incorrect value for x, expected -1154410, is {}", + msg.x + ); + assert_eq!( + msg.y, 1327294, + "incorrect value for y, expected 1327294, is {}", + msg.y + ); + assert_eq!( + msg.z, 631798, + "incorrect value for z, expected 631798, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineECEF"), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEF; + let payload: Vec = vec![ + 85, 11, 2, 211, 136, 20, 16, 248, 122, 19, 72, 99, 238, 255, 191, 65, 20, 0, 138, 162, + 9, 0, 0, 0, 15, 0, 240, 78, + ]; + + assert_eq!( + MsgBaselineECEF::MSG_ID, + 0x20b, + "Incorrect message type, expected 0x20b, is {}", + MsgBaselineECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326826000, + "incorrect value for tow, expected 326826000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -1154232, + "incorrect value for x, expected -1154232, is {}", + msg.x + ); + assert_eq!( + msg.y, 1327551, + "incorrect value for y, expected 1327551, is {}", + msg.y + ); + assert_eq!( + msg.z, 631434, + "incorrect value for z, expected 631434, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineECEF"), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEF; + let payload: Vec = vec![ + 85, 11, 2, 211, 136, 20, 248, 251, 122, 19, 41, 99, 238, 255, 181, 65, 20, 0, 148, 161, + 9, 0, 0, 0, 15, 0, 4, 132, + ]; + + assert_eq!( + MsgBaselineECEF::MSG_ID, + 0x20b, + "Incorrect message type, expected 0x20b, is {}", + MsgBaselineECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326827000, + "incorrect value for tow, expected 326827000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -1154263, + "incorrect value for x, expected -1154263, is {}", + msg.x + ); + assert_eq!( + msg.y, 1327541, + "incorrect value for y, expected 1327541, is {}", + msg.y + ); + assert_eq!( + msg.z, 631188, + "incorrect value for z, expected 631188, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineECEF"), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEF; + let payload: Vec = vec![ + 85, 11, 2, 211, 136, 20, 224, 255, 122, 19, 188, 97, 238, 255, 81, 64, 20, 0, 65, 160, + 9, 0, 0, 0, 15, 0, 67, 94, + ]; + + assert_eq!( + MsgBaselineECEF::MSG_ID, + 0x20b, + "Incorrect message type, expected 0x20b, is {}", + MsgBaselineECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326828000, + "incorrect value for tow, expected 326828000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -1154628, + "incorrect value for x, expected -1154628, is {}", + msg.x + ); + assert_eq!( + msg.y, 1327185, + "incorrect value for y, expected 1327185, is {}", + msg.y + ); + assert_eq!( + msg.z, 630849, + "incorrect value for z, expected 630849, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineECEF"), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEF; + let payload: Vec = vec![ + 85, 11, 2, 211, 136, 20, 200, 3, 123, 19, 189, 96, 238, 255, 93, 63, 20, 0, 98, 159, 9, + 0, 0, 0, 15, 0, 106, 94, + ]; + + assert_eq!( + MsgBaselineECEF::MSG_ID, + 0x20b, + "Incorrect message type, expected 0x20b, is {}", + MsgBaselineECEF::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEF(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326829000, + "incorrect value for tow, expected 326829000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -1154883, + "incorrect value for x, expected -1154883, is {}", + msg.x + ); + assert_eq!( + msg.y, 1326941, + "incorrect value for y, expected 1326941, is {}", + msg.y + ); + assert_eq!( + msg.z, 630626, + "incorrect value for z, expected 630626, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineECEF"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_43.rs b/rust/sbp/tests/auto_check_sbp_navigation_43.rs new file mode 100644 index 0000000000..499ddc3239 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_43.rs @@ -0,0 +1,3159 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_navigation.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_43() { + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 195, 4, 11, 46, 7, 212, 157, 67, 24, 111, 147, 252, 255, 0, 215, 190, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, -224401, + "incorrect value for ns_residual, expected -224401, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 407084500, + "incorrect value for tow, expected 407084500, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1838, + "incorrect value for wn, expected 1838, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 195, 4, 11, 46, 7, 56, 158, 67, 24, 109, 103, 3, 0, 0, 134, 89, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 223085, + "incorrect value for ns_residual, expected 223085, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 407084600, + "incorrect value for tow, expected 407084600, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1838, + "incorrect value for wn, expected 1838, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 195, 4, 11, 46, 7, 156, 158, 67, 24, 233, 152, 252, 255, 0, 206, 241, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, -222999, + "incorrect value for ns_residual, expected -222999, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 407084700, + "incorrect value for tow, expected 407084700, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1838, + "incorrect value for wn, expected 1838, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 195, 4, 11, 46, 7, 0, 159, 67, 24, 240, 154, 3, 0, 0, 147, 98, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, 236272, + "incorrect value for ns_residual, expected 236272, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 407084800, + "incorrect value for tow, expected 407084800, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1838, + "incorrect value for wn, expected 1838, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 195, 4, 11, 46, 7, 100, 159, 67, 24, 144, 101, 252, 255, 0, 186, 152, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, -236144, + "incorrect value for ns_residual, expected -236144, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 407084900, + "incorrect value for tow, expected 407084900, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1838, + "incorrect value for wn, expected 1838, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgGPSTimeDepA; + let payload: Vec = vec![ + 85, 0, 1, 195, 4, 11, 46, 7, 46, 162, 68, 24, 205, 230, 250, 255, 0, 11, 225, + ]; + + assert_eq!( + MsgGPSTimeDepA::MSG_ID, + 0x100, + "Incorrect message type, expected 0x100, is {}", + MsgGPSTimeDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.ns_residual, -334131, + "incorrect value for ns_residual, expected -334131, is {}", + msg.ns_residual + ); + assert_eq!( + msg.tow, 407151150, + "incorrect value for tow, expected 407151150, is {}", + msg.tow + ); + assert_eq!( + msg.wn, 1838, + "incorrect value for wn, expected 1838, is {}", + msg.wn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgGPSTimeDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 195, 4, 32, 212, 157, 67, 24, 153, 222, 105, 1, 252, 161, 68, 193, 254, 247, + 52, 112, 74, 67, 80, 193, 164, 207, 47, 146, 44, 163, 77, 65, 0, 0, 8, 0, 145, 4, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084500, + "incorrect value for tow, expected 407084500, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70437601104338141e+06), + "incorrect value for x, expected -2.70437601104338141e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.26320975323295407e+06), + "incorrect value for y, expected -4.26320975323295407e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.88463314208407886e+06), + "incorrect value for z, expected 3.88463314208407886e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 195, 4, 32, 56, 158, 67, 24, 215, 184, 223, 246, 251, 161, 68, 193, 36, 126, + 17, 39, 74, 67, 80, 193, 19, 179, 70, 80, 44, 163, 77, 65, 0, 0, 8, 0, 245, 66, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084600, + "incorrect value for tow, expected 407084600, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70437592870245455e+06), + "incorrect value for x, expected -2.70437592870245455e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.26320861044267192e+06), + "incorrect value for y, expected -4.26320861044267192e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.88463262715757778e+06), + "incorrect value for z, expected 3.88463262715757778e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 195, 4, 32, 156, 158, 67, 24, 73, 74, 214, 148, 251, 161, 68, 193, 213, 151, + 184, 215, 73, 67, 80, 193, 110, 99, 38, 164, 43, 163, 77, 65, 0, 0, 8, 0, 5, 223, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084700, + "incorrect value for tow, expected 407084700, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70437516278961720e+06), + "incorrect value for x, expected -2.70437516278961720e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.26320737064166833e+06), + "incorrect value for y, expected -4.26320737064166833e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.88463128242152091e+06), + "incorrect value for z, expected 3.88463128242152091e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 195, 4, 32, 0, 159, 67, 24, 177, 111, 112, 45, 252, 161, 68, 193, 213, 168, + 198, 253, 73, 67, 80, 193, 245, 12, 228, 12, 44, 163, 77, 65, 0, 0, 8, 0, 143, 212, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084800, + "incorrect value for tow, expected 407084800, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70437635499378340e+06), + "incorrect value for x, expected -2.70437635499378340e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.26320796525021363e+06), + "incorrect value for y, expected -4.26320796525021363e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.88463210070955241e+06), + "incorrect value for z, expected 3.88463210070955241e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 195, 4, 32, 100, 159, 67, 24, 67, 231, 72, 165, 251, 161, 68, 193, 150, 210, + 36, 212, 73, 67, 80, 193, 234, 33, 25, 189, 43, 163, 77, 65, 0, 0, 8, 0, 70, 221, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084900, + "incorrect value for tow, expected 407084900, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70437529128733417e+06), + "incorrect value for x, expected -2.70437529128733417e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.26320731474747322e+06), + "incorrect value for y, expected -4.26320731474747322e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.88463147732948232e+06), + "incorrect value for z, expected 3.88463147732948232e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosECEFDepA; + let payload: Vec = vec![ + 85, 0, 2, 195, 4, 32, 46, 162, 68, 24, 224, 72, 131, 215, 251, 161, 68, 193, 180, 123, + 222, 94, 74, 67, 80, 193, 191, 3, 131, 193, 45, 163, 77, 65, 0, 0, 5, 0, 17, 221, + ]; + + assert_eq!( + MsgPosECEFDepA::MSG_ID, + 0x200, + "Incorrect message type, expected 0x200, is {}", + MsgPosECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 5, + "incorrect value for n_sats, expected 5, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407151150, + "incorrect value for tow, expected 407151150, is {}", + msg.tow + ); + assert!( + msg.x.almost_eq(-2.70437568369399011e+06), + "incorrect value for x, expected -2.70437568369399011e+06, is {:e}", + msg.x + ); + assert!( + msg.y.almost_eq(-4.26320948232929781e+06), + "incorrect value for y, expected -4.26320948232929781e+06, is {:e}", + msg.y + ); + assert!( + msg.z.almost_eq(3.88463551181074930e+06), + "incorrect value for z, expected 3.88463551181074930e+06, is {:e}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 195, 4, 20, 156, 21, 69, 24, 169, 231, 255, 255, 102, 208, 255, 255, 251, 28, + 0, 0, 0, 0, 6, 0, 146, 168, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407180700, + "incorrect value for tow, expected 407180700, is {}", + msg.tow + ); + assert_eq!( + msg.x, -6231, + "incorrect value for x, expected -6231, is {}", + msg.x + ); + assert_eq!( + msg.y, -12186, + "incorrect value for y, expected -12186, is {}", + msg.y + ); + assert_eq!( + msg.z, 7419, + "incorrect value for z, expected 7419, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 195, 4, 20, 0, 22, 69, 24, 169, 231, 255, 255, 103, 208, 255, 255, 252, 28, + 0, 0, 0, 0, 6, 0, 34, 116, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407180800, + "incorrect value for tow, expected 407180800, is {}", + msg.tow + ); + assert_eq!( + msg.x, -6231, + "incorrect value for x, expected -6231, is {}", + msg.x + ); + assert_eq!( + msg.y, -12185, + "incorrect value for y, expected -12185, is {}", + msg.y + ); + assert_eq!( + msg.z, 7420, + "incorrect value for z, expected 7420, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 195, 4, 20, 100, 22, 69, 24, 30, 224, 255, 255, 192, 183, 255, 255, 239, 53, + 0, 0, 0, 0, 6, 0, 225, 15, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407180900, + "incorrect value for tow, expected 407180900, is {}", + msg.tow + ); + assert_eq!( + msg.x, -8162, + "incorrect value for x, expected -8162, is {}", + msg.x + ); + assert_eq!( + msg.y, -18496, + "incorrect value for y, expected -18496, is {}", + msg.y + ); + assert_eq!( + msg.z, 13807, + "incorrect value for z, expected 13807, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 195, 4, 20, 200, 22, 69, 24, 28, 224, 255, 255, 191, 183, 255, 255, 242, 53, + 0, 0, 0, 0, 6, 0, 35, 100, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407181000, + "incorrect value for tow, expected 407181000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -8164, + "incorrect value for x, expected -8164, is {}", + msg.x + ); + assert_eq!( + msg.y, -18497, + "incorrect value for y, expected -18497, is {}", + msg.y + ); + assert_eq!( + msg.z, 13810, + "incorrect value for z, expected 13810, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 195, 4, 20, 44, 23, 69, 24, 24, 227, 255, 255, 25, 195, 255, 255, 153, 59, 0, + 0, 0, 0, 6, 0, 66, 66, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407181100, + "incorrect value for tow, expected 407181100, is {}", + msg.tow + ); + assert_eq!( + msg.x, -7400, + "incorrect value for x, expected -7400, is {}", + msg.x + ); + assert_eq!( + msg.y, -15591, + "incorrect value for y, expected -15591, is {}", + msg.y + ); + assert_eq!( + msg.z, 15257, + "incorrect value for z, expected 15257, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 195, 4, 20, 144, 23, 69, 24, 23, 227, 255, 255, 25, 195, 255, 255, 153, 59, + 0, 0, 0, 0, 6, 0, 35, 135, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407181200, + "incorrect value for tow, expected 407181200, is {}", + msg.tow + ); + assert_eq!( + msg.x, -7401, + "incorrect value for x, expected -7401, is {}", + msg.x + ); + assert_eq!( + msg.y, -15591, + "incorrect value for y, expected -15591, is {}", + msg.y + ); + assert_eq!( + msg.z, 15257, + "incorrect value for z, expected 15257, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 195, 4, 22, 156, 21, 69, 24, 130, 246, 255, 255, 241, 4, 0, 0, 35, 196, 255, + 255, 0, 0, 0, 0, 6, 0, 250, 21, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -15325, + "incorrect value for d, expected -15325, is {}", + msg.d + ); + assert_eq!( + msg.e, 1265, + "incorrect value for e, expected 1265, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -2430, + "incorrect value for n, expected -2430, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407180700, + "incorrect value for tow, expected 407180700, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 195, 4, 22, 0, 22, 69, 24, 130, 246, 255, 255, 241, 4, 0, 0, 35, 196, 255, + 255, 0, 0, 0, 0, 6, 0, 240, 133, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -15325, + "incorrect value for d, expected -15325, is {}", + msg.d + ); + assert_eq!( + msg.e, 1265, + "incorrect value for e, expected 1265, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -2430, + "incorrect value for n, expected -2430, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407180800, + "incorrect value for tow, expected 407180800, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 195, 4, 22, 100, 22, 69, 24, 32, 251, 255, 255, 199, 11, 0, 0, 57, 161, 255, + 255, 0, 0, 0, 0, 6, 0, 12, 181, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -24263, + "incorrect value for d, expected -24263, is {}", + msg.d + ); + assert_eq!( + msg.e, 3015, + "incorrect value for e, expected 3015, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -1248, + "incorrect value for n, expected -1248, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407180900, + "incorrect value for tow, expected 407180900, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 195, 4, 22, 200, 22, 69, 24, 33, 251, 255, 255, 199, 11, 0, 0, 54, 161, 255, + 255, 0, 0, 0, 0, 6, 0, 86, 58, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -24266, + "incorrect value for d, expected -24266, is {}", + msg.d + ); + assert_eq!( + msg.e, 3015, + "incorrect value for e, expected 3015, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -1247, + "incorrect value for n, expected -1247, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407181000, + "incorrect value for tow, expected 407181000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 195, 4, 22, 44, 23, 69, 24, 110, 6, 0, 0, 55, 8, 0, 0, 160, 166, 255, 255, 0, + 0, 0, 0, 6, 0, 51, 249, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -22880, + "incorrect value for d, expected -22880, is {}", + msg.d + ); + assert_eq!( + msg.e, 2103, + "incorrect value for e, expected 2103, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, 1646, + "incorrect value for n, expected 1646, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407181100, + "incorrect value for tow, expected 407181100, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 195, 4, 22, 144, 23, 69, 24, 110, 6, 0, 0, 54, 8, 0, 0, 160, 166, 255, 255, + 0, 0, 0, 0, 6, 0, 206, 22, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -22880, + "incorrect value for d, expected -22880, is {}", + msg.d + ); + assert_eq!( + msg.e, 2102, + "incorrect value for e, expected 2102, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, 1646, + "incorrect value for n, expected 1646, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 6, + "incorrect value for n_sats, expected 6, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407181200, + "incorrect value for tow, expected 407181200, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 195, 4, 20, 212, 157, 67, 24, 24, 0, 0, 0, 245, 255, 255, 255, 219, 255, 255, + 255, 0, 0, 8, 0, 68, 255, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084500, + "incorrect value for tow, expected 407084500, is {}", + msg.tow + ); + assert_eq!( + msg.x, 24, + "incorrect value for x, expected 24, is {}", + msg.x + ); + assert_eq!( + msg.y, -11, + "incorrect value for y, expected -11, is {}", + msg.y + ); + assert_eq!( + msg.z, -37, + "incorrect value for z, expected -37, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 195, 4, 20, 56, 158, 67, 24, 4, 0, 0, 0, 234, 255, 255, 255, 18, 0, 0, 0, 0, + 0, 8, 0, 214, 136, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084600, + "incorrect value for tow, expected 407084600, is {}", + msg.tow + ); + assert_eq!(msg.x, 4, "incorrect value for x, expected 4, is {}", msg.x); + assert_eq!( + msg.y, -22, + "incorrect value for y, expected -22, is {}", + msg.y + ); + assert_eq!( + msg.z, 18, + "incorrect value for z, expected 18, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 195, 4, 20, 156, 158, 67, 24, 230, 255, 255, 255, 4, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 8, 0, 122, 159, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084700, + "incorrect value for tow, expected 407084700, is {}", + msg.tow + ); + assert_eq!( + msg.x, -26, + "incorrect value for x, expected -26, is {}", + msg.x + ); + assert_eq!(msg.y, 4, "incorrect value for y, expected 4, is {}", msg.y); + assert_eq!(msg.z, 1, "incorrect value for z, expected 1, is {}", msg.z); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 195, 4, 20, 0, 159, 67, 24, 247, 255, 255, 255, 237, 255, 255, 255, 28, 0, 0, + 0, 0, 0, 8, 0, 232, 146, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084800, + "incorrect value for tow, expected 407084800, is {}", + msg.tow + ); + assert_eq!( + msg.x, -9, + "incorrect value for x, expected -9, is {}", + msg.x + ); + assert_eq!( + msg.y, -19, + "incorrect value for y, expected -19, is {}", + msg.y + ); + assert_eq!( + msg.z, 28, + "incorrect value for z, expected 28, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 195, 4, 20, 100, 159, 67, 24, 255, 255, 255, 255, 2, 0, 0, 0, 245, 255, 255, + 255, 0, 0, 8, 0, 171, 238, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084900, + "incorrect value for tow, expected 407084900, is {}", + msg.tow + ); + assert_eq!( + msg.x, -1, + "incorrect value for x, expected -1, is {}", + msg.x + ); + assert_eq!(msg.y, 2, "incorrect value for y, expected 2, is {}", msg.y); + assert_eq!( + msg.z, -11, + "incorrect value for z, expected -11, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelECEFDepA; + let payload: Vec = vec![ + 85, 4, 2, 195, 4, 20, 46, 162, 68, 24, 207, 255, 255, 255, 185, 255, 255, 255, 65, 0, + 0, 0, 0, 0, 5, 0, 82, 154, + ]; + + assert_eq!( + MsgVelECEFDepA::MSG_ID, + 0x204, + "Incorrect message type, expected 0x204, is {}", + MsgVelECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 5, + "incorrect value for n_sats, expected 5, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407151150, + "incorrect value for tow, expected 407151150, is {}", + msg.tow + ); + assert_eq!( + msg.x, -49, + "incorrect value for x, expected -49, is {}", + msg.x + ); + assert_eq!( + msg.y, -71, + "incorrect value for y, expected -71, is {}", + msg.y + ); + assert_eq!( + msg.z, 65, + "incorrect value for z, expected 65, is {}", + msg.z + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelECEFDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 195, 4, 22, 212, 157, 67, 24, 229, 255, 255, 255, 26, 0, 0, 0, 25, 0, 0, 0, + 0, 0, 0, 0, 8, 0, 132, 25, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, 25, + "incorrect value for d, expected 25, is {}", + msg.d + ); + assert_eq!( + msg.e, 26, + "incorrect value for e, expected 26, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -27, + "incorrect value for n, expected -27, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084500, + "incorrect value for tow, expected 407084500, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 195, 4, 22, 56, 158, 67, 24, 4, 0, 0, 0, 15, 0, 0, 0, 232, 255, 255, 255, 0, + 0, 0, 0, 8, 0, 42, 14, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -24, + "incorrect value for d, expected -24, is {}", + msg.d + ); + assert_eq!( + msg.e, 15, + "incorrect value for e, expected 15, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!(msg.n, 4, "incorrect value for n, expected 4, is {}", msg.n); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084600, + "incorrect value for tow, expected 407084600, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 195, 4, 22, 156, 158, 67, 24, 251, 255, 255, 255, 232, 255, 255, 255, 247, + 255, 255, 255, 0, 0, 0, 0, 8, 0, 218, 148, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -9, + "incorrect value for d, expected -9, is {}", + msg.d + ); + assert_eq!( + msg.e, -24, + "incorrect value for e, expected -24, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -5, + "incorrect value for n, expected -5, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084700, + "incorrect value for tow, expected 407084700, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 195, 4, 22, 0, 159, 67, 24, 10, 0, 0, 0, 2, 0, 0, 0, 222, 255, 255, 255, 0, + 0, 0, 0, 8, 0, 148, 16, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -34, + "incorrect value for d, expected -34, is {}", + msg.d + ); + assert_eq!(msg.e, 2, "incorrect value for e, expected 2, is {}", msg.e); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, 10, + "incorrect value for n, expected 10, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084800, + "incorrect value for tow, expected 407084800, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 195, 4, 22, 100, 159, 67, 24, 248, 255, 255, 255, 254, 255, 255, 255, 7, 0, + 0, 0, 0, 0, 0, 0, 8, 0, 255, 236, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!(msg.d, 7, "incorrect value for d, expected 7, is {}", msg.d); + assert_eq!( + msg.e, -2, + "incorrect value for e, expected -2, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -8, + "incorrect value for n, expected -8, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084900, + "incorrect value for tow, expected 407084900, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgVelNEDDepA; + let payload: Vec = vec![ + 85, 5, 2, 195, 4, 22, 46, 162, 68, 24, 255, 255, 255, 255, 253, 255, 255, 255, 148, + 255, 255, 255, 0, 0, 0, 0, 5, 0, 166, 189, + ]; + + assert_eq!( + MsgVelNEDDepA::MSG_ID, + 0x205, + "Incorrect message type, expected 0x205, is {}", + MsgVelNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgVelNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.d, -108, + "incorrect value for d, expected -108, is {}", + msg.d + ); + assert_eq!( + msg.e, -3, + "incorrect value for e, expected -3, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -1, + "incorrect value for n, expected -1, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 5, + "incorrect value for n_sats, expected 5, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407151150, + "incorrect value for tow, expected 407151150, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgVelNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 195, 4, 14, 212, 157, 67, 24, 247, 0, 215, 0, 123, 0, 17, 1, 44, 0, 206, 21, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 247, + "incorrect value for gdop, expected 247, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 273, + "incorrect value for hdop, expected 273, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 215, + "incorrect value for pdop, expected 215, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 123, + "incorrect value for tdop, expected 123, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 407084500, + "incorrect value for tow, expected 407084500, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 44, + "incorrect value for vdop, expected 44, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 195, 4, 14, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 146, 12, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 65535, + "incorrect value for gdop, expected 65535, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 0, + "incorrect value for hdop, expected 0, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 65535, + "incorrect value for pdop, expected 65535, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 0, + "incorrect value for tdop, expected 0, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 0, + "incorrect value for tow, expected 0, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 0, + "incorrect value for vdop, expected 0, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 195, 4, 14, 128, 165, 68, 24, 92, 1, 56, 1, 155, 0, 125, 2, 113, 0, 129, 93, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 348, + "incorrect value for gdop, expected 348, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 637, + "incorrect value for hdop, expected 637, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 312, + "incorrect value for pdop, expected 312, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 155, + "incorrect value for tdop, expected 155, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 407152000, + "incorrect value for tow, expected 407152000, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 113, + "incorrect value for vdop, expected 113, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 195, 4, 14, 104, 169, 68, 24, 92, 1, 55, 1, 155, 0, 125, 2, 113, 0, 209, 128, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 348, + "incorrect value for gdop, expected 348, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 637, + "incorrect value for hdop, expected 637, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 311, + "incorrect value for pdop, expected 311, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 155, + "incorrect value for tdop, expected 155, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 407153000, + "incorrect value for tow, expected 407153000, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 113, + "incorrect value for vdop, expected 113, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 195, 4, 14, 80, 173, 68, 24, 92, 1, 55, 1, 155, 0, 125, 2, 112, 0, 30, 6, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 348, + "incorrect value for gdop, expected 348, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 637, + "incorrect value for hdop, expected 637, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 311, + "incorrect value for pdop, expected 311, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 155, + "incorrect value for tdop, expected 155, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 407154000, + "incorrect value for tow, expected 407154000, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 112, + "incorrect value for vdop, expected 112, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 195, 4, 14, 56, 177, 68, 24, 92, 1, 55, 1, 155, 0, 125, 2, 112, 0, 70, 67, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 348, + "incorrect value for gdop, expected 348, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 637, + "incorrect value for hdop, expected 637, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 311, + "incorrect value for pdop, expected 311, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 155, + "incorrect value for tdop, expected 155, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 407155000, + "incorrect value for tow, expected 407155000, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 112, + "incorrect value for vdop, expected 112, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 195, 4, 34, 212, 157, 67, 24, 8, 23, 228, 8, 151, 225, 66, 64, 156, 174, 42, + 194, 230, 152, 94, 192, 153, 23, 72, 47, 196, 40, 16, 64, 0, 0, 0, 0, 8, 0, 237, 169, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(4.03981088521495568e+00), + "incorrect value for height, expected 4.03981088521495568e+00, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.77624217141838585e+01), + "incorrect value for lat, expected 3.77624217141838585e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22389084378892619e+02), + "incorrect value for lon, expected -1.22389084378892619e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084500, + "incorrect value for tow, expected 407084500, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 195, 4, 34, 56, 158, 67, 24, 220, 109, 212, 24, 151, 225, 66, 64, 159, 231, + 254, 219, 230, 152, 94, 192, 128, 151, 67, 19, 233, 105, 7, 64, 0, 0, 0, 0, 8, 0, 152, + 11, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(2.92671408700965685e+00), + "incorrect value for height, expected 2.92671408700965685e+00, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.77624236142398502e+01), + "incorrect value for lat, expected 3.77624236142398502e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22389090537004890e+02), + "incorrect value for lon, expected -1.22389090537004890e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084600, + "incorrect value for tow, expected 407084600, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 195, 4, 34, 156, 158, 67, 24, 13, 91, 237, 11, 151, 225, 66, 64, 75, 113, + 210, 220, 230, 152, 94, 192, 37, 6, 145, 188, 89, 112, 238, 63, 0, 0, 0, 0, 8, 0, 221, + 155, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(9.51214664739556626e-01), + "incorrect value for height, expected 9.51214664739556626e-01, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.77624220761264056e+01), + "incorrect value for lat, expected 3.77624220761264056e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22389090734014800e+02), + "incorrect value for lon, expected -1.22389090734014800e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084700, + "incorrect value for tow, expected 407084700, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 195, 4, 34, 0, 159, 67, 24, 51, 183, 5, 8, 151, 225, 66, 64, 13, 226, 148, + 253, 230, 152, 94, 192, 187, 27, 11, 32, 69, 213, 2, 64, 0, 0, 0, 0, 8, 0, 82, 94, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(2.35413575204753789e+00), + "incorrect value for height, expected 2.35413575204753789e+00, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.77624216106327353e+01), + "incorrect value for lat, expected 3.77624216106327353e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22389098544496122e+02), + "incorrect value for lon, expected -1.22389098544496122e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084800, + "incorrect value for tow, expected 407084800, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 195, 4, 34, 100, 159, 67, 24, 22, 77, 146, 22, 151, 225, 66, 64, 64, 134, + 105, 227, 230, 152, 94, 192, 37, 99, 114, 72, 31, 103, 241, 63, 0, 0, 0, 0, 8, 0, 70, + 60, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(1.08767631816426413e+00), + "incorrect value for height, expected 1.08767631816426413e+00, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.77624233450280116e+01), + "incorrect value for lat, expected 3.77624233450280116e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22389092305232225e+02), + "incorrect value for lon, expected -1.22389092305232225e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 8, + "incorrect value for n_sats, expected 8, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407084900, + "incorrect value for tow, expected 407084900, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } + { + use sbp::messages::navigation::MsgPosLLHDepA; + let payload: Vec = vec![ + 85, 1, 2, 195, 4, 34, 46, 162, 68, 24, 124, 245, 46, 169, 151, 225, 66, 64, 135, 149, + 234, 187, 230, 152, 94, 192, 194, 201, 115, 145, 166, 175, 20, 64, 0, 0, 0, 0, 5, 0, + 212, 121, + ]; + + assert_eq!( + MsgPosLLHDepA::MSG_ID, + 0x201, + "Incorrect message type, expected 0x201, is {}", + MsgPosLLHDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgPosLLHDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert!( + msg.height.almost_eq(5.17153384465422228e+00), + "incorrect value for height, expected 5.17153384465422228e+00, is {:e}", + msg.height + ); + assert!( + msg.lat.almost_eq(3.77624408225337618e+01), + "incorrect value for lat, expected 3.77624408225337618e+01, is {:e}", + msg.lat + ); + assert!( + msg.lon.almost_eq(-1.22389082888685252e+02), + "incorrect value for lon, expected -1.22389082888685252e+02, is {:e}", + msg.lon + ); + assert_eq!( + msg.n_sats, 5, + "incorrect value for n_sats, expected 5, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 407151150, + "incorrect value for tow, expected 407151150, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgPosLLHDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_5.rs b/rust/sbp/tests/auto_check_sbp_navigation_5.rs new file mode 100644 index 0000000000..838ba61d07 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_5.rs @@ -0,0 +1,384 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgBaselineECEFDepA.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_5() { + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 246, 215, 20, 20, 46, 39, 0, 21, 48, 255, 255, 52, 117, 255, 255, 216, 211, + 254, 255, 0, 0, 9, 1, 50, 137, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567700, + "incorrect value for tow, expected 2567700, is {}", + msg.tow + ); + assert_eq!( + msg.x, -53227, + "incorrect value for x, expected -53227, is {}", + msg.x + ); + assert_eq!( + msg.y, -35532, + "incorrect value for y, expected -35532, is {}", + msg.y + ); + assert_eq!( + msg.z, -76840, + "incorrect value for z, expected -76840, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 246, 215, 20, 120, 46, 39, 0, 58, 49, 255, 255, 49, 116, 255, 255, 134, 211, + 254, 255, 0, 0, 9, 1, 227, 155, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert_eq!( + msg.x, -52934, + "incorrect value for x, expected -52934, is {}", + msg.x + ); + assert_eq!( + msg.y, -35791, + "incorrect value for y, expected -35791, is {}", + msg.y + ); + assert_eq!( + msg.z, -76922, + "incorrect value for z, expected -76922, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 246, 215, 20, 220, 46, 39, 0, 97, 50, 255, 255, 47, 115, 255, 255, 52, 211, + 254, 255, 0, 0, 9, 1, 61, 126, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567900, + "incorrect value for tow, expected 2567900, is {}", + msg.tow + ); + assert_eq!( + msg.x, -52639, + "incorrect value for x, expected -52639, is {}", + msg.x + ); + assert_eq!( + msg.y, -36049, + "incorrect value for y, expected -36049, is {}", + msg.y + ); + assert_eq!( + msg.z, -77004, + "incorrect value for z, expected -77004, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 246, 215, 20, 64, 47, 39, 0, 136, 51, 255, 255, 45, 114, 255, 255, 228, 210, + 254, 255, 0, 0, 9, 1, 200, 79, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2568000, + "incorrect value for tow, expected 2568000, is {}", + msg.tow + ); + assert_eq!( + msg.x, -52344, + "incorrect value for x, expected -52344, is {}", + msg.x + ); + assert_eq!( + msg.y, -36307, + "incorrect value for y, expected -36307, is {}", + msg.y + ); + assert_eq!( + msg.z, -77084, + "incorrect value for z, expected -77084, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } + { + use sbp::messages::navigation::MsgBaselineECEFDepA; + let payload: Vec = vec![ + 85, 2, 2, 246, 215, 20, 164, 47, 39, 0, 176, 52, 255, 255, 44, 113, 255, 255, 149, 210, + 254, 255, 0, 0, 9, 1, 104, 24, + ]; + + assert_eq!( + MsgBaselineECEFDepA::MSG_ID, + 0x202, + "Incorrect message type, expected 0x202, is {}", + MsgBaselineECEFDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.accuracy, 0, + "incorrect value for accuracy, expected 0, is {}", + msg.accuracy + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2568100, + "incorrect value for tow, expected 2568100, is {}", + msg.tow + ); + assert_eq!( + msg.x, -52048, + "incorrect value for x, expected -52048, is {}", + msg.x + ); + assert_eq!( + msg.y, -36564, + "incorrect value for y, expected -36564, is {}", + msg.y + ); + assert_eq!( + msg.z, -77163, + "incorrect value for z, expected -77163, is {}", + msg.z + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgBaselineECEFDepA" + ), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_6.rs b/rust/sbp/tests/auto_check_sbp_navigation_6.rs new file mode 100644 index 0000000000..f24d96d733 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_6.rs @@ -0,0 +1,394 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgBaselineNED.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_6() { + { + use sbp::messages::navigation::MsgBaselineNED; + let payload: Vec = vec![ + 85, 12, 2, 211, 136, 22, 40, 244, 122, 19, 201, 115, 12, 0, 179, 88, 230, 255, 153, + 125, 0, 0, 0, 0, 0, 0, 14, 0, 226, 70, + ]; + + assert_eq!( + MsgBaselineNED::MSG_ID, + 0x20c, + "Incorrect message type, expected 0x20c, is {}", + MsgBaselineNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, 32153, + "incorrect value for d, expected 32153, is {}", + msg.d + ); + assert_eq!( + msg.e, -1681229, + "incorrect value for e, expected -1681229, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, 816073, + "incorrect value for n, expected 816073, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 14, + "incorrect value for n_sats, expected 14, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326825000, + "incorrect value for tow, expected 326825000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNED"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNED; + let payload: Vec = vec![ + 85, 12, 2, 211, 136, 22, 16, 248, 122, 19, 98, 115, 12, 0, 194, 88, 230, 255, 110, 127, + 0, 0, 0, 0, 0, 0, 15, 0, 69, 93, + ]; + + assert_eq!( + MsgBaselineNED::MSG_ID, + 0x20c, + "Incorrect message type, expected 0x20c, is {}", + MsgBaselineNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, 32622, + "incorrect value for d, expected 32622, is {}", + msg.d + ); + assert_eq!( + msg.e, -1681214, + "incorrect value for e, expected -1681214, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, 815970, + "incorrect value for n, expected 815970, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326826000, + "incorrect value for tow, expected 326826000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNED"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNED; + let payload: Vec = vec![ + 85, 12, 2, 211, 136, 22, 248, 251, 122, 19, 143, 114, 12, 0, 173, 88, 230, 255, 238, + 127, 0, 0, 0, 0, 0, 0, 15, 0, 210, 169, + ]; + + assert_eq!( + MsgBaselineNED::MSG_ID, + 0x20c, + "Incorrect message type, expected 0x20c, is {}", + MsgBaselineNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, 32750, + "incorrect value for d, expected 32750, is {}", + msg.d + ); + assert_eq!( + msg.e, -1681235, + "incorrect value for e, expected -1681235, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, 815759, + "incorrect value for n, expected 815759, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326827000, + "incorrect value for tow, expected 326827000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNED"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNED; + let payload: Vec = vec![ + 85, 12, 2, 211, 136, 22, 224, 255, 122, 19, 86, 112, 12, 0, 51, 88, 230, 255, 47, 127, + 0, 0, 0, 0, 0, 0, 15, 0, 135, 107, + ]; + + assert_eq!( + MsgBaselineNED::MSG_ID, + 0x20c, + "Incorrect message type, expected 0x20c, is {}", + MsgBaselineNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, 32559, + "incorrect value for d, expected 32559, is {}", + msg.d + ); + assert_eq!( + msg.e, -1681357, + "incorrect value for e, expected -1681357, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, 815190, + "incorrect value for n, expected 815190, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326828000, + "incorrect value for tow, expected 326828000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNED"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNED; + let payload: Vec = vec![ + 85, 12, 2, 211, 136, 22, 200, 3, 123, 19, 214, 110, 12, 0, 220, 87, 230, 255, 165, 126, + 0, 0, 0, 0, 0, 0, 15, 0, 190, 80, + ]; + + assert_eq!( + MsgBaselineNED::MSG_ID, + 0x20c, + "Incorrect message type, expected 0x20c, is {}", + MsgBaselineNED::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNED(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x88d3, + "incorrect sender id, expected 0x88d3, is {}", + sender_id + ); + assert_eq!( + msg.d, 32421, + "incorrect value for d, expected 32421, is {}", + msg.d + ); + assert_eq!( + msg.e, -1681444, + "incorrect value for e, expected -1681444, is {}", + msg.e + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, 814806, + "incorrect value for n, expected 814806, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 15, + "incorrect value for n_sats, expected 15, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 326829000, + "incorrect value for tow, expected 326829000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNED"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_7.rs b/rust/sbp/tests/auto_check_sbp_navigation_7.rs new file mode 100644 index 0000000000..2df895c577 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_7.rs @@ -0,0 +1,374 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgBaselineNEDDepA.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_7() { + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 246, 215, 22, 20, 46, 39, 0, 243, 134, 254, 255, 234, 153, 255, 255, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 1, 93, 193, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, -26134, + "incorrect value for e, expected -26134, is {}", + msg.e + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -96525, + "incorrect value for n, expected -96525, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567700, + "incorrect value for tow, expected 2567700, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 246, 215, 22, 120, 46, 39, 0, 139, 134, 254, 255, 109, 155, 255, 255, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 1, 38, 39, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, -25747, + "incorrect value for e, expected -25747, is {}", + msg.e + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -96629, + "incorrect value for n, expected -96629, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567800, + "incorrect value for tow, expected 2567800, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 246, 215, 22, 220, 46, 39, 0, 37, 134, 254, 255, 240, 156, 255, 255, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 1, 58, 133, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, -25360, + "incorrect value for e, expected -25360, is {}", + msg.e + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -96731, + "incorrect value for n, expected -96731, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2567900, + "incorrect value for tow, expected 2567900, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 246, 215, 22, 64, 47, 39, 0, 193, 133, 254, 255, 115, 158, 255, 255, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 1, 56, 214, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, -24973, + "incorrect value for e, expected -24973, is {}", + msg.e + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -96831, + "incorrect value for n, expected -96831, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2568000, + "incorrect value for tow, expected 2568000, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } + { + use sbp::messages::navigation::MsgBaselineNEDDepA; + let payload: Vec = vec![ + 85, 3, 2, 246, 215, 22, 164, 47, 39, 0, 93, 133, 254, 255, 246, 159, 255, 255, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 1, 234, 244, + ]; + + assert_eq!( + MsgBaselineNEDDepA::MSG_ID, + 0x203, + "Incorrect message type, expected 0x203, is {}", + MsgBaselineNEDDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!(msg.d, 0, "incorrect value for d, expected 0, is {}", msg.d); + assert_eq!( + msg.e, -24586, + "incorrect value for e, expected -24586, is {}", + msg.e + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.h_accuracy, 0, + "incorrect value for h_accuracy, expected 0, is {}", + msg.h_accuracy + ); + assert_eq!( + msg.n, -96931, + "incorrect value for n, expected -96931, is {}", + msg.n + ); + assert_eq!( + msg.n_sats, 9, + "incorrect value for n_sats, expected 9, is {}", + msg.n_sats + ); + assert_eq!( + msg.tow, 2568100, + "incorrect value for tow, expected 2568100, is {}", + msg.tow + ); + assert_eq!( + msg.v_accuracy, 0, + "incorrect value for v_accuracy, expected 0, is {}", + msg.v_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgBaselineNEDDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_8.rs b/rust/sbp/tests/auto_check_sbp_navigation_8.rs new file mode 100644 index 0000000000..806fbfd3d6 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_8.rs @@ -0,0 +1,104 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgDops.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_8() { + { + use sbp::messages::navigation::MsgDops; + let payload: Vec = vec![ + 85, 8, 2, 66, 0, 15, 100, 0, 0, 0, 2, 0, 6, 0, 5, 0, 5, 0, 5, 0, 0, 244, 4, + ]; + + assert_eq!( + MsgDops::MSG_ID, + 0x208, + "Incorrect message type, expected 0x208, is {}", + MsgDops::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDops(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.gdop, 2, + "incorrect value for gdop, expected 2, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 5, + "incorrect value for hdop, expected 5, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 6, + "incorrect value for pdop, expected 6, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 5, + "incorrect value for tdop, expected 5, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 100, + "incorrect value for tow, expected 100, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 5, + "incorrect value for vdop, expected 5, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDops"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_navigation_9.rs b/rust/sbp/tests/auto_check_sbp_navigation_9.rs new file mode 100644 index 0000000000..fcf5271950 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_navigation_9.rs @@ -0,0 +1,219 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgDopsDepA.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_navigation_9() { + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 246, 215, 14, 8, 48, 39, 0, 180, 0, 190, 0, 170, 0, 160, 0, 150, 0, 121, 170, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 180, + "incorrect value for gdop, expected 180, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 160, + "incorrect value for hdop, expected 160, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 190, + "incorrect value for pdop, expected 190, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 170, + "incorrect value for tdop, expected 170, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 2568200, + "incorrect value for tow, expected 2568200, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 150, + "incorrect value for vdop, expected 150, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 246, 215, 14, 240, 51, 39, 0, 180, 0, 190, 0, 170, 0, 160, 0, 150, 0, 78, 169, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 180, + "incorrect value for gdop, expected 180, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 160, + "incorrect value for hdop, expected 160, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 190, + "incorrect value for pdop, expected 190, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 170, + "incorrect value for tdop, expected 170, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 2569200, + "incorrect value for tow, expected 2569200, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 150, + "incorrect value for vdop, expected 150, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } + { + use sbp::messages::navigation::MsgDopsDepA; + let payload: Vec = vec![ + 85, 6, 2, 246, 215, 14, 216, 55, 39, 0, 180, 0, 190, 0, 170, 0, 160, 0, 150, 0, 71, 218, + ]; + + assert_eq!( + MsgDopsDepA::MSG_ID, + 0x206, + "Incorrect message type, expected 0x206, is {}", + MsgDopsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDopsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.gdop, 180, + "incorrect value for gdop, expected 180, is {}", + msg.gdop + ); + assert_eq!( + msg.hdop, 160, + "incorrect value for hdop, expected 160, is {}", + msg.hdop + ); + assert_eq!( + msg.pdop, 190, + "incorrect value for pdop, expected 190, is {}", + msg.pdop + ); + assert_eq!( + msg.tdop, 170, + "incorrect value for tdop, expected 170, is {}", + msg.tdop + ); + assert_eq!( + msg.tow, 2570200, + "incorrect value for tow, expected 2570200, is {}", + msg.tow + ); + assert_eq!( + msg.vdop, 150, + "incorrect value for vdop, expected 150, is {}", + msg.vdop + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDopsDepA"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_observation_25.rs b/rust/sbp/tests/auto_check_sbp_observation_25.rs new file mode 100644 index 0000000000..cdbd48a9e4 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_observation_25.rs @@ -0,0 +1,1120 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgObsDepC.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_observation_25() { + { + use sbp::messages::observation::MsgObsDepC; + let payload: Vec = vec![ + 85, 73, 0, 70, 152, 87, 8, 95, 183, 24, 106, 7, 32, 126, 250, 73, 80, 113, 94, 247, + 255, 231, 163, 229, 229, 4, 0, 0, 0, 60, 220, 96, 70, 81, 147, 250, 255, 196, 208, 20, + 28, 6, 0, 0, 0, 248, 61, 62, 77, 28, 60, 242, 255, 110, 171, 180, 178, 7, 0, 0, 0, 237, + 84, 190, 77, 172, 37, 13, 0, 41, 170, 233, 164, 10, 0, 0, 0, 36, 85, 9, 75, 240, 188, + 21, 0, 19, 182, 196, 209, 12, 0, 0, 0, 190, 175, + ]; + + assert_eq!( + MsgObsDepC::MSG_ID, + 0x49, + "Incorrect message type, expected 0x49, is {}", + MsgObsDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x9846, + "incorrect sender id, expected 0x9846, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 32, + "incorrect value for header.n_obs, expected 32, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 414670600, + "incorrect value for header.t.tow, expected 414670600, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1898, + "incorrect value for header.t.wn, expected 1898, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 231, + "incorrect value for obs[0].L.f, expected 231, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, -565647, + "incorrect value for obs[0].L.i, expected -565647, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 1347025534, + "incorrect value for obs[0].P, expected 1347025534, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 163, + "incorrect value for obs[0].cn0, expected 163, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 58853, + "incorrect value for obs[0].lock, expected 58853, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 4, + "incorrect value for obs[0].sid.sat, expected 4, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 196, + "incorrect value for obs[1].L.f, expected 196, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, -355503, + "incorrect value for obs[1].L.i, expected -355503, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 1180752956, + "incorrect value for obs[1].P, expected 1180752956, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 208, + "incorrect value for obs[1].cn0, expected 208, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 7188, + "incorrect value for obs[1].lock, expected 7188, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 6, + "incorrect value for obs[1].sid.sat, expected 6, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 110, + "incorrect value for obs[2].L.f, expected 110, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, -902116, + "incorrect value for obs[2].L.i, expected -902116, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 1295924728, + "incorrect value for obs[2].P, expected 1295924728, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 171, + "incorrect value for obs[2].cn0, expected 171, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 45748, + "incorrect value for obs[2].lock, expected 45748, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 7, + "incorrect value for obs[2].sid.sat, expected 7, is {}", + msg.obs[2].sid.sat + ); + assert_eq!( + msg.obs[3].L.f, 41, + "incorrect value for obs[3].L.f, expected 41, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, 861612, + "incorrect value for obs[3].L.i, expected 861612, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 1304319213, + "incorrect value for obs[3].P, expected 1304319213, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 170, + "incorrect value for obs[3].cn0, expected 170, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 42217, + "incorrect value for obs[3].lock, expected 42217, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].sid.code, 0, + "incorrect value for obs[3].sid.code, expected 0, is {}", + msg.obs[3].sid.code + ); + assert_eq!( + msg.obs[3].sid.reserved, 0, + "incorrect value for obs[3].sid.reserved, expected 0, is {}", + msg.obs[3].sid.reserved + ); + assert_eq!( + msg.obs[3].sid.sat, 10, + "incorrect value for obs[3].sid.sat, expected 10, is {}", + msg.obs[3].sid.sat + ); + assert_eq!( + msg.obs[4].L.f, 19, + "incorrect value for obs[4].L.f, expected 19, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, 1424624, + "incorrect value for obs[4].L.i, expected 1424624, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 1258902820, + "incorrect value for obs[4].P, expected 1258902820, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 182, + "incorrect value for obs[4].cn0, expected 182, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 53700, + "incorrect value for obs[4].lock, expected 53700, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].sid.code, 0, + "incorrect value for obs[4].sid.code, expected 0, is {}", + msg.obs[4].sid.code + ); + assert_eq!( + msg.obs[4].sid.reserved, 0, + "incorrect value for obs[4].sid.reserved, expected 0, is {}", + msg.obs[4].sid.reserved + ); + assert_eq!( + msg.obs[4].sid.sat, 12, + "incorrect value for obs[4].sid.sat, expected 12, is {}", + msg.obs[4].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepC"), + }; + } + { + use sbp::messages::observation::MsgObsDepC; + let payload: Vec = vec![ + 85, 73, 0, 70, 152, 55, 8, 95, 183, 24, 106, 7, 33, 68, 166, 75, 77, 186, 230, 24, 0, + 101, 186, 162, 102, 16, 0, 0, 0, 87, 255, 155, 69, 74, 158, 5, 0, 26, 190, 206, 30, 27, + 0, 0, 0, 64, 89, 124, 68, 26, 22, 3, 0, 114, 217, 225, 73, 29, 0, 0, 0, 37, 179, + ]; + + assert_eq!( + MsgObsDepC::MSG_ID, + 0x49, + "Incorrect message type, expected 0x49, is {}", + MsgObsDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x9846, + "incorrect sender id, expected 0x9846, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 33, + "incorrect value for header.n_obs, expected 33, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 414670600, + "incorrect value for header.t.tow, expected 414670600, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1898, + "incorrect value for header.t.wn, expected 1898, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 101, + "incorrect value for obs[0].L.f, expected 101, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 1631930, + "incorrect value for obs[0].L.i, expected 1631930, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 1296803396, + "incorrect value for obs[0].P, expected 1296803396, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 186, + "incorrect value for obs[0].cn0, expected 186, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 26274, + "incorrect value for obs[0].lock, expected 26274, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 16, + "incorrect value for obs[0].sid.sat, expected 16, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 26, + "incorrect value for obs[1].L.f, expected 26, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 368202, + "incorrect value for obs[1].L.i, expected 368202, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 1167851351, + "incorrect value for obs[1].P, expected 1167851351, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 190, + "incorrect value for obs[1].cn0, expected 190, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 7886, + "incorrect value for obs[1].lock, expected 7886, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 27, + "incorrect value for obs[1].sid.sat, expected 27, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 114, + "incorrect value for obs[2].L.f, expected 114, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, 202266, + "incorrect value for obs[2].L.i, expected 202266, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 1149000000, + "incorrect value for obs[2].P, expected 1149000000, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 217, + "incorrect value for obs[2].cn0, expected 217, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 18913, + "incorrect value for obs[2].lock, expected 18913, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 29, + "incorrect value for obs[2].sid.sat, expected 29, is {}", + msg.obs[2].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepC"), + }; + } + { + use sbp::messages::observation::MsgObsDepC; + let payload: Vec = vec![ + 85, 73, 0, 0, 0, 87, 8, 95, 183, 24, 106, 7, 32, 217, 251, 73, 80, 9, 72, 248, 255, 30, + 168, 113, 81, 4, 0, 0, 0, 211, 220, 96, 70, 198, 107, 251, 255, 115, 195, 53, 144, 6, + 0, 0, 0, 77, 61, 62, 77, 40, 161, 243, 255, 130, 176, 93, 142, 7, 0, 0, 0, 1, 86, 190, + 77, 88, 77, 12, 0, 116, 199, 229, 213, 10, 0, 0, 0, 93, 85, 9, 75, 64, 139, 20, 0, 120, + 177, 196, 194, 12, 0, 0, 0, 141, 161, + ]; + + assert_eq!( + MsgObsDepC::MSG_ID, + 0x49, + "Incorrect message type, expected 0x49, is {}", + MsgObsDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x0, + "incorrect sender id, expected 0x0, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 32, + "incorrect value for header.n_obs, expected 32, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 414670600, + "incorrect value for header.t.tow, expected 414670600, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1898, + "incorrect value for header.t.wn, expected 1898, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 30, + "incorrect value for obs[0].L.f, expected 30, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, -505847, + "incorrect value for obs[0].L.i, expected -505847, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 1347025881, + "incorrect value for obs[0].P, expected 1347025881, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 168, + "incorrect value for obs[0].cn0, expected 168, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 20849, + "incorrect value for obs[0].lock, expected 20849, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 4, + "incorrect value for obs[0].sid.sat, expected 4, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 115, + "incorrect value for obs[1].L.f, expected 115, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, -300090, + "incorrect value for obs[1].L.i, expected -300090, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 1180753107, + "incorrect value for obs[1].P, expected 1180753107, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 195, + "incorrect value for obs[1].cn0, expected 195, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 36917, + "incorrect value for obs[1].lock, expected 36917, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 6, + "incorrect value for obs[1].sid.sat, expected 6, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 130, + "incorrect value for obs[2].L.f, expected 130, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, -810712, + "incorrect value for obs[2].L.i, expected -810712, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 1295924557, + "incorrect value for obs[2].P, expected 1295924557, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 176, + "incorrect value for obs[2].cn0, expected 176, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 36445, + "incorrect value for obs[2].lock, expected 36445, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 7, + "incorrect value for obs[2].sid.sat, expected 7, is {}", + msg.obs[2].sid.sat + ); + assert_eq!( + msg.obs[3].L.f, 116, + "incorrect value for obs[3].L.f, expected 116, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, 806232, + "incorrect value for obs[3].L.i, expected 806232, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 1304319489, + "incorrect value for obs[3].P, expected 1304319489, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 199, + "incorrect value for obs[3].cn0, expected 199, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 54757, + "incorrect value for obs[3].lock, expected 54757, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].sid.code, 0, + "incorrect value for obs[3].sid.code, expected 0, is {}", + msg.obs[3].sid.code + ); + assert_eq!( + msg.obs[3].sid.reserved, 0, + "incorrect value for obs[3].sid.reserved, expected 0, is {}", + msg.obs[3].sid.reserved + ); + assert_eq!( + msg.obs[3].sid.sat, 10, + "incorrect value for obs[3].sid.sat, expected 10, is {}", + msg.obs[3].sid.sat + ); + assert_eq!( + msg.obs[4].L.f, 120, + "incorrect value for obs[4].L.f, expected 120, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, 1346368, + "incorrect value for obs[4].L.i, expected 1346368, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 1258902877, + "incorrect value for obs[4].P, expected 1258902877, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 177, + "incorrect value for obs[4].cn0, expected 177, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 49860, + "incorrect value for obs[4].lock, expected 49860, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].sid.code, 0, + "incorrect value for obs[4].sid.code, expected 0, is {}", + msg.obs[4].sid.code + ); + assert_eq!( + msg.obs[4].sid.reserved, 0, + "incorrect value for obs[4].sid.reserved, expected 0, is {}", + msg.obs[4].sid.reserved + ); + assert_eq!( + msg.obs[4].sid.sat, 12, + "incorrect value for obs[4].sid.sat, expected 12, is {}", + msg.obs[4].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepC"), + }; + } + { + use sbp::messages::observation::MsgObsDepC; + let payload: Vec = vec![ + 85, 73, 0, 0, 0, 55, 8, 95, 183, 24, 106, 7, 33, 70, 167, 75, 77, 140, 136, 23, 0, 90, + 187, 158, 129, 16, 0, 0, 0, 232, 255, 155, 69, 45, 175, 5, 0, 17, 208, 175, 56, 27, 0, + 0, 0, 64, 89, 124, 68, 45, 96, 3, 0, 75, 185, 73, 206, 29, 0, 0, 0, 220, 158, + ]; + + assert_eq!( + MsgObsDepC::MSG_ID, + 0x49, + "Incorrect message type, expected 0x49, is {}", + MsgObsDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x0, + "incorrect sender id, expected 0x0, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 33, + "incorrect value for header.n_obs, expected 33, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 414670600, + "incorrect value for header.t.tow, expected 414670600, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1898, + "incorrect value for header.t.wn, expected 1898, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 90, + "incorrect value for obs[0].L.f, expected 90, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 1542284, + "incorrect value for obs[0].L.i, expected 1542284, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 1296803654, + "incorrect value for obs[0].P, expected 1296803654, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 187, + "incorrect value for obs[0].cn0, expected 187, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 33182, + "incorrect value for obs[0].lock, expected 33182, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 16, + "incorrect value for obs[0].sid.sat, expected 16, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 17, + "incorrect value for obs[1].L.f, expected 17, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 372525, + "incorrect value for obs[1].L.i, expected 372525, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 1167851496, + "incorrect value for obs[1].P, expected 1167851496, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 208, + "incorrect value for obs[1].cn0, expected 208, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 14511, + "incorrect value for obs[1].lock, expected 14511, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 27, + "incorrect value for obs[1].sid.sat, expected 27, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 75, + "incorrect value for obs[2].L.f, expected 75, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, 221229, + "incorrect value for obs[2].L.i, expected 221229, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 1149000000, + "incorrect value for obs[2].P, expected 1149000000, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 185, + "incorrect value for obs[2].cn0, expected 185, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 52809, + "incorrect value for obs[2].lock, expected 52809, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 29, + "incorrect value for obs[2].sid.sat, expected 29, is {}", + msg.obs[2].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepC"), + }; + } + { + use sbp::messages::observation::MsgObsDepC; + let payload: Vec = vec![ + 85, 73, 0, 70, 152, 87, 208, 95, 183, 24, 106, 7, 32, 44, 8, 74, 80, 86, 93, 247, 255, + 57, 158, 229, 229, 4, 0, 0, 0, 224, 229, 96, 70, 156, 146, 250, 255, 221, 200, 20, 28, + 6, 0, 0, 0, 60, 82, 62, 77, 93, 58, 242, 255, 39, 164, 180, 178, 7, 0, 0, 0, 222, 73, + 190, 77, 46, 39, 13, 0, 202, 181, 233, 164, 10, 0, 0, 0, 149, 64, 9, 75, 114, 191, 21, + 0, 249, 182, 196, 209, 12, 0, 0, 0, 112, 8, + ]; + + assert_eq!( + MsgObsDepC::MSG_ID, + 0x49, + "Incorrect message type, expected 0x49, is {}", + MsgObsDepC::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepC(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x9846, + "incorrect sender id, expected 0x9846, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 32, + "incorrect value for header.n_obs, expected 32, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 414670800, + "incorrect value for header.t.tow, expected 414670800, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1898, + "incorrect value for header.t.wn, expected 1898, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 57, + "incorrect value for obs[0].L.f, expected 57, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, -565930, + "incorrect value for obs[0].L.i, expected -565930, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 1347029036, + "incorrect value for obs[0].P, expected 1347029036, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 158, + "incorrect value for obs[0].cn0, expected 158, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 58853, + "incorrect value for obs[0].lock, expected 58853, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 4, + "incorrect value for obs[0].sid.sat, expected 4, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 221, + "incorrect value for obs[1].L.f, expected 221, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, -355684, + "incorrect value for obs[1].L.i, expected -355684, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 1180755424, + "incorrect value for obs[1].P, expected 1180755424, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 200, + "incorrect value for obs[1].cn0, expected 200, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 7188, + "incorrect value for obs[1].lock, expected 7188, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 6, + "incorrect value for obs[1].sid.sat, expected 6, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 39, + "incorrect value for obs[2].L.f, expected 39, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, -902563, + "incorrect value for obs[2].L.i, expected -902563, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 1295929916, + "incorrect value for obs[2].P, expected 1295929916, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 164, + "incorrect value for obs[2].cn0, expected 164, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 45748, + "incorrect value for obs[2].lock, expected 45748, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 7, + "incorrect value for obs[2].sid.sat, expected 7, is {}", + msg.obs[2].sid.sat + ); + assert_eq!( + msg.obs[3].L.f, 202, + "incorrect value for obs[3].L.f, expected 202, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, 861998, + "incorrect value for obs[3].L.i, expected 861998, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 1304316382, + "incorrect value for obs[3].P, expected 1304316382, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 181, + "incorrect value for obs[3].cn0, expected 181, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 42217, + "incorrect value for obs[3].lock, expected 42217, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].sid.code, 0, + "incorrect value for obs[3].sid.code, expected 0, is {}", + msg.obs[3].sid.code + ); + assert_eq!( + msg.obs[3].sid.reserved, 0, + "incorrect value for obs[3].sid.reserved, expected 0, is {}", + msg.obs[3].sid.reserved + ); + assert_eq!( + msg.obs[3].sid.sat, 10, + "incorrect value for obs[3].sid.sat, expected 10, is {}", + msg.obs[3].sid.sat + ); + assert_eq!( + msg.obs[4].L.f, 249, + "incorrect value for obs[4].L.f, expected 249, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, 1425266, + "incorrect value for obs[4].L.i, expected 1425266, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 1258897557, + "incorrect value for obs[4].P, expected 1258897557, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 182, + "incorrect value for obs[4].cn0, expected 182, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 53700, + "incorrect value for obs[4].lock, expected 53700, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].sid.code, 0, + "incorrect value for obs[4].sid.code, expected 0, is {}", + msg.obs[4].sid.code + ); + assert_eq!( + msg.obs[4].sid.reserved, 0, + "incorrect value for obs[4].sid.reserved, expected 0, is {}", + msg.obs[4].sid.reserved + ); + assert_eq!( + msg.obs[4].sid.sat, 12, + "incorrect value for obs[4].sid.sat, expected 12, is {}", + msg.obs[4].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepC"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_observation_26.rs b/rust/sbp/tests/auto_check_sbp_observation_26.rs new file mode 100644 index 0000000000..033058aaa6 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_observation_26.rs @@ -0,0 +1,1243 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgObs_dep_b.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_observation_26() { + { + use sbp::messages::observation::MsgObsDepB; + let payload: Vec = vec![ + 85, 67, 0, 246, 215, 103, 120, 46, 39, 0, 251, 6, 32, 180, 175, 187, 133, 223, 53, 7, + 7, 27, 157, 0, 0, 202, 0, 0, 0, 58, 140, 85, 147, 88, 28, 190, 7, 175, 144, 0, 0, 203, + 0, 0, 0, 220, 140, 248, 138, 208, 172, 77, 7, 135, 151, 0, 0, 208, 0, 0, 0, 173, 194, + 72, 135, 115, 18, 28, 7, 242, 156, 0, 0, 212, 0, 0, 0, 164, 144, 105, 124, 18, 196, + 137, 6, 120, 168, 0, 0, 217, 0, 0, 0, 30, 232, 228, 139, 210, 7, 90, 7, 87, 150, 0, 0, + 218, 0, 0, 0, 169, 85, + ]; + + assert_eq!( + MsgObsDepB::MSG_ID, + 0x43, + "Incorrect message type, expected 0x43, is {}", + MsgObsDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 32, + "incorrect value for header.n_obs, expected 32, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 2567800, + "incorrect value for header.t.tow, expected 2567800, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1787, + "incorrect value for header.t.wn, expected 1787, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 27, + "incorrect value for obs[0].L.f, expected 27, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 117913055, + "incorrect value for obs[0].L.i, expected 117913055, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2243669940, + "incorrect value for obs[0].P, expected 2243669940, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 157, + "incorrect value for obs[0].cn0, expected 157, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 0, + "incorrect value for obs[0].lock, expected 0, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 202, + "incorrect value for obs[0].sid.sat, expected 202, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 175, + "incorrect value for obs[1].L.f, expected 175, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 129899608, + "incorrect value for obs[1].L.i, expected 129899608, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2471857210, + "incorrect value for obs[1].P, expected 2471857210, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 144, + "incorrect value for obs[1].cn0, expected 144, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 0, + "incorrect value for obs[1].lock, expected 0, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 203, + "incorrect value for obs[1].sid.sat, expected 203, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 135, + "incorrect value for obs[2].L.f, expected 135, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, 122531024, + "incorrect value for obs[2].L.i, expected 122531024, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2331544796, + "incorrect value for obs[2].P, expected 2331544796, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 151, + "incorrect value for obs[2].cn0, expected 151, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 0, + "incorrect value for obs[2].lock, expected 0, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 208, + "incorrect value for obs[2].sid.sat, expected 208, is {}", + msg.obs[2].sid.sat + ); + assert_eq!( + msg.obs[3].L.f, 242, + "incorrect value for obs[3].L.f, expected 242, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, 119280243, + "incorrect value for obs[3].L.i, expected 119280243, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 2269692589, + "incorrect value for obs[3].P, expected 2269692589, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 156, + "incorrect value for obs[3].cn0, expected 156, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 0, + "incorrect value for obs[3].lock, expected 0, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].sid.code, 0, + "incorrect value for obs[3].sid.code, expected 0, is {}", + msg.obs[3].sid.code + ); + assert_eq!( + msg.obs[3].sid.reserved, 0, + "incorrect value for obs[3].sid.reserved, expected 0, is {}", + msg.obs[3].sid.reserved + ); + assert_eq!( + msg.obs[3].sid.sat, 212, + "incorrect value for obs[3].sid.sat, expected 212, is {}", + msg.obs[3].sid.sat + ); + assert_eq!( + msg.obs[4].L.f, 120, + "incorrect value for obs[4].L.f, expected 120, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, 109691922, + "incorrect value for obs[4].L.i, expected 109691922, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 2087293092, + "incorrect value for obs[4].P, expected 2087293092, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 168, + "incorrect value for obs[4].cn0, expected 168, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 0, + "incorrect value for obs[4].lock, expected 0, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].sid.code, 0, + "incorrect value for obs[4].sid.code, expected 0, is {}", + msg.obs[4].sid.code + ); + assert_eq!( + msg.obs[4].sid.reserved, 0, + "incorrect value for obs[4].sid.reserved, expected 0, is {}", + msg.obs[4].sid.reserved + ); + assert_eq!( + msg.obs[4].sid.sat, 217, + "incorrect value for obs[4].sid.sat, expected 217, is {}", + msg.obs[4].sid.sat + ); + assert_eq!( + msg.obs[5].L.f, 87, + "incorrect value for obs[5].L.f, expected 87, is {}", + msg.obs[5].L.f + ); + assert_eq!( + msg.obs[5].L.i, 123340754, + "incorrect value for obs[5].L.i, expected 123340754, is {}", + msg.obs[5].L.i + ); + assert_eq!( + msg.obs[5].P, 2347034654, + "incorrect value for obs[5].P, expected 2347034654, is {}", + msg.obs[5].P + ); + assert_eq!( + msg.obs[5].cn0, 150, + "incorrect value for obs[5].cn0, expected 150, is {}", + msg.obs[5].cn0 + ); + assert_eq!( + msg.obs[5].lock, 0, + "incorrect value for obs[5].lock, expected 0, is {}", + msg.obs[5].lock + ); + assert_eq!( + msg.obs[5].sid.code, 0, + "incorrect value for obs[5].sid.code, expected 0, is {}", + msg.obs[5].sid.code + ); + assert_eq!( + msg.obs[5].sid.reserved, 0, + "incorrect value for obs[5].sid.reserved, expected 0, is {}", + msg.obs[5].sid.reserved + ); + assert_eq!( + msg.obs[5].sid.sat, 218, + "incorrect value for obs[5].sid.sat, expected 218, is {}", + msg.obs[5].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepB"), + }; + } + { + use sbp::messages::observation::MsgObsDepB; + let payload: Vec = vec![ + 85, 67, 0, 246, 215, 55, 120, 46, 39, 0, 251, 6, 33, 68, 199, 101, 136, 133, 247, 42, + 7, 219, 154, 0, 0, 220, 0, 0, 0, 219, 14, 123, 133, 96, 215, 3, 7, 235, 156, 0, 0, 222, + 0, 0, 0, 87, 166, 81, 122, 5, 173, 109, 6, 174, 170, 0, 0, 225, 0, 0, 0, 11, 233, + ]; + + assert_eq!( + MsgObsDepB::MSG_ID, + 0x43, + "Incorrect message type, expected 0x43, is {}", + MsgObsDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 33, + "incorrect value for header.n_obs, expected 33, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 2567800, + "incorrect value for header.t.tow, expected 2567800, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1787, + "incorrect value for header.t.wn, expected 1787, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 219, + "incorrect value for obs[0].L.f, expected 219, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 120256389, + "incorrect value for obs[0].L.i, expected 120256389, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2288371524, + "incorrect value for obs[0].P, expected 2288371524, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 154, + "incorrect value for obs[0].cn0, expected 154, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 0, + "incorrect value for obs[0].lock, expected 0, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 220, + "incorrect value for obs[0].sid.sat, expected 220, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 235, + "incorrect value for obs[1].L.f, expected 235, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 117692256, + "incorrect value for obs[1].L.i, expected 117692256, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2239434459, + "incorrect value for obs[1].P, expected 2239434459, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 156, + "incorrect value for obs[1].cn0, expected 156, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 0, + "incorrect value for obs[1].lock, expected 0, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 222, + "incorrect value for obs[1].sid.sat, expected 222, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 174, + "incorrect value for obs[2].L.f, expected 174, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, 107851013, + "incorrect value for obs[2].L.i, expected 107851013, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2052171351, + "incorrect value for obs[2].P, expected 2052171351, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 170, + "incorrect value for obs[2].cn0, expected 170, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 0, + "incorrect value for obs[2].lock, expected 0, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 225, + "incorrect value for obs[2].sid.sat, expected 225, is {}", + msg.obs[2].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepB"), + }; + } + { + use sbp::messages::observation::MsgObsDepB; + let payload: Vec = vec![ + 85, 67, 0, 246, 215, 103, 64, 47, 39, 0, 251, 6, 32, 100, 132, 187, 133, 236, 51, 7, 7, + 94, 156, 0, 0, 202, 0, 0, 0, 97, 184, 85, 147, 178, 30, 190, 7, 40, 140, 0, 0, 203, 0, + 0, 0, 135, 111, 248, 138, 90, 171, 77, 7, 2, 150, 0, 0, 208, 0, 0, 0, 180, 238, 72, + 135, 190, 20, 28, 7, 241, 155, 0, 0, 212, 0, 0, 0, 15, 153, 105, 124, 92, 196, 137, 6, + 153, 168, 0, 0, 217, 0, 0, 0, 49, 185, 228, 139, 144, 5, 90, 7, 41, 150, 0, 0, 218, 0, + 0, 0, 241, 98, + ]; + + assert_eq!( + MsgObsDepB::MSG_ID, + 0x43, + "Incorrect message type, expected 0x43, is {}", + MsgObsDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 32, + "incorrect value for header.n_obs, expected 32, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 2568000, + "incorrect value for header.t.tow, expected 2568000, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1787, + "incorrect value for header.t.wn, expected 1787, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 94, + "incorrect value for obs[0].L.f, expected 94, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 117912556, + "incorrect value for obs[0].L.i, expected 117912556, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2243658852, + "incorrect value for obs[0].P, expected 2243658852, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 156, + "incorrect value for obs[0].cn0, expected 156, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 0, + "incorrect value for obs[0].lock, expected 0, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 202, + "incorrect value for obs[0].sid.sat, expected 202, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 40, + "incorrect value for obs[1].L.f, expected 40, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 129900210, + "incorrect value for obs[1].L.i, expected 129900210, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2471868513, + "incorrect value for obs[1].P, expected 2471868513, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 140, + "incorrect value for obs[1].cn0, expected 140, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 0, + "incorrect value for obs[1].lock, expected 0, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 203, + "incorrect value for obs[1].sid.sat, expected 203, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 2, + "incorrect value for obs[2].L.f, expected 2, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, 122530650, + "incorrect value for obs[2].L.i, expected 122530650, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2331537287, + "incorrect value for obs[2].P, expected 2331537287, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 150, + "incorrect value for obs[2].cn0, expected 150, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 0, + "incorrect value for obs[2].lock, expected 0, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 208, + "incorrect value for obs[2].sid.sat, expected 208, is {}", + msg.obs[2].sid.sat + ); + assert_eq!( + msg.obs[3].L.f, 241, + "incorrect value for obs[3].L.f, expected 241, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, 119280830, + "incorrect value for obs[3].L.i, expected 119280830, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 2269703860, + "incorrect value for obs[3].P, expected 2269703860, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 155, + "incorrect value for obs[3].cn0, expected 155, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 0, + "incorrect value for obs[3].lock, expected 0, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].sid.code, 0, + "incorrect value for obs[3].sid.code, expected 0, is {}", + msg.obs[3].sid.code + ); + assert_eq!( + msg.obs[3].sid.reserved, 0, + "incorrect value for obs[3].sid.reserved, expected 0, is {}", + msg.obs[3].sid.reserved + ); + assert_eq!( + msg.obs[3].sid.sat, 212, + "incorrect value for obs[3].sid.sat, expected 212, is {}", + msg.obs[3].sid.sat + ); + assert_eq!( + msg.obs[4].L.f, 153, + "incorrect value for obs[4].L.f, expected 153, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, 109691996, + "incorrect value for obs[4].L.i, expected 109691996, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 2087295247, + "incorrect value for obs[4].P, expected 2087295247, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 168, + "incorrect value for obs[4].cn0, expected 168, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 0, + "incorrect value for obs[4].lock, expected 0, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].sid.code, 0, + "incorrect value for obs[4].sid.code, expected 0, is {}", + msg.obs[4].sid.code + ); + assert_eq!( + msg.obs[4].sid.reserved, 0, + "incorrect value for obs[4].sid.reserved, expected 0, is {}", + msg.obs[4].sid.reserved + ); + assert_eq!( + msg.obs[4].sid.sat, 217, + "incorrect value for obs[4].sid.sat, expected 217, is {}", + msg.obs[4].sid.sat + ); + assert_eq!( + msg.obs[5].L.f, 41, + "incorrect value for obs[5].L.f, expected 41, is {}", + msg.obs[5].L.f + ); + assert_eq!( + msg.obs[5].L.i, 123340176, + "incorrect value for obs[5].L.i, expected 123340176, is {}", + msg.obs[5].L.i + ); + assert_eq!( + msg.obs[5].P, 2347022641, + "incorrect value for obs[5].P, expected 2347022641, is {}", + msg.obs[5].P + ); + assert_eq!( + msg.obs[5].cn0, 150, + "incorrect value for obs[5].cn0, expected 150, is {}", + msg.obs[5].cn0 + ); + assert_eq!( + msg.obs[5].lock, 0, + "incorrect value for obs[5].lock, expected 0, is {}", + msg.obs[5].lock + ); + assert_eq!( + msg.obs[5].sid.code, 0, + "incorrect value for obs[5].sid.code, expected 0, is {}", + msg.obs[5].sid.code + ); + assert_eq!( + msg.obs[5].sid.reserved, 0, + "incorrect value for obs[5].sid.reserved, expected 0, is {}", + msg.obs[5].sid.reserved + ); + assert_eq!( + msg.obs[5].sid.sat, 218, + "incorrect value for obs[5].sid.sat, expected 218, is {}", + msg.obs[5].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepB"), + }; + } + { + use sbp::messages::observation::MsgObsDepB; + let payload: Vec = vec![ + 85, 67, 0, 246, 215, 55, 64, 47, 39, 0, 251, 6, 33, 234, 148, 101, 136, 15, 245, 42, 7, + 20, 154, 0, 0, 220, 0, 0, 0, 208, 247, 122, 133, 16, 214, 3, 7, 38, 156, 0, 0, 222, 0, + 0, 0, 15, 150, 81, 122, 22, 172, 109, 6, 7, 172, 0, 0, 225, 0, 0, 0, 201, 13, + ]; + + assert_eq!( + MsgObsDepB::MSG_ID, + 0x43, + "Incorrect message type, expected 0x43, is {}", + MsgObsDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 33, + "incorrect value for header.n_obs, expected 33, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 2568000, + "incorrect value for header.t.tow, expected 2568000, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1787, + "incorrect value for header.t.wn, expected 1787, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 20, + "incorrect value for obs[0].L.f, expected 20, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 120255759, + "incorrect value for obs[0].L.i, expected 120255759, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2288358634, + "incorrect value for obs[0].P, expected 2288358634, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 154, + "incorrect value for obs[0].cn0, expected 154, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 0, + "incorrect value for obs[0].lock, expected 0, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 220, + "incorrect value for obs[0].sid.sat, expected 220, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 38, + "incorrect value for obs[1].L.f, expected 38, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 117691920, + "incorrect value for obs[1].L.i, expected 117691920, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2239428560, + "incorrect value for obs[1].P, expected 2239428560, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 156, + "incorrect value for obs[1].cn0, expected 156, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 0, + "incorrect value for obs[1].lock, expected 0, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 222, + "incorrect value for obs[1].sid.sat, expected 222, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 7, + "incorrect value for obs[2].L.f, expected 7, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, 107850774, + "incorrect value for obs[2].L.i, expected 107850774, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2052167183, + "incorrect value for obs[2].P, expected 2052167183, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 172, + "incorrect value for obs[2].cn0, expected 172, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 0, + "incorrect value for obs[2].lock, expected 0, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 225, + "incorrect value for obs[2].sid.sat, expected 225, is {}", + msg.obs[2].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepB"), + }; + } + { + use sbp::messages::observation::MsgObsDepB; + let payload: Vec = vec![ + 85, 67, 0, 246, 215, 103, 8, 48, 39, 0, 251, 6, 32, 254, 96, 187, 133, 249, 49, 7, 7, + 165, 156, 0, 0, 202, 0, 0, 0, 113, 229, 85, 147, 11, 33, 190, 7, 106, 143, 0, 0, 203, + 0, 0, 0, 182, 85, 248, 138, 227, 169, 77, 7, 159, 150, 0, 0, 208, 0, 0, 0, 17, 24, 73, + 135, 10, 23, 28, 7, 7, 156, 0, 0, 212, 0, 0, 0, 108, 155, 105, 124, 166, 196, 137, 6, + 186, 170, 0, 0, 217, 0, 0, 0, 214, 142, 228, 139, 77, 3, 90, 7, 236, 151, 0, 0, 218, 0, + 0, 0, 59, 118, + ]; + + assert_eq!( + MsgObsDepB::MSG_ID, + 0x43, + "Incorrect message type, expected 0x43, is {}", + MsgObsDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 32, + "incorrect value for header.n_obs, expected 32, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 2568200, + "incorrect value for header.t.tow, expected 2568200, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1787, + "incorrect value for header.t.wn, expected 1787, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 165, + "incorrect value for obs[0].L.f, expected 165, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 117912057, + "incorrect value for obs[0].L.i, expected 117912057, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2243649790, + "incorrect value for obs[0].P, expected 2243649790, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 156, + "incorrect value for obs[0].cn0, expected 156, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 0, + "incorrect value for obs[0].lock, expected 0, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].sid.code, 0, + "incorrect value for obs[0].sid.code, expected 0, is {}", + msg.obs[0].sid.code + ); + assert_eq!( + msg.obs[0].sid.reserved, 0, + "incorrect value for obs[0].sid.reserved, expected 0, is {}", + msg.obs[0].sid.reserved + ); + assert_eq!( + msg.obs[0].sid.sat, 202, + "incorrect value for obs[0].sid.sat, expected 202, is {}", + msg.obs[0].sid.sat + ); + assert_eq!( + msg.obs[1].L.f, 106, + "incorrect value for obs[1].L.f, expected 106, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 129900811, + "incorrect value for obs[1].L.i, expected 129900811, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2471880049, + "incorrect value for obs[1].P, expected 2471880049, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 143, + "incorrect value for obs[1].cn0, expected 143, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 0, + "incorrect value for obs[1].lock, expected 0, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].sid.code, 0, + "incorrect value for obs[1].sid.code, expected 0, is {}", + msg.obs[1].sid.code + ); + assert_eq!( + msg.obs[1].sid.reserved, 0, + "incorrect value for obs[1].sid.reserved, expected 0, is {}", + msg.obs[1].sid.reserved + ); + assert_eq!( + msg.obs[1].sid.sat, 203, + "incorrect value for obs[1].sid.sat, expected 203, is {}", + msg.obs[1].sid.sat + ); + assert_eq!( + msg.obs[2].L.f, 159, + "incorrect value for obs[2].L.f, expected 159, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, 122530275, + "incorrect value for obs[2].L.i, expected 122530275, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2331530678, + "incorrect value for obs[2].P, expected 2331530678, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 150, + "incorrect value for obs[2].cn0, expected 150, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 0, + "incorrect value for obs[2].lock, expected 0, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].sid.code, 0, + "incorrect value for obs[2].sid.code, expected 0, is {}", + msg.obs[2].sid.code + ); + assert_eq!( + msg.obs[2].sid.reserved, 0, + "incorrect value for obs[2].sid.reserved, expected 0, is {}", + msg.obs[2].sid.reserved + ); + assert_eq!( + msg.obs[2].sid.sat, 208, + "incorrect value for obs[2].sid.sat, expected 208, is {}", + msg.obs[2].sid.sat + ); + assert_eq!( + msg.obs[3].L.f, 7, + "incorrect value for obs[3].L.f, expected 7, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, 119281418, + "incorrect value for obs[3].L.i, expected 119281418, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 2269714449, + "incorrect value for obs[3].P, expected 2269714449, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 156, + "incorrect value for obs[3].cn0, expected 156, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 0, + "incorrect value for obs[3].lock, expected 0, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].sid.code, 0, + "incorrect value for obs[3].sid.code, expected 0, is {}", + msg.obs[3].sid.code + ); + assert_eq!( + msg.obs[3].sid.reserved, 0, + "incorrect value for obs[3].sid.reserved, expected 0, is {}", + msg.obs[3].sid.reserved + ); + assert_eq!( + msg.obs[3].sid.sat, 212, + "incorrect value for obs[3].sid.sat, expected 212, is {}", + msg.obs[3].sid.sat + ); + assert_eq!( + msg.obs[4].L.f, 186, + "incorrect value for obs[4].L.f, expected 186, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, 109692070, + "incorrect value for obs[4].L.i, expected 109692070, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 2087295852, + "incorrect value for obs[4].P, expected 2087295852, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 170, + "incorrect value for obs[4].cn0, expected 170, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 0, + "incorrect value for obs[4].lock, expected 0, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].sid.code, 0, + "incorrect value for obs[4].sid.code, expected 0, is {}", + msg.obs[4].sid.code + ); + assert_eq!( + msg.obs[4].sid.reserved, 0, + "incorrect value for obs[4].sid.reserved, expected 0, is {}", + msg.obs[4].sid.reserved + ); + assert_eq!( + msg.obs[4].sid.sat, 217, + "incorrect value for obs[4].sid.sat, expected 217, is {}", + msg.obs[4].sid.sat + ); + assert_eq!( + msg.obs[5].L.f, 236, + "incorrect value for obs[5].L.f, expected 236, is {}", + msg.obs[5].L.f + ); + assert_eq!( + msg.obs[5].L.i, 123339597, + "incorrect value for obs[5].L.i, expected 123339597, is {}", + msg.obs[5].L.i + ); + assert_eq!( + msg.obs[5].P, 2347011798, + "incorrect value for obs[5].P, expected 2347011798, is {}", + msg.obs[5].P + ); + assert_eq!( + msg.obs[5].cn0, 151, + "incorrect value for obs[5].cn0, expected 151, is {}", + msg.obs[5].cn0 + ); + assert_eq!( + msg.obs[5].lock, 0, + "incorrect value for obs[5].lock, expected 0, is {}", + msg.obs[5].lock + ); + assert_eq!( + msg.obs[5].sid.code, 0, + "incorrect value for obs[5].sid.code, expected 0, is {}", + msg.obs[5].sid.code + ); + assert_eq!( + msg.obs[5].sid.reserved, 0, + "incorrect value for obs[5].sid.reserved, expected 0, is {}", + msg.obs[5].sid.reserved + ); + assert_eq!( + msg.obs[5].sid.sat, 218, + "incorrect value for obs[5].sid.sat, expected 218, is {}", + msg.obs[5].sid.sat + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepB"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_observation_44.rs b/rust/sbp/tests/auto_check_sbp_observation_44.rs new file mode 100644 index 0000000000..bb4cf8a600 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_observation_44.rs @@ -0,0 +1,2147 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_observation.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_observation_44() { + { + use sbp::messages::observation::MsgObsDepA; + let payload: Vec = vec![ + 85, 69, 0, 195, 4, 98, 56, 158, 67, 24, 46, 7, 32, 56, 235, 249, 121, 244, 114, 255, + 255, 33, 46, 67, 218, 0, 238, 203, 70, 124, 22, 25, 3, 0, 98, 43, 184, 157, 2, 176, + 133, 197, 125, 126, 71, 253, 255, 185, 39, 68, 55, 3, 60, 173, 162, 131, 98, 231, 253, + 255, 139, 30, 33, 16, 10, 128, 178, 248, 136, 42, 113, 253, 255, 40, 20, 42, 71, 13, + 246, 246, 17, 135, 255, 51, 3, 0, 64, 27, 108, 249, 22, 210, 41, 114, 118, 131, 48, + 255, 255, 31, 52, 226, 58, 30, 23, 217, + ]; + + assert_eq!( + MsgObsDepA::MSG_ID, + 0x45, + "Incorrect message type, expected 0x45, is {}", + MsgObsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 32, + "incorrect value for header.n_obs, expected 32, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 407084600, + "incorrect value for header.t.tow, expected 407084600, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1838, + "incorrect value for header.t.wn, expected 1838, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 33, + "incorrect value for obs[0].L.f, expected 33, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, -36108, + "incorrect value for obs[0].L.i, expected -36108, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2046421816, + "incorrect value for obs[0].P, expected 2046421816, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 46, + "incorrect value for obs[0].cn0, expected 46, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 55875, + "incorrect value for obs[0].lock, expected 55875, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].prn, 0, + "incorrect value for obs[0].prn, expected 0, is {}", + msg.obs[0].prn + ); + assert_eq!( + msg.obs[1].L.f, 98, + "incorrect value for obs[1].L.f, expected 98, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 203030, + "incorrect value for obs[1].L.i, expected 203030, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2085014510, + "incorrect value for obs[1].P, expected 2085014510, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 43, + "incorrect value for obs[1].cn0, expected 43, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 40376, + "incorrect value for obs[1].lock, expected 40376, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].prn, 2, + "incorrect value for obs[1].prn, expected 2, is {}", + msg.obs[1].prn + ); + assert_eq!( + msg.obs[2].L.f, 185, + "incorrect value for obs[2].L.f, expected 185, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, -178306, + "incorrect value for obs[2].L.i, expected -178306, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2110096816, + "incorrect value for obs[2].P, expected 2110096816, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 39, + "incorrect value for obs[2].cn0, expected 39, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 14148, + "incorrect value for obs[2].lock, expected 14148, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].prn, 3, + "incorrect value for obs[2].prn, expected 3, is {}", + msg.obs[2].prn + ); + assert_eq!( + msg.obs[3].L.f, 139, + "incorrect value for obs[3].L.f, expected 139, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, -137374, + "incorrect value for obs[3].L.i, expected -137374, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 2208476476, + "incorrect value for obs[3].P, expected 2208476476, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 30, + "incorrect value for obs[3].cn0, expected 30, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 4129, + "incorrect value for obs[3].lock, expected 4129, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].prn, 10, + "incorrect value for obs[3].prn, expected 10, is {}", + msg.obs[3].prn + ); + assert_eq!( + msg.obs[4].L.f, 40, + "incorrect value for obs[4].L.f, expected 40, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, -167638, + "incorrect value for obs[4].L.i, expected -167638, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 2298000000, + "incorrect value for obs[4].P, expected 2298000000, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 20, + "incorrect value for obs[4].cn0, expected 20, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 18218, + "incorrect value for obs[4].lock, expected 18218, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].prn, 13, + "incorrect value for obs[4].prn, expected 13, is {}", + msg.obs[4].prn + ); + assert_eq!( + msg.obs[5].L.f, 64, + "incorrect value for obs[5].L.f, expected 64, is {}", + msg.obs[5].L.f + ); + assert_eq!( + msg.obs[5].L.i, 209919, + "incorrect value for obs[5].L.i, expected 209919, is {}", + msg.obs[5].L.i + ); + assert_eq!( + msg.obs[5].P, 2266101494, + "incorrect value for obs[5].P, expected 2266101494, is {}", + msg.obs[5].P + ); + assert_eq!( + msg.obs[5].cn0, 27, + "incorrect value for obs[5].cn0, expected 27, is {}", + msg.obs[5].cn0 + ); + assert_eq!( + msg.obs[5].lock, 63852, + "incorrect value for obs[5].lock, expected 63852, is {}", + msg.obs[5].lock + ); + assert_eq!( + msg.obs[5].prn, 22, + "incorrect value for obs[5].prn, expected 22, is {}", + msg.obs[5].prn + ); + assert_eq!( + msg.obs[6].L.f, 31, + "incorrect value for obs[6].L.f, expected 31, is {}", + msg.obs[6].L.f + ); + assert_eq!( + msg.obs[6].L.i, -53117, + "incorrect value for obs[6].L.i, expected -53117, is {}", + msg.obs[6].L.i + ); + assert_eq!( + msg.obs[6].P, 1987193298, + "incorrect value for obs[6].P, expected 1987193298, is {}", + msg.obs[6].P + ); + assert_eq!( + msg.obs[6].cn0, 52, + "incorrect value for obs[6].cn0, expected 52, is {}", + msg.obs[6].cn0 + ); + assert_eq!( + msg.obs[6].lock, 15074, + "incorrect value for obs[6].lock, expected 15074, is {}", + msg.obs[6].lock + ); + assert_eq!( + msg.obs[6].prn, 30, + "incorrect value for obs[6].prn, expected 30, is {}", + msg.obs[6].prn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepA"), + }; + } + { + use sbp::messages::observation::MsgObsDepA; + let payload: Vec = vec![ + 85, 69, 0, 195, 4, 20, 56, 158, 67, 24, 46, 7, 33, 84, 52, 164, 117, 102, 32, 0, 0, + 147, 62, 62, 250, 31, 234, 14, + ]; + + assert_eq!( + MsgObsDepA::MSG_ID, + 0x45, + "Incorrect message type, expected 0x45, is {}", + MsgObsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 33, + "incorrect value for header.n_obs, expected 33, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 407084600, + "incorrect value for header.t.tow, expected 407084600, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1838, + "incorrect value for header.t.wn, expected 1838, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 147, + "incorrect value for obs[0].L.f, expected 147, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 8294, + "incorrect value for obs[0].L.i, expected 8294, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 1973695572, + "incorrect value for obs[0].P, expected 1973695572, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 62, + "incorrect value for obs[0].cn0, expected 62, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 64062, + "incorrect value for obs[0].lock, expected 64062, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].prn, 31, + "incorrect value for obs[0].prn, expected 31, is {}", + msg.obs[0].prn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepA"), + }; + } + { + use sbp::messages::observation::MsgObsDepA; + let payload: Vec = vec![ + 85, 69, 0, 195, 4, 98, 0, 159, 67, 24, 46, 7, 32, 32, 209, 249, 121, 145, 114, 255, + 255, 141, 45, 67, 218, 0, 177, 128, 70, 124, 79, 27, 3, 0, 159, 44, 184, 157, 2, 59, + 135, 197, 125, 175, 69, 253, 255, 77, 40, 68, 55, 3, 211, 172, 162, 131, 177, 229, 253, + 255, 20, 31, 33, 16, 10, 128, 178, 248, 136, 116, 111, 253, 255, 94, 21, 42, 71, 13, + 182, 173, 17, 135, 37, 54, 3, 0, 214, 27, 108, 249, 22, 91, 20, 114, 118, 240, 47, 255, + 255, 129, 52, 226, 58, 30, 200, 119, + ]; + + assert_eq!( + MsgObsDepA::MSG_ID, + 0x45, + "Incorrect message type, expected 0x45, is {}", + MsgObsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 32, + "incorrect value for header.n_obs, expected 32, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 407084800, + "incorrect value for header.t.tow, expected 407084800, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1838, + "incorrect value for header.t.wn, expected 1838, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 141, + "incorrect value for obs[0].L.f, expected 141, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, -36207, + "incorrect value for obs[0].L.i, expected -36207, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2046415136, + "incorrect value for obs[0].P, expected 2046415136, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 45, + "incorrect value for obs[0].cn0, expected 45, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 55875, + "incorrect value for obs[0].lock, expected 55875, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].prn, 0, + "incorrect value for obs[0].prn, expected 0, is {}", + msg.obs[0].prn + ); + assert_eq!( + msg.obs[1].L.f, 159, + "incorrect value for obs[1].L.f, expected 159, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, 203599, + "incorrect value for obs[1].L.i, expected 203599, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2084995249, + "incorrect value for obs[1].P, expected 2084995249, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 44, + "incorrect value for obs[1].cn0, expected 44, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 40376, + "incorrect value for obs[1].lock, expected 40376, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].prn, 2, + "incorrect value for obs[1].prn, expected 2, is {}", + msg.obs[1].prn + ); + assert_eq!( + msg.obs[2].L.f, 77, + "incorrect value for obs[2].L.f, expected 77, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, -178769, + "incorrect value for obs[2].L.i, expected -178769, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2110097211, + "incorrect value for obs[2].P, expected 2110097211, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 40, + "incorrect value for obs[2].cn0, expected 40, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 14148, + "incorrect value for obs[2].lock, expected 14148, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].prn, 3, + "incorrect value for obs[2].prn, expected 3, is {}", + msg.obs[2].prn + ); + assert_eq!( + msg.obs[3].L.f, 20, + "incorrect value for obs[3].L.f, expected 20, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, -137807, + "incorrect value for obs[3].L.i, expected -137807, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 2208476371, + "incorrect value for obs[3].P, expected 2208476371, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 31, + "incorrect value for obs[3].cn0, expected 31, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 4129, + "incorrect value for obs[3].lock, expected 4129, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].prn, 10, + "incorrect value for obs[3].prn, expected 10, is {}", + msg.obs[3].prn + ); + assert_eq!( + msg.obs[4].L.f, 94, + "incorrect value for obs[4].L.f, expected 94, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, -168076, + "incorrect value for obs[4].L.i, expected -168076, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 2298000000, + "incorrect value for obs[4].P, expected 2298000000, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 21, + "incorrect value for obs[4].cn0, expected 21, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 18218, + "incorrect value for obs[4].lock, expected 18218, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].prn, 13, + "incorrect value for obs[4].prn, expected 13, is {}", + msg.obs[4].prn + ); + assert_eq!( + msg.obs[5].L.f, 214, + "incorrect value for obs[5].L.f, expected 214, is {}", + msg.obs[5].L.f + ); + assert_eq!( + msg.obs[5].L.i, 210469, + "incorrect value for obs[5].L.i, expected 210469, is {}", + msg.obs[5].L.i + ); + assert_eq!( + msg.obs[5].P, 2266082742, + "incorrect value for obs[5].P, expected 2266082742, is {}", + msg.obs[5].P + ); + assert_eq!( + msg.obs[5].cn0, 27, + "incorrect value for obs[5].cn0, expected 27, is {}", + msg.obs[5].cn0 + ); + assert_eq!( + msg.obs[5].lock, 63852, + "incorrect value for obs[5].lock, expected 63852, is {}", + msg.obs[5].lock + ); + assert_eq!( + msg.obs[5].prn, 22, + "incorrect value for obs[5].prn, expected 22, is {}", + msg.obs[5].prn + ); + assert_eq!( + msg.obs[6].L.f, 129, + "incorrect value for obs[6].L.f, expected 129, is {}", + msg.obs[6].L.f + ); + assert_eq!( + msg.obs[6].L.i, -53264, + "incorrect value for obs[6].L.i, expected -53264, is {}", + msg.obs[6].L.i + ); + assert_eq!( + msg.obs[6].P, 1987187803, + "incorrect value for obs[6].P, expected 1987187803, is {}", + msg.obs[6].P + ); + assert_eq!( + msg.obs[6].cn0, 52, + "incorrect value for obs[6].cn0, expected 52, is {}", + msg.obs[6].cn0 + ); + assert_eq!( + msg.obs[6].lock, 15074, + "incorrect value for obs[6].lock, expected 15074, is {}", + msg.obs[6].lock + ); + assert_eq!( + msg.obs[6].prn, 30, + "incorrect value for obs[6].prn, expected 30, is {}", + msg.obs[6].prn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepA"), + }; + } + { + use sbp::messages::observation::MsgObsDepA; + let payload: Vec = vec![ + 85, 69, 0, 195, 4, 20, 0, 159, 67, 24, 46, 7, 33, 49, 19, 164, 117, 120, 32, 0, 0, 222, + 63, 62, 250, 31, 11, 231, + ]; + + assert_eq!( + MsgObsDepA::MSG_ID, + 0x45, + "Incorrect message type, expected 0x45, is {}", + MsgObsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 33, + "incorrect value for header.n_obs, expected 33, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 407084800, + "incorrect value for header.t.tow, expected 407084800, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1838, + "incorrect value for header.t.wn, expected 1838, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 222, + "incorrect value for obs[0].L.f, expected 222, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, 8312, + "incorrect value for obs[0].L.i, expected 8312, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 1973687089, + "incorrect value for obs[0].P, expected 1973687089, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 63, + "incorrect value for obs[0].cn0, expected 63, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 64062, + "incorrect value for obs[0].lock, expected 64062, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].prn, 31, + "incorrect value for obs[0].prn, expected 31, is {}", + msg.obs[0].prn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepA"), + }; + } + { + use sbp::messages::observation::MsgObsDepA; + let payload: Vec = vec![ + 85, 69, 0, 195, 4, 72, 96, 162, 68, 24, 46, 7, 16, 87, 132, 217, 121, 121, 148, 255, + 255, 189, 43, 175, 147, 0, 132, 64, 200, 125, 106, 31, 254, 255, 1, 41, 14, 177, 3, + 128, 178, 248, 136, 70, 68, 254, 255, 166, 18, 184, 133, 13, 24, 127, 178, 134, 6, 25, + 2, 0, 249, 28, 33, 96, 22, 170, 104, 86, 118, 67, 112, 255, 255, 203, 56, 208, 88, 30, + 43, 107, + ]; + + assert_eq!( + MsgObsDepA::MSG_ID, + 0x45, + "Incorrect message type, expected 0x45, is {}", + MsgObsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 16, + "incorrect value for header.n_obs, expected 16, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 407151200, + "incorrect value for header.t.tow, expected 407151200, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1838, + "incorrect value for header.t.wn, expected 1838, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 189, + "incorrect value for obs[0].L.f, expected 189, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, -27527, + "incorrect value for obs[0].L.i, expected -27527, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2044298327, + "incorrect value for obs[0].P, expected 2044298327, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 43, + "incorrect value for obs[0].cn0, expected 43, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 37807, + "incorrect value for obs[0].lock, expected 37807, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].prn, 0, + "incorrect value for obs[0].prn, expected 0, is {}", + msg.obs[0].prn + ); + assert_eq!( + msg.obs[1].L.f, 1, + "incorrect value for obs[1].L.f, expected 1, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, -123030, + "incorrect value for obs[1].L.i, expected -123030, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2110275716, + "incorrect value for obs[1].P, expected 2110275716, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 41, + "incorrect value for obs[1].cn0, expected 41, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 45326, + "incorrect value for obs[1].lock, expected 45326, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].prn, 3, + "incorrect value for obs[1].prn, expected 3, is {}", + msg.obs[1].prn + ); + assert_eq!( + msg.obs[2].L.f, 166, + "incorrect value for obs[2].L.f, expected 166, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, -113594, + "incorrect value for obs[2].L.i, expected -113594, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2298000000, + "incorrect value for obs[2].P, expected 2298000000, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 18, + "incorrect value for obs[2].cn0, expected 18, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 34232, + "incorrect value for obs[2].lock, expected 34232, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].prn, 13, + "incorrect value for obs[2].prn, expected 13, is {}", + msg.obs[2].prn + ); + assert_eq!( + msg.obs[3].L.f, 249, + "incorrect value for obs[3].L.f, expected 249, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, 137478, + "incorrect value for obs[3].L.i, expected 137478, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 2259844888, + "incorrect value for obs[3].P, expected 2259844888, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 28, + "incorrect value for obs[3].cn0, expected 28, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 24609, + "incorrect value for obs[3].lock, expected 24609, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].prn, 22, + "incorrect value for obs[3].prn, expected 22, is {}", + msg.obs[3].prn + ); + assert_eq!( + msg.obs[4].L.f, 203, + "incorrect value for obs[4].L.f, expected 203, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, -36797, + "incorrect value for obs[4].L.i, expected -36797, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 1985374378, + "incorrect value for obs[4].P, expected 1985374378, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 56, + "incorrect value for obs[4].cn0, expected 56, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 22736, + "incorrect value for obs[4].lock, expected 22736, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].prn, 30, + "incorrect value for obs[4].prn, expected 30, is {}", + msg.obs[4].prn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepA"), + }; + } + { + use sbp::messages::observation::MsgObsDepA; + let payload: Vec = vec![ + 85, 69, 0, 195, 4, 72, 40, 163, 68, 24, 46, 7, 16, 132, 107, 217, 121, 14, 148, 255, + 255, 1, 44, 175, 147, 0, 129, 66, 200, 125, 148, 29, 254, 255, 153, 41, 14, 177, 3, + 128, 178, 248, 136, 143, 66, 254, 255, 222, 18, 184, 133, 13, 158, 53, 178, 134, 42, + 27, 2, 0, 237, 30, 33, 96, 22, 38, 83, 86, 118, 168, 111, 255, 255, 45, 56, 208, 88, + 30, 1, 175, + ]; + + assert_eq!( + MsgObsDepA::MSG_ID, + 0x45, + "Incorrect message type, expected 0x45, is {}", + MsgObsDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgObsDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.header.n_obs, 16, + "incorrect value for header.n_obs, expected 16, is {}", + msg.header.n_obs + ); + assert_eq!( + msg.header.t.tow, 407151400, + "incorrect value for header.t.tow, expected 407151400, is {}", + msg.header.t.tow + ); + assert_eq!( + msg.header.t.wn, 1838, + "incorrect value for header.t.wn, expected 1838, is {}", + msg.header.t.wn + ); + assert_eq!( + msg.obs[0].L.f, 1, + "incorrect value for obs[0].L.f, expected 1, is {}", + msg.obs[0].L.f + ); + assert_eq!( + msg.obs[0].L.i, -27634, + "incorrect value for obs[0].L.i, expected -27634, is {}", + msg.obs[0].L.i + ); + assert_eq!( + msg.obs[0].P, 2044291972, + "incorrect value for obs[0].P, expected 2044291972, is {}", + msg.obs[0].P + ); + assert_eq!( + msg.obs[0].cn0, 44, + "incorrect value for obs[0].cn0, expected 44, is {}", + msg.obs[0].cn0 + ); + assert_eq!( + msg.obs[0].lock, 37807, + "incorrect value for obs[0].lock, expected 37807, is {}", + msg.obs[0].lock + ); + assert_eq!( + msg.obs[0].prn, 0, + "incorrect value for obs[0].prn, expected 0, is {}", + msg.obs[0].prn + ); + assert_eq!( + msg.obs[1].L.f, 153, + "incorrect value for obs[1].L.f, expected 153, is {}", + msg.obs[1].L.f + ); + assert_eq!( + msg.obs[1].L.i, -123500, + "incorrect value for obs[1].L.i, expected -123500, is {}", + msg.obs[1].L.i + ); + assert_eq!( + msg.obs[1].P, 2110276225, + "incorrect value for obs[1].P, expected 2110276225, is {}", + msg.obs[1].P + ); + assert_eq!( + msg.obs[1].cn0, 41, + "incorrect value for obs[1].cn0, expected 41, is {}", + msg.obs[1].cn0 + ); + assert_eq!( + msg.obs[1].lock, 45326, + "incorrect value for obs[1].lock, expected 45326, is {}", + msg.obs[1].lock + ); + assert_eq!( + msg.obs[1].prn, 3, + "incorrect value for obs[1].prn, expected 3, is {}", + msg.obs[1].prn + ); + assert_eq!( + msg.obs[2].L.f, 222, + "incorrect value for obs[2].L.f, expected 222, is {}", + msg.obs[2].L.f + ); + assert_eq!( + msg.obs[2].L.i, -114033, + "incorrect value for obs[2].L.i, expected -114033, is {}", + msg.obs[2].L.i + ); + assert_eq!( + msg.obs[2].P, 2298000000, + "incorrect value for obs[2].P, expected 2298000000, is {}", + msg.obs[2].P + ); + assert_eq!( + msg.obs[2].cn0, 18, + "incorrect value for obs[2].cn0, expected 18, is {}", + msg.obs[2].cn0 + ); + assert_eq!( + msg.obs[2].lock, 34232, + "incorrect value for obs[2].lock, expected 34232, is {}", + msg.obs[2].lock + ); + assert_eq!( + msg.obs[2].prn, 13, + "incorrect value for obs[2].prn, expected 13, is {}", + msg.obs[2].prn + ); + assert_eq!( + msg.obs[3].L.f, 237, + "incorrect value for obs[3].L.f, expected 237, is {}", + msg.obs[3].L.f + ); + assert_eq!( + msg.obs[3].L.i, 138026, + "incorrect value for obs[3].L.i, expected 138026, is {}", + msg.obs[3].L.i + ); + assert_eq!( + msg.obs[3].P, 2259826078, + "incorrect value for obs[3].P, expected 2259826078, is {}", + msg.obs[3].P + ); + assert_eq!( + msg.obs[3].cn0, 30, + "incorrect value for obs[3].cn0, expected 30, is {}", + msg.obs[3].cn0 + ); + assert_eq!( + msg.obs[3].lock, 24609, + "incorrect value for obs[3].lock, expected 24609, is {}", + msg.obs[3].lock + ); + assert_eq!( + msg.obs[3].prn, 22, + "incorrect value for obs[3].prn, expected 22, is {}", + msg.obs[3].prn + ); + assert_eq!( + msg.obs[4].L.f, 45, + "incorrect value for obs[4].L.f, expected 45, is {}", + msg.obs[4].L.f + ); + assert_eq!( + msg.obs[4].L.i, -36952, + "incorrect value for obs[4].L.i, expected -36952, is {}", + msg.obs[4].L.i + ); + assert_eq!( + msg.obs[4].P, 1985368870, + "incorrect value for obs[4].P, expected 1985368870, is {}", + msg.obs[4].P + ); + assert_eq!( + msg.obs[4].cn0, 56, + "incorrect value for obs[4].cn0, expected 56, is {}", + msg.obs[4].cn0 + ); + assert_eq!( + msg.obs[4].lock, 22736, + "incorrect value for obs[4].lock, expected 22736, is {}", + msg.obs[4].lock + ); + assert_eq!( + msg.obs[4].prn, 30, + "incorrect value for obs[4].prn, expected 30, is {}", + msg.obs[4].prn + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgObsDepA"), + }; + } + { + use sbp::messages::observation::MsgEphemerisDepB; + let payload: Vec = vec![ + 85, 70, 0, 195, 4, 176, 0, 0, 0, 0, 0, 0, 60, 190, 0, 0, 0, 0, 0, 186, 82, 192, 0, 0, + 0, 0, 0, 76, 109, 64, 0, 0, 0, 0, 0, 132, 208, 190, 0, 0, 0, 0, 0, 254, 220, 62, 0, 0, + 0, 0, 0, 0, 113, 62, 0, 0, 0, 0, 0, 0, 133, 190, 28, 36, 25, 81, 223, 254, 52, 62, 220, + 116, 216, 39, 33, 189, 3, 64, 0, 0, 0, 156, 177, 204, 134, 63, 0, 0, 160, 220, 182, 33, + 180, 64, 152, 225, 192, 44, 254, 76, 238, 191, 41, 150, 24, 2, 148, 156, 65, 190, 252, + 90, 119, 48, 15, 215, 240, 63, 124, 127, 115, 94, 208, 16, 238, 63, 165, 115, 52, 74, + 97, 167, 246, 189, 0, 0, 0, 0, 192, 180, 229, 190, 0, 0, 0, 0, 0, 0, 112, 189, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, + 1, 1, 3, 0, 225, 156, + ]; + + assert_eq!( + MsgEphemerisDepB::MSG_ID, + 0x46, + "Incorrect message type, expected 0x46, is {}", + MsgEphemerisDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgEphemerisDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.af0.almost_eq(-1.03502534329891205e-05), + "incorrect value for af0, expected -1.03502534329891205e-05, is {:e}", + msg.af0 + ); + assert!( + msg.af1.almost_eq(-9.09494701772928238e-13), + "incorrect value for af1, expected -9.09494701772928238e-13, is {:e}", + msg.af1 + ); + assert!( + msg.af2.almost_eq(0.00000000000000000e+00), + "incorrect value for af2, expected 0.00000000000000000e+00, is {:e}", + msg.af2 + ); + assert!( + msg.c_ic.almost_eq(6.33299350738525391e-08), + "incorrect value for c_ic, expected 6.33299350738525391e-08, is {:e}", + msg.c_ic + ); + assert!( + msg.c_is.almost_eq(-1.56462192535400391e-07), + "incorrect value for c_is, expected -1.56462192535400391e-07, is {:e}", + msg.c_is + ); + assert!( + msg.c_rc.almost_eq(2.34375000000000000e+02), + "incorrect value for c_rc, expected 2.34375000000000000e+02, is {:e}", + msg.c_rc + ); + assert!( + msg.c_rs.almost_eq(-7.49062500000000000e+01), + "incorrect value for c_rs, expected -7.49062500000000000e+01, is {:e}", + msg.c_rs + ); + assert!( + msg.c_uc.almost_eq(-3.93763184547424316e-06), + "incorrect value for c_uc, expected -3.93763184547424316e-06, is {:e}", + msg.c_uc + ); + assert!( + msg.c_us.almost_eq(6.91227614879608154e-06), + "incorrect value for c_us, expected 6.91227614879608154e-06, is {:e}", + msg.c_us + ); + assert!( + msg.dn.almost_eq(4.88841790794180047e-09), + "incorrect value for dn, expected 4.88841790794180047e-09, is {:e}", + msg.dn + ); + assert!( + msg.ecc.almost_eq(1.11326099140569568e-02), + "incorrect value for ecc, expected 1.11326099140569568e-02, is {:e}", + msg.ecc + ); + assert_eq!( + msg.healthy, 1, + "incorrect value for healthy, expected 1, is {}", + msg.healthy + ); + assert!( + msg.inc.almost_eq(9.39552483057908727e-01), + "incorrect value for inc, expected 9.39552483057908727e-01, is {:e}", + msg.inc + ); + assert!( + msg.inc_dot.almost_eq(-3.29656588662985413e-10), + "incorrect value for inc_dot, expected -3.29656588662985413e-10, is {:e}", + msg.inc_dot + ); + assert_eq!( + msg.iode, 0, + "incorrect value for iode, expected 0, is {}", + msg.iode + ); + assert!( + msg.m0.almost_eq(2.46734839562723884e+00), + "incorrect value for m0, expected 2.46734839562723884e+00, is {:e}", + msg.m0 + ); + assert!( + msg.omega0.almost_eq(-9.46898543747965782e-01), + "incorrect value for omega0, expected -9.46898543747965782e-01, is {:e}", + msg.omega0 + ); + assert!( + msg.omegadot.almost_eq(-8.20105589261047769e-09), + "incorrect value for omegadot, expected -8.20105589261047769e-09, is {:e}", + msg.omegadot + ); + assert_eq!( + msg.prn, 3, + "incorrect value for prn, expected 3, is {}", + msg.prn + ); + assert!( + msg.sqrta.almost_eq(5.15371430397033691e+03), + "incorrect value for sqrta, expected 5.15371430397033691e+03, is {:e}", + msg.sqrta + ); + assert!( + msg.tgd.almost_eq(-6.51925802230834961e-09), + "incorrect value for tgd, expected -6.51925802230834961e-09, is {:e}", + msg.tgd + ); + assert!( + msg.toc_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toc_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toc_tow + ); + assert_eq!( + msg.toc_wn, 1838, + "incorrect value for toc_wn, expected 1838, is {}", + msg.toc_wn + ); + assert!( + msg.toe_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toe_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toe_tow + ); + assert_eq!( + msg.toe_wn, 1838, + "incorrect value for toe_wn, expected 1838, is {}", + msg.toe_wn + ); + assert_eq!( + msg.valid, 1, + "incorrect value for valid, expected 1, is {}", + msg.valid + ); + assert!( + msg.w.almost_eq(1.05250472004053020e+00), + "incorrect value for w, expected 1.05250472004053020e+00, is {:e}", + msg.w + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgEphemerisDepB"), + }; + } + { + use sbp::messages::observation::MsgEphemerisDepB; + let payload: Vec = vec![ + 85, 70, 0, 195, 4, 176, 0, 0, 0, 0, 0, 0, 68, 190, 0, 0, 0, 0, 0, 72, 66, 64, 0, 0, 0, + 0, 128, 188, 115, 64, 0, 0, 0, 0, 0, 80, 193, 62, 0, 0, 0, 0, 0, 164, 204, 62, 0, 0, 0, + 0, 0, 0, 130, 62, 0, 0, 0, 0, 0, 0, 128, 62, 72, 181, 127, 6, 208, 225, 52, 62, 158, + 174, 129, 91, 27, 105, 249, 191, 0, 0, 0, 96, 204, 57, 128, 63, 0, 0, 160, 35, 146, 33, + 180, 64, 247, 169, 1, 36, 133, 206, 243, 63, 79, 11, 109, 92, 156, 208, 65, 190, 103, + 78, 3, 253, 223, 147, 255, 191, 164, 214, 90, 250, 218, 240, 238, 63, 94, 239, 187, 37, + 36, 10, 242, 61, 0, 0, 0, 0, 176, 91, 19, 63, 0, 0, 0, 0, 0, 0, 137, 189, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 1, + 1, 13, 0, 180, 21, + ]; + + assert_eq!( + MsgEphemerisDepB::MSG_ID, + 0x46, + "Incorrect message type, expected 0x46, is {}", + MsgEphemerisDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgEphemerisDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.af0.almost_eq(7.38454982638359070e-05), + "incorrect value for af0, expected 7.38454982638359070e-05, is {:e}", + msg.af0 + ); + assert!( + msg.af1.almost_eq(-2.84217094304040074e-12), + "incorrect value for af1, expected -2.84217094304040074e-12, is {:e}", + msg.af1 + ); + assert!( + msg.af2.almost_eq(0.00000000000000000e+00), + "incorrect value for af2, expected 0.00000000000000000e+00, is {:e}", + msg.af2 + ); + assert!( + msg.c_ic.almost_eq(1.34110450744628906e-07), + "incorrect value for c_ic, expected 1.34110450744628906e-07, is {:e}", + msg.c_ic + ); + assert!( + msg.c_is.almost_eq(1.19209289550781250e-07), + "incorrect value for c_is, expected 1.19209289550781250e-07, is {:e}", + msg.c_is + ); + assert!( + msg.c_rc.almost_eq(3.15781250000000000e+02), + "incorrect value for c_rc, expected 3.15781250000000000e+02, is {:e}", + msg.c_rc + ); + assert!( + msg.c_rs.almost_eq(3.65625000000000000e+01), + "incorrect value for c_rs, expected 3.65625000000000000e+01, is {:e}", + msg.c_rs + ); + assert!( + msg.c_uc.almost_eq(2.06381082534790039e-06), + "incorrect value for c_uc, expected 2.06381082534790039e-06, is {:e}", + msg.c_uc + ); + assert!( + msg.c_us.almost_eq(3.41422855854034424e-06), + "incorrect value for c_us, expected 3.41422855854034424e-06, is {:e}", + msg.c_us + ); + assert!( + msg.dn.almost_eq(4.86198823561129038e-09), + "incorrect value for dn, expected 4.86198823561129038e-09, is {:e}", + msg.dn + ); + assert!( + msg.ecc.almost_eq(7.92274158447980881e-03), + "incorrect value for ecc, expected 7.92274158447980881e-03, is {:e}", + msg.ecc + ); + assert_eq!( + msg.healthy, 1, + "incorrect value for healthy, expected 1, is {}", + msg.healthy + ); + assert!( + msg.inc.almost_eq(9.66901291822712228e-01), + "incorrect value for inc, expected 9.66901291822712228e-01, is {:e}", + msg.inc + ); + assert!( + msg.inc_dot.almost_eq(2.62510934634121662e-10), + "incorrect value for inc_dot, expected 2.62510934634121662e-10, is {:e}", + msg.inc_dot + ); + assert_eq!( + msg.iode, 0, + "incorrect value for iode, expected 0, is {}", + msg.iode + ); + assert!( + msg.m0.almost_eq(-1.58816085572008303e+00), + "incorrect value for m0, expected -1.58816085572008303e+00, is {:e}", + msg.m0 + ); + assert!( + msg.omega0.almost_eq(1.23791994156874607e+00), + "incorrect value for omega0, expected 1.23791994156874607e+00, is {:e}", + msg.omega0 + ); + assert!( + msg.omegadot.almost_eq(-8.29570269217244098e-09), + "incorrect value for omegadot, expected -8.29570269217244098e-09, is {:e}", + msg.omegadot + ); + assert_eq!( + msg.prn, 13, + "incorrect value for prn, expected 13, is {}", + msg.prn + ); + assert!( + msg.sqrta.almost_eq(5.15357085609436035e+03), + "incorrect value for sqrta, expected 5.15357085609436035e+03, is {:e}", + msg.sqrta + ); + assert!( + msg.tgd.almost_eq(-9.31322574615478516e-09), + "incorrect value for tgd, expected -9.31322574615478516e-09, is {:e}", + msg.tgd + ); + assert!( + msg.toc_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toc_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toc_tow + ); + assert_eq!( + msg.toc_wn, 1838, + "incorrect value for toc_wn, expected 1838, is {}", + msg.toc_wn + ); + assert!( + msg.toe_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toe_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toe_tow + ); + assert_eq!( + msg.toe_wn, 1838, + "incorrect value for toe_wn, expected 1838, is {}", + msg.toe_wn + ); + assert_eq!( + msg.valid, 1, + "incorrect value for valid, expected 1, is {}", + msg.valid + ); + assert!( + msg.w.almost_eq(-1.97360228379411651e+00), + "incorrect value for w, expected -1.97360228379411651e+00, is {:e}", + msg.w + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgEphemerisDepB"), + }; + } + { + use sbp::messages::observation::MsgEphemerisDepB; + let payload: Vec = vec![ + 85, 70, 0, 195, 4, 176, 0, 0, 0, 0, 0, 0, 56, 62, 0, 0, 0, 0, 0, 40, 81, 192, 0, 0, 0, + 0, 0, 129, 109, 64, 0, 0, 0, 0, 0, 28, 205, 190, 0, 0, 0, 0, 0, 76, 223, 62, 0, 0, 0, + 0, 0, 0, 105, 190, 0, 0, 0, 0, 0, 0, 92, 190, 134, 161, 223, 255, 243, 43, 51, 62, 146, + 176, 113, 142, 234, 164, 5, 64, 0, 0, 0, 56, 175, 140, 112, 63, 0, 0, 192, 90, 171, 33, + 180, 64, 36, 38, 237, 255, 200, 160, 237, 191, 204, 92, 63, 154, 49, 91, 65, 190, 125, + 94, 251, 132, 52, 61, 216, 63, 2, 139, 28, 27, 231, 199, 238, 63, 124, 183, 4, 180, + 194, 30, 247, 189, 0, 0, 0, 0, 0, 104, 222, 190, 0, 0, 0, 0, 0, 0, 96, 61, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 1, + 1, 0, 0, 222, 152, + ]; + + assert_eq!( + MsgEphemerisDepB::MSG_ID, + 0x46, + "Incorrect message type, expected 0x46, is {}", + MsgEphemerisDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgEphemerisDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.af0.almost_eq(-7.24941492080688477e-06), + "incorrect value for af0, expected -7.24941492080688477e-06, is {:e}", + msg.af0 + ); + assert!( + msg.af1.almost_eq(4.54747350886464119e-13), + "incorrect value for af1, expected 4.54747350886464119e-13, is {:e}", + msg.af1 + ); + assert!( + msg.af2.almost_eq(0.00000000000000000e+00), + "incorrect value for af2, expected 0.00000000000000000e+00, is {:e}", + msg.af2 + ); + assert!( + msg.c_ic.almost_eq(-4.65661287307739258e-08), + "incorrect value for c_ic, expected -4.65661287307739258e-08, is {:e}", + msg.c_ic + ); + assert!( + msg.c_is.almost_eq(-2.60770320892333984e-08), + "incorrect value for c_is, expected -2.60770320892333984e-08, is {:e}", + msg.c_is + ); + assert!( + msg.c_rc.almost_eq(2.36031250000000000e+02), + "incorrect value for c_rc, expected 2.36031250000000000e+02, is {:e}", + msg.c_rc + ); + assert!( + msg.c_rs.almost_eq(-6.86250000000000000e+01), + "incorrect value for c_rs, expected -6.86250000000000000e+01, is {:e}", + msg.c_rs + ); + assert!( + msg.c_uc.almost_eq(-3.47010791301727295e-06), + "incorrect value for c_uc, expected -3.47010791301727295e-06, is {:e}", + msg.c_uc + ); + assert!( + msg.c_us.almost_eq(7.46175646781921387e-06), + "incorrect value for c_us, expected 7.46175646781921387e-06, is {:e}", + msg.c_us + ); + assert!( + msg.dn.almost_eq(4.46375736198265652e-09), + "incorrect value for dn, expected 4.46375736198265652e-09, is {:e}", + msg.dn + ); + assert!( + msg.ecc.almost_eq(4.04041714500635862e-03), + "incorrect value for ecc, expected 4.04041714500635862e-03, is {:e}", + msg.ecc + ); + assert_eq!( + msg.healthy, 1, + "incorrect value for healthy, expected 1, is {}", + msg.healthy + ); + assert!( + msg.inc.almost_eq(9.61902192070141604e-01), + "incorrect value for inc, expected 9.61902192070141604e-01, is {:e}", + msg.inc + ); + assert!( + msg.inc_dot.almost_eq(-3.36442585612711049e-10), + "incorrect value for inc_dot, expected -3.36442585612711049e-10, is {:e}", + msg.inc_dot + ); + assert_eq!( + msg.iode, 0, + "incorrect value for iode, expected 0, is {}", + msg.iode + ); + assert!( + msg.m0.almost_eq(2.70552550587132945e+00), + "incorrect value for m0, expected 2.70552550587132945e+00, is {:e}", + msg.m0 + ); + assert!( + msg.omega0.almost_eq(-9.25877094131639655e-01), + "incorrect value for omega0, expected -9.25877094131639655e-01, is {:e}", + msg.omega0 + ); + assert!( + msg.omegadot.almost_eq(-8.08212236712318227e-09), + "incorrect value for omegadot, expected -8.08212236712318227e-09, is {:e}", + msg.omegadot + ); + assert_eq!( + msg.prn, 0, + "incorrect value for prn, expected 0, is {}", + msg.prn + ); + assert!( + msg.sqrta.almost_eq(5.15366935348510742e+03), + "incorrect value for sqrta, expected 5.15366935348510742e+03, is {:e}", + msg.sqrta + ); + assert!( + msg.tgd.almost_eq(5.58793544769287109e-09), + "incorrect value for tgd, expected 5.58793544769287109e-09, is {:e}", + msg.tgd + ); + assert!( + msg.toc_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toc_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toc_tow + ); + assert_eq!( + msg.toc_wn, 1838, + "incorrect value for toc_wn, expected 1838, is {}", + msg.toc_wn + ); + assert!( + msg.toe_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toe_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toe_tow + ); + assert_eq!( + msg.toe_wn, 1838, + "incorrect value for toe_wn, expected 1838, is {}", + msg.toe_wn + ); + assert_eq!( + msg.valid, 1, + "incorrect value for valid, expected 1, is {}", + msg.valid + ); + assert!( + msg.w.almost_eq(3.78735666146418570e-01), + "incorrect value for w, expected 3.78735666146418570e-01, is {:e}", + msg.w + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgEphemerisDepB"), + }; + } + { + use sbp::messages::observation::MsgEphemerisDepB; + let payload: Vec = vec![ + 85, 70, 0, 195, 4, 176, 0, 0, 0, 0, 0, 0, 68, 190, 0, 0, 0, 0, 0, 72, 66, 64, 0, 0, 0, + 0, 128, 188, 115, 64, 0, 0, 0, 0, 0, 80, 193, 62, 0, 0, 0, 0, 0, 164, 204, 62, 0, 0, 0, + 0, 0, 0, 130, 62, 0, 0, 0, 0, 0, 0, 128, 62, 72, 181, 127, 6, 208, 225, 52, 62, 158, + 174, 129, 91, 27, 105, 249, 191, 0, 0, 0, 96, 204, 57, 128, 63, 0, 0, 160, 35, 146, 33, + 180, 64, 247, 169, 1, 36, 133, 206, 243, 63, 79, 11, 109, 92, 156, 208, 65, 190, 103, + 78, 3, 253, 223, 147, 255, 191, 164, 214, 90, 250, 218, 240, 238, 63, 94, 239, 187, 37, + 36, 10, 242, 61, 0, 0, 0, 0, 176, 91, 19, 63, 0, 0, 0, 0, 0, 0, 137, 189, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 1, + 1, 13, 0, 180, 21, + ]; + + assert_eq!( + MsgEphemerisDepB::MSG_ID, + 0x46, + "Incorrect message type, expected 0x46, is {}", + MsgEphemerisDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgEphemerisDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.af0.almost_eq(7.38454982638359070e-05), + "incorrect value for af0, expected 7.38454982638359070e-05, is {:e}", + msg.af0 + ); + assert!( + msg.af1.almost_eq(-2.84217094304040074e-12), + "incorrect value for af1, expected -2.84217094304040074e-12, is {:e}", + msg.af1 + ); + assert!( + msg.af2.almost_eq(0.00000000000000000e+00), + "incorrect value for af2, expected 0.00000000000000000e+00, is {:e}", + msg.af2 + ); + assert!( + msg.c_ic.almost_eq(1.34110450744628906e-07), + "incorrect value for c_ic, expected 1.34110450744628906e-07, is {:e}", + msg.c_ic + ); + assert!( + msg.c_is.almost_eq(1.19209289550781250e-07), + "incorrect value for c_is, expected 1.19209289550781250e-07, is {:e}", + msg.c_is + ); + assert!( + msg.c_rc.almost_eq(3.15781250000000000e+02), + "incorrect value for c_rc, expected 3.15781250000000000e+02, is {:e}", + msg.c_rc + ); + assert!( + msg.c_rs.almost_eq(3.65625000000000000e+01), + "incorrect value for c_rs, expected 3.65625000000000000e+01, is {:e}", + msg.c_rs + ); + assert!( + msg.c_uc.almost_eq(2.06381082534790039e-06), + "incorrect value for c_uc, expected 2.06381082534790039e-06, is {:e}", + msg.c_uc + ); + assert!( + msg.c_us.almost_eq(3.41422855854034424e-06), + "incorrect value for c_us, expected 3.41422855854034424e-06, is {:e}", + msg.c_us + ); + assert!( + msg.dn.almost_eq(4.86198823561129038e-09), + "incorrect value for dn, expected 4.86198823561129038e-09, is {:e}", + msg.dn + ); + assert!( + msg.ecc.almost_eq(7.92274158447980881e-03), + "incorrect value for ecc, expected 7.92274158447980881e-03, is {:e}", + msg.ecc + ); + assert_eq!( + msg.healthy, 1, + "incorrect value for healthy, expected 1, is {}", + msg.healthy + ); + assert!( + msg.inc.almost_eq(9.66901291822712228e-01), + "incorrect value for inc, expected 9.66901291822712228e-01, is {:e}", + msg.inc + ); + assert!( + msg.inc_dot.almost_eq(2.62510934634121662e-10), + "incorrect value for inc_dot, expected 2.62510934634121662e-10, is {:e}", + msg.inc_dot + ); + assert_eq!( + msg.iode, 0, + "incorrect value for iode, expected 0, is {}", + msg.iode + ); + assert!( + msg.m0.almost_eq(-1.58816085572008303e+00), + "incorrect value for m0, expected -1.58816085572008303e+00, is {:e}", + msg.m0 + ); + assert!( + msg.omega0.almost_eq(1.23791994156874607e+00), + "incorrect value for omega0, expected 1.23791994156874607e+00, is {:e}", + msg.omega0 + ); + assert!( + msg.omegadot.almost_eq(-8.29570269217244098e-09), + "incorrect value for omegadot, expected -8.29570269217244098e-09, is {:e}", + msg.omegadot + ); + assert_eq!( + msg.prn, 13, + "incorrect value for prn, expected 13, is {}", + msg.prn + ); + assert!( + msg.sqrta.almost_eq(5.15357085609436035e+03), + "incorrect value for sqrta, expected 5.15357085609436035e+03, is {:e}", + msg.sqrta + ); + assert!( + msg.tgd.almost_eq(-9.31322574615478516e-09), + "incorrect value for tgd, expected -9.31322574615478516e-09, is {:e}", + msg.tgd + ); + assert!( + msg.toc_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toc_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toc_tow + ); + assert_eq!( + msg.toc_wn, 1838, + "incorrect value for toc_wn, expected 1838, is {}", + msg.toc_wn + ); + assert!( + msg.toe_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toe_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toe_tow + ); + assert_eq!( + msg.toe_wn, 1838, + "incorrect value for toe_wn, expected 1838, is {}", + msg.toe_wn + ); + assert_eq!( + msg.valid, 1, + "incorrect value for valid, expected 1, is {}", + msg.valid + ); + assert!( + msg.w.almost_eq(-1.97360228379411651e+00), + "incorrect value for w, expected -1.97360228379411651e+00, is {:e}", + msg.w + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgEphemerisDepB"), + }; + } + { + use sbp::messages::observation::MsgEphemerisDepB; + let payload: Vec = vec![ + 85, 70, 0, 195, 4, 176, 0, 0, 0, 0, 0, 128, 85, 190, 0, 0, 0, 0, 0, 156, 69, 64, 0, 0, + 0, 0, 128, 19, 115, 64, 0, 0, 0, 0, 0, 160, 193, 62, 0, 0, 0, 0, 0, 152, 207, 62, 0, 0, + 0, 0, 0, 0, 97, 190, 0, 0, 0, 0, 0, 192, 139, 190, 26, 26, 13, 149, 16, 152, 54, 62, + 104, 7, 46, 214, 75, 84, 5, 192, 0, 0, 0, 128, 230, 82, 132, 63, 0, 0, 160, 252, 162, + 33, 180, 64, 73, 6, 130, 54, 217, 171, 242, 63, 81, 224, 163, 123, 238, 42, 66, 190, + 206, 43, 141, 67, 243, 157, 5, 192, 113, 179, 153, 187, 43, 92, 238, 63, 254, 236, 31, + 43, 224, 157, 244, 61, 0, 0, 0, 0, 232, 4, 26, 191, 0, 0, 0, 0, 0, 0, 134, 189, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 0, 0, 0, 0, 128, 12, 25, 65, 46, + 7, 1, 1, 22, 0, 99, 61, + ]; + + assert_eq!( + MsgEphemerisDepB::MSG_ID, + 0x46, + "Incorrect message type, expected 0x46, is {}", + MsgEphemerisDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgEphemerisDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.af0.almost_eq(-9.92552377283573151e-05), + "incorrect value for af0, expected -9.92552377283573151e-05, is {:e}", + msg.af0 + ); + assert!( + msg.af1.almost_eq(-2.50111042987555265e-12), + "incorrect value for af1, expected -2.50111042987555265e-12, is {:e}", + msg.af1 + ); + assert!( + msg.af2.almost_eq(0.00000000000000000e+00), + "incorrect value for af2, expected 0.00000000000000000e+00, is {:e}", + msg.af2 + ); + assert!( + msg.c_ic.almost_eq(-3.16649675369262695e-08), + "incorrect value for c_ic, expected -3.16649675369262695e-08, is {:e}", + msg.c_ic + ); + assert!( + msg.c_is.almost_eq(-2.06753611564636230e-07), + "incorrect value for c_is, expected -2.06753611564636230e-07, is {:e}", + msg.c_is + ); + assert!( + msg.c_rc.almost_eq(3.05218750000000000e+02), + "incorrect value for c_rc, expected 3.05218750000000000e+02, is {:e}", + msg.c_rc + ); + assert!( + msg.c_rs.almost_eq(4.32187500000000000e+01), + "incorrect value for c_rs, expected 4.32187500000000000e+01, is {:e}", + msg.c_rs + ); + assert!( + msg.c_uc.almost_eq(2.10106372833251953e-06), + "incorrect value for c_uc, expected 2.10106372833251953e-06, is {:e}", + msg.c_uc + ); + assert!( + msg.c_us.almost_eq(3.76626849174499512e-06), + "incorrect value for c_us, expected 3.76626849174499512e-06, is {:e}", + msg.c_us + ); + assert!( + msg.dn.almost_eq(5.26057626697411973e-09), + "incorrect value for dn, expected 5.26057626697411973e-09, is {:e}", + msg.dn + ); + assert!( + msg.ecc.almost_eq(9.92374494671821594e-03), + "incorrect value for ecc, expected 9.92374494671821594e-03, is {:e}", + msg.ecc + ); + assert_eq!( + msg.healthy, 1, + "incorrect value for healthy, expected 1, is {}", + msg.healthy + ); + assert!( + msg.inc.almost_eq(9.48751322180767187e-01), + "incorrect value for inc, expected 9.48751322180767187e-01, is {:e}", + msg.inc + ); + assert!( + msg.inc_dot.almost_eq(3.00012496724710486e-10), + "incorrect value for inc_dot, expected 3.00012496724710486e-10, is {:e}", + msg.inc_dot + ); + assert_eq!( + msg.iode, 0, + "incorrect value for iode, expected 0, is {}", + msg.iode + ); + assert!( + msg.m0.almost_eq(-2.66616027191132687e+00), + "incorrect value for m0, expected -2.66616027191132687e+00, is {:e}", + msg.m0 + ); + assert!( + msg.omega0.almost_eq(1.16695519725944252e+00), + "incorrect value for omega0, expected 1.16695519725944252e+00, is {:e}", + msg.omega0 + ); + assert!( + msg.omegadot.almost_eq(-8.45999524990263948e-09), + "incorrect value for omegadot, expected -8.45999524990263948e-09, is {:e}", + msg.omegadot + ); + assert_eq!( + msg.prn, 22, + "incorrect value for prn, expected 22, is {}", + msg.prn + ); + assert!( + msg.sqrta.almost_eq(5.15363666725158691e+03), + "incorrect value for sqrta, expected 5.15363666725158691e+03, is {:e}", + msg.sqrta + ); + assert!( + msg.tgd.almost_eq(-2.00234353542327881e-08), + "incorrect value for tgd, expected -2.00234353542327881e-08, is {:e}", + msg.tgd + ); + assert!( + msg.toc_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toc_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toc_tow + ); + assert_eq!( + msg.toc_wn, 1838, + "incorrect value for toc_wn, expected 1838, is {}", + msg.toc_wn + ); + assert!( + msg.toe_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toe_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toe_tow + ); + assert_eq!( + msg.toe_wn, 1838, + "incorrect value for toe_wn, expected 1838, is {}", + msg.toe_wn + ); + assert_eq!( + msg.valid, 1, + "incorrect value for valid, expected 1, is {}", + msg.valid + ); + assert!( + msg.w.almost_eq(-2.70212414526529354e+00), + "incorrect value for w, expected -2.70212414526529354e+00, is {:e}", + msg.w + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgEphemerisDepB"), + }; + } + { + use sbp::messages::observation::MsgEphemerisDepB; + let payload: Vec = vec![ + 85, 70, 0, 195, 4, 176, 0, 0, 0, 0, 0, 0, 77, 190, 0, 0, 0, 0, 0, 122, 83, 192, 0, 0, + 0, 0, 0, 233, 110, 64, 0, 0, 0, 0, 0, 60, 207, 190, 0, 0, 0, 0, 0, 28, 222, 62, 0, 0, + 0, 0, 0, 128, 120, 62, 0, 0, 0, 0, 0, 0, 108, 62, 10, 230, 183, 140, 214, 230, 50, 62, + 54, 86, 196, 164, 252, 10, 255, 63, 0, 0, 0, 36, 247, 191, 128, 63, 0, 0, 160, 5, 193, + 33, 180, 64, 186, 138, 81, 129, 88, 239, 1, 64, 94, 210, 120, 170, 106, 25, 65, 190, + 103, 213, 32, 155, 227, 194, 224, 191, 156, 47, 104, 93, 101, 55, 239, 63, 196, 83, + 100, 254, 51, 54, 4, 190, 0, 0, 0, 0, 50, 242, 52, 63, 0, 0, 0, 0, 0, 0, 114, 189, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 12, 25, 65, 46, 7, 0, 0, 0, 0, 128, 12, 25, 65, + 46, 7, 1, 1, 30, 0, 170, 33, + ]; + + assert_eq!( + MsgEphemerisDepB::MSG_ID, + 0x46, + "Incorrect message type, expected 0x46, is {}", + MsgEphemerisDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgEphemerisDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.af0.almost_eq(3.19611746817827225e-04), + "incorrect value for af0, expected 3.19611746817827225e-04, is {:e}", + msg.af0 + ); + assert!( + msg.af1.almost_eq(-1.02318153949454427e-12), + "incorrect value for af1, expected -1.02318153949454427e-12, is {:e}", + msg.af1 + ); + assert!( + msg.af2.almost_eq(0.00000000000000000e+00), + "incorrect value for af2, expected 0.00000000000000000e+00, is {:e}", + msg.af2 + ); + assert!( + msg.c_ic.almost_eq(9.12696123123168945e-08), + "incorrect value for c_ic, expected 9.12696123123168945e-08, is {:e}", + msg.c_ic + ); + assert!( + msg.c_is.almost_eq(5.21540641784667969e-08), + "incorrect value for c_is, expected 5.21540641784667969e-08, is {:e}", + msg.c_is + ); + assert!( + msg.c_rc.almost_eq(2.47281250000000000e+02), + "incorrect value for c_rc, expected 2.47281250000000000e+02, is {:e}", + msg.c_rc + ); + assert!( + msg.c_rs.almost_eq(-7.79062500000000000e+01), + "incorrect value for c_rs, expected -7.79062500000000000e+01, is {:e}", + msg.c_rs + ); + assert!( + msg.c_uc.almost_eq(-3.72342765331268311e-06), + "incorrect value for c_uc, expected -3.72342765331268311e-06, is {:e}", + msg.c_uc + ); + assert!( + msg.c_us.almost_eq(7.17863440513610840e-06), + "incorrect value for c_us, expected 7.17863440513610840e-06, is {:e}", + msg.c_us + ); + assert!( + msg.dn.almost_eq(4.40089760076414576e-09), + "incorrect value for dn, expected 4.40089760076414576e-09, is {:e}", + msg.dn + ); + assert!( + msg.ecc.almost_eq(8.17864493001252413e-03), + "incorrect value for ecc, expected 8.17864493001252413e-03, is {:e}", + msg.ecc + ); + assert_eq!( + msg.healthy, 1, + "incorrect value for healthy, expected 1, is {}", + msg.healthy + ); + assert!( + msg.inc.almost_eq(9.75512201724530126e-01), + "incorrect value for inc, expected 9.75512201724530126e-01, is {:e}", + msg.inc + ); + assert!( + msg.inc_dot.almost_eq(-5.88238788220950205e-10), + "incorrect value for inc_dot, expected -5.88238788220950205e-10, is {:e}", + msg.inc_dot + ); + assert_eq!( + msg.iode, 0, + "incorrect value for iode, expected 0, is {}", + msg.iode + ); + assert!( + msg.m0.almost_eq(1.94018234598241923e+00), + "incorrect value for m0, expected 1.94018234598241923e+00, is {:e}", + msg.m0 + ); + assert!( + msg.omega0.almost_eq(2.24186802892776615e+00), + "incorrect value for omega0, expected 2.24186802892776615e+00, is {:e}", + msg.omega0 + ); + assert!( + msg.omegadot.almost_eq(-7.96247452616749420e-09), + "incorrect value for omegadot, expected -7.96247452616749420e-09, is {:e}", + msg.omegadot + ); + assert_eq!( + msg.prn, 30, + "incorrect value for prn, expected 30, is {}", + msg.prn + ); + assert!( + msg.sqrta.almost_eq(5.15375399208068848e+03), + "incorrect value for sqrta, expected 5.15375399208068848e+03, is {:e}", + msg.sqrta + ); + assert!( + msg.tgd.almost_eq(-1.35041773319244385e-08), + "incorrect value for tgd, expected -1.35041773319244385e-08, is {:e}", + msg.tgd + ); + assert!( + msg.toc_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toc_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toc_tow + ); + assert_eq!( + msg.toc_wn, 1838, + "incorrect value for toc_wn, expected 1838, is {}", + msg.toc_wn + ); + assert!( + msg.toe_tow.almost_eq(4.10400000000000000e+05), + "incorrect value for toe_tow, expected 4.10400000000000000e+05, is {:e}", + msg.toe_tow + ); + assert_eq!( + msg.toe_wn, 1838, + "incorrect value for toe_wn, expected 1838, is {}", + msg.toe_wn + ); + assert_eq!( + msg.valid, 1, + "incorrect value for valid, expected 1, is {}", + msg.valid + ); + assert!( + msg.w.almost_eq(-5.23790171608806143e-01), + "incorrect value for w, expected -5.23790171608806143e-01, is {:e}", + msg.w + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgEphemerisDepB"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_orientation_27.rs b/rust/sbp/tests/auto_check_sbp_orientation_27.rs new file mode 100644 index 0000000000..4ed7c448d4 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_orientation_27.rs @@ -0,0 +1,82 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/orientation/test_MsgAngularRate.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_orientation_27() { + { + use sbp::messages::orientation::MsgAngularRate; + let payload: Vec = vec![ + 85, 34, 2, 66, 0, 17, 2, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 0, 0, 88, 70, + ]; + + assert_eq!( + MsgAngularRate::MSG_ID, + 0x222, + "Incorrect message type, expected 0x222, is {}", + MsgAngularRate::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgAngularRate(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.tow, 2, + "incorrect value for tow, expected 2, is {}", + msg.tow + ); + assert_eq!(msg.x, 2, "incorrect value for x, expected 2, is {}", msg.x); + assert_eq!(msg.y, 5, "incorrect value for y, expected 5, is {}", msg.y); + assert_eq!(msg.z, 2, "incorrect value for z, expected 2, is {}", msg.z); + } + _ => assert!(false, "Invalid message type! Expected a MsgAngularRate"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_orientation_28.rs b/rust/sbp/tests/auto_check_sbp_orientation_28.rs new file mode 100644 index 0000000000..96305c319f --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_orientation_28.rs @@ -0,0 +1,110 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientEuler.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_orientation_28() { + { + use sbp::messages::orientation::MsgOrientEuler; + let payload: Vec = vec![ + 85, 33, 2, 66, 0, 29, 1, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 0, 0, 224, 64, 0, + 0, 64, 64, 0, 0, 224, 64, 3, 44, 226, + ]; + + assert_eq!( + MsgOrientEuler::MSG_ID, + 0x221, + "Incorrect message type, expected 0x221, is {}", + MsgOrientEuler::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgOrientEuler(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.flags, 3, + "incorrect value for flags, expected 3, is {}", + msg.flags + ); + assert_eq!( + msg.pitch, 2, + "incorrect value for pitch, expected 2, is {}", + msg.pitch + ); + assert!( + msg.pitch_accuracy.almost_eq(3.00000000000000000e+00), + "incorrect value for pitch_accuracy, expected 3.00000000000000000e+00, is {:e}", + msg.pitch_accuracy + ); + assert_eq!( + msg.roll, 1, + "incorrect value for roll, expected 1, is {}", + msg.roll + ); + assert!( + msg.roll_accuracy.almost_eq(7.00000000000000000e+00), + "incorrect value for roll_accuracy, expected 7.00000000000000000e+00, is {:e}", + msg.roll_accuracy + ); + assert_eq!( + msg.tow, 1, + "incorrect value for tow, expected 1, is {}", + msg.tow + ); + assert_eq!( + msg.yaw, 8, + "incorrect value for yaw, expected 8, is {}", + msg.yaw + ); + assert!( + msg.yaw_accuracy.almost_eq(7.00000000000000000e+00), + "incorrect value for yaw_accuracy, expected 7.00000000000000000e+00, is {:e}", + msg.yaw_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgOrientEuler"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_orientation_29.rs b/rust/sbp/tests/auto_check_sbp_orientation_29.rs new file mode 100644 index 0000000000..5f841e442d --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_orientation_29.rs @@ -0,0 +1,104 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientQuat.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_orientation_29() { + { + use sbp::messages::orientation::MsgOrientQuat; + let payload: Vec = vec![ + 85, 32, 2, 66, 0, 37, 0, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 4, 0, 0, 0, 0, 0, + 64, 64, 0, 0, 128, 64, 0, 0, 0, 65, 0, 0, 64, 64, 1, 186, 6, + ]; + + assert_eq!( + MsgOrientQuat::MSG_ID, + 0x220, + "Incorrect message type, expected 0x220, is {}", + MsgOrientQuat::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgOrientQuat(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.tow, 0, + "incorrect value for tow, expected 0, is {}", + msg.tow + ); + assert_eq!(msg.w, 3, "incorrect value for w, expected 3, is {}", msg.w); + assert!( + msg.w_accuracy.almost_eq(3.00000000000000000e+00), + "incorrect value for w_accuracy, expected 3.00000000000000000e+00, is {:e}", + msg.w_accuracy + ); + assert_eq!(msg.x, 7, "incorrect value for x, expected 7, is {}", msg.x); + assert!( + msg.x_accuracy.almost_eq(4.00000000000000000e+00), + "incorrect value for x_accuracy, expected 4.00000000000000000e+00, is {:e}", + msg.x_accuracy + ); + assert_eq!(msg.y, 8, "incorrect value for y, expected 8, is {}", msg.y); + assert!( + msg.y_accuracy.almost_eq(8.00000000000000000e+00), + "incorrect value for y_accuracy, expected 8.00000000000000000e+00, is {:e}", + msg.y_accuracy + ); + assert_eq!(msg.z, 4, "incorrect value for z, expected 4, is {}", msg.z); + assert!( + msg.z_accuracy.almost_eq(3.00000000000000000e+00), + "incorrect value for z_accuracy, expected 3.00000000000000000e+00, is {:e}", + msg.z_accuracy + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgOrientQuat"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_piksi_30.rs b/rust/sbp/tests/auto_check_sbp_piksi_30.rs new file mode 100644 index 0000000000..0f2e78eb56 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_piksi_30.rs @@ -0,0 +1,72 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/piksi/test_MsgIarState.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_piksi_30() { + { + use sbp::messages::piksi::MsgIarState; + let payload: Vec = vec![85, 25, 0, 246, 215, 4, 1, 0, 0, 0, 216, 140]; + + assert_eq!( + MsgIarState::MSG_ID, + 0x19, + "Incorrect message type, expected 0x19, is {}", + MsgIarState::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgIarState(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.num_hyps, 1, + "incorrect value for num_hyps, expected 1, is {}", + msg.num_hyps + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgIarState"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_piksi_31.rs b/rust/sbp/tests/auto_check_sbp_piksi_31.rs new file mode 100644 index 0000000000000000000000000000000000000000..210a6b1ae48bfb54c91651e0285971e7a5a27dba GIT binary patch literal 10187 zcmeHNZExC05bkGw#e|a@=n;b<5aP7a5pY}UcoUHJs;WYcy?`%ZQ?JR3+WhyMS;ucc zjwY8}Ditfj>-Eetvpci%c zc@qQ(?MYCZPQelP#4tIyj5GIwnKT;V-FvMM^-e>DTDt*S`)#M!stvSG8?e9I>wM4} zY6H@>K3=Ecqc(WoIUT^qTCZ1Y4?aQXE$V%OKecuvM{p_%s69~s>h{!rA2mBY&|2N5 zrZ#ejUT>Z@wDvnVL5y~108Oo>4Nz*(0n`g53Fy{>ruNB3OYPO)qruvV*3{4}`kF`N zx7whMW&oXr8gy&DfmT0l)_TxA?R7hSRZ58=(u9a9z0^7A3(wgbGn=_O&E3d#X29pn z$a{=?Jb$gvruiU@d44v}&#iNAiMzuV9}gxj)6Kqz$`Z-K*);@c()?P2h6A?a!OStO z(KX$j=(f3&O0g@Cxi%PN77+I+wZO1rLs4dobA8OXqV!L?E&t*umGWHO@-TukhkNQ* z_?7}ZMmFf8XUM*0IGc`g;7&N^BQ~?JcMNBaGd)V(q*B&wK8>_Tjtiqw@jfWGvSih8 zZ0^Bnv#SV@H&B)eN5UVvn-Pw{9(j_L^fR8x!s|DX;hw1|XjD_5V25#(N@t?WPkXbCep+TT7?wth)rHc(?o zNj)?s%s3xnMh!*E4ofn|!Ot51mnL>i(g|s_kVx(*x>M%CT)&<=x~aeiX1rchk8w^e zn6dLY5wmJJ2gOnj3V7PD;Ezll*pLf{IXFC^2KLA@3jFY2!a`h2E+aDH`h5pzS1wg^ zq4*bEKr~)DbdEL8!v(XG3Hzu&IbxiF{=1=ub&T!>N8w67NcN@tH!g24$TJ{}?|ET$eR`SOxDWnL2A%iGX@mZUE+O@B&vGP6)y zviQ(B&tzjl1W)ORLWms`UD%hdK974c(>Gl@Q6ra=mE6d}o8wr;iVu-9 z+hp$0GJP*3WXoaLm&r=2?gZL*WlnHEM8Q0~G7mJd_jw61&%Oc{$A+Q1wEa(AQYk;&;6^rw-#2=ALy*D&)6NV z&UDLuv2>&*EQj=bWREl1JM^NEL_;L6g{f#Q`zWyc?Pgbum>NrqI+*qJ16>KMKGtM$ zd_p}Rj$DQ{2@COkVjNcuLoF~iMmtj7G>)5uz>wB$P)Pw|N9Sib}U*3EpQ6YIA-XppzAVbN8D*ea-UB!v)j&@>_e3>eeTrmeFB)(8dE+c3$ z7UM1P(IfSi_yqZGi7zP5{y8MR@?rTNypW_m(%o1NQ6;g0$^PS$pJh(j68F7$Ch~ir zD^E#&SSVLwKyg_6coXqg?8%Hu?Yif9LZO4aj}%voEd~6SA-)4-y9zFnD$-O58H;vj zL|#>FhsPo{9Dz=*m;lo-FUj_5(qH>AW_`5r4&qPhf0}cBHzJ zQ@<+p5zSSQnTY!C|Cg9Xf43+fBAOh&=sZMFxpEjS;w|lMX^+cJ^VJ9AUwKwCenMLD^E#!^q3Py4kYdmi=h4Z`m(i@^0H9`z?LJ z4n%)|{cySc99zDbZsWhmfNp$^Nbs51?}4s7CHoai#ry2**Rr3$*ck0dHBq)HrJiTY Hca!=DDQxc_ literal 0 HcmV?d00001 diff --git a/rust/sbp/tests/auto_check_sbp_piksi_32.rs b/rust/sbp/tests/auto_check_sbp_piksi_32.rs new file mode 100644 index 0000000000..4894d1b1c8 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_piksi_32.rs @@ -0,0 +1,275 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/piksi/test_MsgUartState.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_piksi_32() { + { + use sbp::messages::piksi::MsgUartStateDepa; + let payload: Vec = vec![ + 85, 24, 0, 246, 215, 58, 26, 191, 93, 63, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 123, 50, 62, + 64, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 54, 7, 162, 64, 177, 57, 16, 61, 0, 0, 0, 0, 81, 1, + 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 71, 124, + ]; + + assert_eq!( + MsgUartStateDepa::MSG_ID, + 0x18, + "Incorrect message type, expected 0x18, is {}", + MsgUartStateDepa::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgUartStateDepa(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.latency.avg, -1, + "incorrect value for latency.avg, expected -1, is {}", + msg.latency.avg + ); + assert_eq!( + msg.latency.current, -1, + "incorrect value for latency.current, expected -1, is {}", + msg.latency.current + ); + assert_eq!( + msg.latency.lmax, 0, + "incorrect value for latency.lmax, expected 0, is {}", + msg.latency.lmax + ); + assert_eq!( + msg.latency.lmin, 0, + "incorrect value for latency.lmin, expected 0, is {}", + msg.latency.lmin + ); + assert_eq!( + msg.uart_a.crc_error_count, 0, + "incorrect value for uart_a.crc_error_count, expected 0, is {}", + msg.uart_a.crc_error_count + ); + assert_eq!( + msg.uart_a.io_error_count, 0, + "incorrect value for uart_a.io_error_count, expected 0, is {}", + msg.uart_a.io_error_count + ); + assert_eq!( + msg.uart_a.rx_buffer_level, 0, + "incorrect value for uart_a.rx_buffer_level, expected 0, is {}", + msg.uart_a.rx_buffer_level + ); + assert!(msg.uart_a.rx_throughput.almost_eq( 0.00000000000000000e+00 ), "incorrect value for uart_a.rx_throughput, expected 0.00000000000000000e+00, is {:e}", msg.uart_a.rx_throughput); + assert_eq!( + msg.uart_a.tx_buffer_level, 24, + "incorrect value for uart_a.tx_buffer_level, expected 24, is {}", + msg.uart_a.tx_buffer_level + ); + assert!(msg.uart_a.tx_throughput.almost_eq( 8.66197228431701660e-01 ), "incorrect value for uart_a.tx_throughput, expected 8.66197228431701660e-01, is {:e}", msg.uart_a.tx_throughput); + assert_eq!( + msg.uart_b.crc_error_count, 0, + "incorrect value for uart_b.crc_error_count, expected 0, is {}", + msg.uart_b.crc_error_count + ); + assert_eq!( + msg.uart_b.io_error_count, 0, + "incorrect value for uart_b.io_error_count, expected 0, is {}", + msg.uart_b.io_error_count + ); + assert_eq!( + msg.uart_b.rx_buffer_level, 0, + "incorrect value for uart_b.rx_buffer_level, expected 0, is {}", + msg.uart_b.rx_buffer_level + ); + assert!(msg.uart_b.rx_throughput.almost_eq( 0.00000000000000000e+00 ), "incorrect value for uart_b.rx_throughput, expected 0.00000000000000000e+00, is {:e}", msg.uart_b.rx_throughput); + assert_eq!( + msg.uart_b.tx_buffer_level, 40, + "incorrect value for uart_b.tx_buffer_level, expected 40, is {}", + msg.uart_b.tx_buffer_level + ); + assert!(msg.uart_b.tx_throughput.almost_eq( 2.97183108329772949e+00 ), "incorrect value for uart_b.tx_throughput, expected 2.97183108329772949e+00, is {:e}", msg.uart_b.tx_throughput); + assert_eq!( + msg.uart_ftdi.crc_error_count, 0, + "incorrect value for uart_ftdi.crc_error_count, expected 0, is {}", + msg.uart_ftdi.crc_error_count + ); + assert_eq!( + msg.uart_ftdi.io_error_count, 0, + "incorrect value for uart_ftdi.io_error_count, expected 0, is {}", + msg.uart_ftdi.io_error_count + ); + assert_eq!( + msg.uart_ftdi.rx_buffer_level, 1, + "incorrect value for uart_ftdi.rx_buffer_level, expected 1, is {}", + msg.uart_ftdi.rx_buffer_level + ); + assert!(msg.uart_ftdi.rx_throughput.almost_eq( 3.52112688124179840e-02 ), "incorrect value for uart_ftdi.rx_throughput, expected 3.52112688124179840e-02, is {:e}", msg.uart_ftdi.rx_throughput); + assert_eq!( + msg.uart_ftdi.tx_buffer_level, 81, + "incorrect value for uart_ftdi.tx_buffer_level, expected 81, is {}", + msg.uart_ftdi.tx_buffer_level + ); + assert!(msg.uart_ftdi.tx_throughput.almost_eq( 5.06338024139404297e+00 ), "incorrect value for uart_ftdi.tx_throughput, expected 5.06338024139404297e+00, is {:e}", msg.uart_ftdi.tx_throughput); + } + _ => assert!(false, "Invalid message type! Expected a MsgUartStateDepa"), + }; + } + { + use sbp::messages::piksi::MsgUartStateDepa; + let payload: Vec = vec![ + 85, 24, 0, 246, 215, 58, 237, 232, 95, 63, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 198, 186, 63, + 64, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 214, 72, 217, 64, 29, 72, 180, 62, 0, 0, 0, 0, 85, + 1, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 153, 248, + ]; + + assert_eq!( + MsgUartStateDepa::MSG_ID, + 0x18, + "Incorrect message type, expected 0x18, is {}", + MsgUartStateDepa::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgUartStateDepa(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.latency.avg, -1, + "incorrect value for latency.avg, expected -1, is {}", + msg.latency.avg + ); + assert_eq!( + msg.latency.current, -1, + "incorrect value for latency.current, expected -1, is {}", + msg.latency.current + ); + assert_eq!( + msg.latency.lmax, 0, + "incorrect value for latency.lmax, expected 0, is {}", + msg.latency.lmax + ); + assert_eq!( + msg.latency.lmin, 0, + "incorrect value for latency.lmin, expected 0, is {}", + msg.latency.lmin + ); + assert_eq!( + msg.uart_a.crc_error_count, 0, + "incorrect value for uart_a.crc_error_count, expected 0, is {}", + msg.uart_a.crc_error_count + ); + assert_eq!( + msg.uart_a.io_error_count, 0, + "incorrect value for uart_a.io_error_count, expected 0, is {}", + msg.uart_a.io_error_count + ); + assert_eq!( + msg.uart_a.rx_buffer_level, 0, + "incorrect value for uart_a.rx_buffer_level, expected 0, is {}", + msg.uart_a.rx_buffer_level + ); + assert!(msg.uart_a.rx_throughput.almost_eq( 0.00000000000000000e+00 ), "incorrect value for uart_a.rx_throughput, expected 0.00000000000000000e+00, is {:e}", msg.uart_a.rx_throughput); + assert_eq!( + msg.uart_a.tx_buffer_level, 24, + "incorrect value for uart_a.tx_buffer_level, expected 24, is {}", + msg.uart_a.tx_buffer_level + ); + assert!(msg.uart_a.tx_throughput.almost_eq( 8.74647915363311768e-01 ), "incorrect value for uart_a.tx_throughput, expected 8.74647915363311768e-01, is {:e}", msg.uart_a.tx_throughput); + assert_eq!( + msg.uart_b.crc_error_count, 0, + "incorrect value for uart_b.crc_error_count, expected 0, is {}", + msg.uart_b.crc_error_count + ); + assert_eq!( + msg.uart_b.io_error_count, 0, + "incorrect value for uart_b.io_error_count, expected 0, is {}", + msg.uart_b.io_error_count + ); + assert_eq!( + msg.uart_b.rx_buffer_level, 0, + "incorrect value for uart_b.rx_buffer_level, expected 0, is {}", + msg.uart_b.rx_buffer_level + ); + assert!(msg.uart_b.rx_throughput.almost_eq( 0.00000000000000000e+00 ), "incorrect value for uart_b.rx_throughput, expected 0.00000000000000000e+00, is {:e}", msg.uart_b.rx_throughput); + assert_eq!( + msg.uart_b.tx_buffer_level, 40, + "incorrect value for uart_b.tx_buffer_level, expected 40, is {}", + msg.uart_b.tx_buffer_level + ); + assert!(msg.uart_b.tx_throughput.almost_eq( 2.99577474594116211e+00 ), "incorrect value for uart_b.tx_throughput, expected 2.99577474594116211e+00, is {:e}", msg.uart_b.tx_throughput); + assert_eq!( + msg.uart_ftdi.crc_error_count, 0, + "incorrect value for uart_ftdi.crc_error_count, expected 0, is {}", + msg.uart_ftdi.crc_error_count + ); + assert_eq!( + msg.uart_ftdi.io_error_count, 0, + "incorrect value for uart_ftdi.io_error_count, expected 0, is {}", + msg.uart_ftdi.io_error_count + ); + assert_eq!( + msg.uart_ftdi.rx_buffer_level, 1, + "incorrect value for uart_ftdi.rx_buffer_level, expected 1, is {}", + msg.uart_ftdi.rx_buffer_level + ); + assert!(msg.uart_ftdi.rx_throughput.almost_eq( 3.52112680673599243e-01 ), "incorrect value for uart_ftdi.rx_throughput, expected 3.52112680673599243e-01, is {:e}", msg.uart_ftdi.rx_throughput); + assert_eq!( + msg.uart_ftdi.tx_buffer_level, 85, + "incorrect value for uart_ftdi.tx_buffer_level, expected 85, is {}", + msg.uart_ftdi.tx_buffer_level + ); + assert!(msg.uart_ftdi.tx_throughput.almost_eq( 6.79014110565185547e+00 ), "incorrect value for uart_ftdi.tx_throughput, expected 6.79014110565185547e+00, is {:e}", msg.uart_ftdi.tx_throughput); + } + _ => assert!(false, "Invalid message type! Expected a MsgUartStateDepa"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_piksi_45.rs b/rust/sbp/tests/auto_check_sbp_piksi_45.rs new file mode 100644 index 0000000000000000000000000000000000000000..61420731daa44f9a4a26be1c90617ff296173519 GIT binary patch literal 55358 zcmeHQ`*YhklHQ;FS0KKs8GF~EMe6N&)OupijOr5GWjnjKm6}q~5^d|E*N{{a*KGdx z>xKjpFIpf-PqJsYoQS4~4`?*{YoOT#4-a<^56P>=@*$qw-KS*l)jkOte)}c-*CSUS zC$}j%3qMTm!gR8jlfiuCtqaW4aFiaYSA0K?KKwnwa`W(mH(JbogzK@$_5CCv$zm0c zB7#S&oBxeQDM=S3y^qLrGK%I&L~a+W`It=R^yKYi8j){b4_=*~U7dbQKHg78_hhz8 zQpCH7@OL~((s**SN~1AA-9>;ElaG`19ssiXJaRmpk_G*aikXl&N}~8fG)8G?>wX3riQ`k71r_Q^zzlOP~q`UgVzJ77TS6U$UhIR&!8Ft zjV8zB;`s7<@apaB<4bb!_VVKV>eSnzB4UToF8vrLBwVG7mv_-TibL$X+jub}$ub%p zrcsh6hY#UwddSpxnA|Ms`QdW%KACv_nf^D4vrM)J!acTsY5boJB4oAn>x?d+s+I7vZevqh4g{!aeb zA@FlMCm}sEjDFusqUr4ciSH8_fN;1^Uj9gK7K`b3JD+!UCbQ)Q&*zult^Auq8d`(AjH?Cq29e;|8FIzBprN{^0CFRli! zVG#WlPC`S;-}p=aiopB(85~0X``>z0l4HIZoUO}zE|9j|Rw%Wwd^ zh2OEC#wWikp4kQNU&JwT_Qq~W`ml@+Nc0J413842L2m!!^R8G{Ut?C`KG$gU6rfqk z|1ot2!0$_@2>6VX$^0%Wib|TTP*E`m3+kc7vi|Gn=z^X-I+{lx_n;Cc94(aG4Z#Vl zrYRI!U+>Y6y>Afjn~mn*dERea$#s{$*qddgy-6}$yx-gBE<$)5jc^fQbC<5>ALDSz zw`3Nk;L_N|`Dn$KQb`1gl*cMIW1sx+BS%=gh)FabNAYknUbn&n?>NlP?d^MNb6Dx3 zk;A^vP+%Z_YK@wrw%Jv?lWfGS3y{fJ7%o^+J6;$*}lo=A-Y2w{ZlF6tvnLC9;+l>XGcIUW%L?K#J$TY`SY6G)|KQm z@+F)e`nm?X!UlLMzu_}qmASA-4}@NVD}w-04oDLmYF01^u##Rr#+}#0>9q5D)bl#8 z$1~o>C&8?=*UAlszrw)pVcD%*2(D7FUaX^j&o>!QBgygoNs~^+^h_VRyT!56#Q{sPqWnPf|KfiPwIh-Y6b_S3-j6@{)6MpYZV^|Duc`X=Gy7? z5sD%B9b8lToPwR#b6yWk(s@1X1>q<2ddP%#Pv!MOb+6i8>}FJP^aJJ zOxXE6=kw6ooX^8v5PmYB=a*Omi1AG@!EJN@KgZv}{XoIj;U8bf-&r>0Dg9lu(dCu_ z{2(Z?&O?l?+IId9mt)$SdU!u?eRmIBAdPe4$`8-<(P{Z`R&j`ezvI8%+#K`+aDUm| zJqThGE{^S7pL2a^>(2G@j7N`i*Jpok4^8mvaDKCJ4p}iI9Q~gAz%S(dESvI_&M#=e zEg^wO*>Es-eiUP?ww?0>lPKf-FggjI4}BPOgN-bHDOo1({jy`c*_XLLKLG#Nc56SE z+rkWd^XVL*)FJD;GIS{?SsA-fOO4{%?`v~^kOew=&m7>Fb$?}>@}%ys3CoPC?hi5k zU%S7zVVquJI_F8W48_Dh^OR2TW1ItQgKx?lmDPcuH7$Y zK09{lq|5~rq>~C==@Lp=Z{ep&Lg^GZW;=yOy+gTu>zMo482i28b)!vh=(J{?uU_9Ml(eiWn|N1)GXy> zQCUbC!a_z7qGl1}Ps5wl?JYcDFpWM$Q!7O(7#2cG80J#ar#QULZ~&C_9-cS3yI-zS zFMraEG`xoV6aB5xAp4N8t;?p@;qk_&hg(z2Q3Map&?rKb=}lJlNyZD>QXSw)uldm#yd(nC~rKGpe!gvg|LuOY(>o?O7vtU zqk>@}q=aEEB}bDtUcEFa;aS?9gi_7!Bzm$^mx5uTE(ya@T>>Fh_G&ktfM=~P0i}w% zZqxCk2By@*lvbJ!#$0a(d`T-1$;x7UYEkTj728t3tP*G03ah}_Nh`sai_0-6?fiO4 zRE4xOOckiIZAvUg!N-!U9C?ia`aEB&sPZ`7Iw_ulgLS0QR2~tA{%%EzJCC z!U*iFbC-*v?QmWba2G~jQBh4fdS3vylgI#Er2aW<{2MJaV{LSb zg|=O!eskZ(Me4Jsp*)g_=*Q5OwN zRZsoU!<1H<4#r$>27E~?5Xs77d}>kbgcaLTzpN5x*$S(`*hwqFn2XCXDD8Xzs&THV zLRuQ83RKxPB^I+)paNs3KnccPfdYZ?wA%67efraB1(-$DRI6a#m z(ruFe{G58Iv4@YP!Dk0z_C!J~7K!Ori<=Hm1&PS32tJ;$B* zM0UjIP`iwJc&xz1>0O*&@ITB{T%10?{muFWKZ^rUp^|M{dTuI1D4MA<4cEljO9$CB z7#2d-v3zoI`fOA_HYBBm4!<5W%xelUDU-i7V?HRk)h2(xw;JE zPHK?7G=-=Tr5Qwqs98jbo-9HYG!D(%3_m^%?M}fkmy)wPDI(5CD6H;}NqD?mCG1W@ zsp8dW&bZjs7DG~^I9@Dcbx9bO>H?G+Y0_oXXI_#!$mX^*&MDnBFxQ&_U(yQ1*ti9q zXi-YDrUs>cS*vp=ZKeWaC#?iyE-uHQtUWbar3%RtP6-}WfvQj`MUz+z;+m!DRF9Ks z&}1Jxnq{KHu~%UsvHD)KMa~b2QqMT}3q|T(Mt%MwMYs12 z9gK9VwYP7MD@a%pX5Z(o0z~xr@}hNPWI5k;|y(?P$F<<0dOtTFO`~H8ffI z*~HB}vsY?|`J~NYNhQa~t%Q`9WEL`t5H*V^EnKW*R4^=rlrYSthyP8Ota_m=lPBCr~2fRx(Ny zXCW6- zjlM|?Wno}?n9@qq!IJq;&Kd1RR}=O zHBw)9px$)7NBg}FPGvxP1s3GLyNr4w?YzC5yiX>uQM$B^`P1xtLtiD`#Vu;!SDU{k)Fg?$p(y$hFM?-J|a(Y|pVsc33>Kq@7lIa;ZTvAEO4of#OS?Wie;b!<42^9gMlSoJleuebm?LW||7g z8D;^Z)-Y9|%C@OYIw5eW^c#-ZEyGp8$ux+OP$NpE(n&ZmmywWe5uyMTnY3 ztiGsHV($Ec!*DvTV39UsAhN7X;O)~ zb97=#lM06UpyX&$ijY^PNePdWs|-y_C{@%&V{y_%&VoerFr|q^2V<@`1HPmch-76e zt&CzPtcX&-tkt=bc9{ZWC#?iyE-q)1tUb>)ZVzEgrQaT(bBBPO6h_Nv2PHgRAXk@J11KsxK0GAXQIeAMJ|gjAH6N2So-D~Se3&l6F?`0!WPX=j zj{C99Rw+Fn#m^yV&3e&o4};{%eoW$1^VMv4|FBHTO&s!48SxtME-RG{RMya^Atg2_ zs=oS~;Z)%x{?*g#8;Jd$BcwQq;-jMrpfCKKM<4gNkw952xf{k&vYMvAVn}mQ?9q?C zZ;;@=*)ZTc&-;xlxgPg)mbEGEO_Jf_{oX!z(bH~P#m0;yBxd9IS&opnN5*&%Z9tMy z3+HyhbTf9kk7p235o!i^@R`ZW> zxa4V?ndUaz&QM^?eQJ%G;w+k>aK^nZKqh0(rq?AOwd<^&ZAOh%Zfi7l0V4@ahLPs} znpWp~ZRF*$IT8Xq+IYUcZSAjV>Bc9C%+=7;)rOo`v&66B0tr>@> z38bYm$*)>kGDvo1<(?%i;RXt9uGEL4X5Y<~++2yxi`-lZX-Ouf?$#OJmbnrvP}~A; w^x~a9!X3btDmf|nUC0fGJzg9wIa+eG#MWgxTH3zw+(JuWX#YvH^m*t10Latb#{d8T literal 0 HcmV?d00001 diff --git a/rust/sbp/tests/auto_check_sbp_settings_33.rs b/rust/sbp/tests/auto_check_sbp_settings_33.rs new file mode 100644 index 0000000000..8621c4c60a --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_settings_33.rs @@ -0,0 +1,70 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/settings/test_MsgSettingsReadByIndexDone.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_settings_33() { + { + use sbp::messages::settings::MsgSettingsReadByIndexDone; + let payload: Vec = vec![85, 166, 0, 246, 215, 0, 163, 58]; + + assert_eq!( + MsgSettingsReadByIndexDone::MSG_ID, + 0xa6, + "Incorrect message type, expected 0xa6, is {}", + MsgSettingsReadByIndexDone::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgSettingsReadByIndexDone(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgSettingsReadByIndexDone" + ), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_settings_34.rs b/rust/sbp/tests/auto_check_sbp_settings_34.rs new file mode 100644 index 0000000000000000000000000000000000000000..76ebf7f595de43069b2da479a99b8b15d94af191 GIT binary patch literal 10629 zcmeHMe{!B7yF78m~$!;nIs z!ik`%I~1N2H1ZdoL$0SPNA6V6^Hb}%+3Gc))78WsPH47}A>&;L{&QRz2JXco6b_)q z0$2fEx#0u=YkdYarc?4&n;NF1Ku8f>3WrCdtb1qm=(v5-q(Lcd6ofmRxg34MwdG0-A=pLG}3B_JRxdIuWU*7BJ^L3g(m`= z=WZ1EGm>*L%!fjTGQYHE(|q(A^YUVzmm&;ZZ!DF-;7pEttBS6$oi|I%bHsI5$hpB? z>0(I{xG`TEbmEiehcxpYceLcziS0Ri>9n{GMc~nptstm*nO?vPP^i~uLP~oqWWC;d z(>c=*FVpETu-y)n6{GM{*~6_FWeB}sOR|Q2Av0Nebwn8% zI`uk~*6Ynq&pL&ReUC~QN&td{O`bI)k2-rfIMon z)$+F=En_A}``rh2-j8W`0~ZGD{X2cWH@=0uO)1GUSS-(njzjLJqqJ|7;1;2oYlTGV407zu!CH zIlUhT7D$2RqF>?KzGccjh}91QCd5_Pqi{JFITF{1$sC|nA12PvH~UGnKi9rio{bHL zDH)4I5pAGY7eqRbJQ(*tBHXXLvUkrG?BM|>0e-Dww0^4BJF2!`_rz5ON}_?PPI5c| z+b*UdI%#=B-7?P@@7Zd}d@ziUv7UOW_cF6}Z^M-X|5GL#6JmH?*boACOmyL01@=5{ z$;=LsJ4C{pRnL~HktEpWOADS&%F@y67!SmUD+P!!7`TqM$UsVhz_Y5$WQ}dpqTcs; zSJb{nfu~+O2cv4z4I;69ckN2L2f0qdk5tz?Jt=}%Yg)g^s3kV}QPrQBjp;I6P7Zj1 zZ2>Y$%;HOXy5J-*Knke3Z2Uj>MU&TBwlsXD$*b6ZkHw*wikS$5kBf?b&-={+rt0GC7)B1N5b_GTD0! z*}Uw{)bU(I=5GRs2BPPmZ=S2E`Sh?{KyhqI_1lwN-^vRbPds{a;8fx=4ap&L8HcHIhit-fkYt9GXs@y~6 z6a`KXbQ%C+REdPTuabzwq^@!e4an491vS?+rRwxWWgIHSC;*_sY#b9~Cg%L-069pN zvjSLmD_E$6saW1I^NyMC+j;JoISSzV{s?9^x1%9rJcyaG>hDTRBU}DqW?tCH&_|); zrf}9EQaCzD32!muGlX30tl3EI|7)!JElk@n;;rMRBXLb(niED_rW>^7@9 z>g+bFtHanGB}O!)?~kCwVsb@CI1i#kEdD1+iR%1ApQI0Fw)~W;Rw|{+lc2<}H*H6W ze-|Yd!CjhX9!H5_LngW87Ey2h6upAAG}%Sx+{|Rq#fPtV{iC^9=ItmB%h#YguG?{4 z;=|*P>mrVNG}pyWRpJ;A;yMI~C&_ge_QK(>$|)R9@$X5n+}9Yj +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgDgnssStatus.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_system_35() { + { + use sbp::messages::system::MsgDgnssStatus; + let payload: Vec = vec![ + 85, 2, 255, 66, 0, 11, 0, 50, 0, 12, 83, 107, 121, 108, 97, 114, 107, 202, 1, + ]; + + assert_eq!( + MsgDgnssStatus::MSG_ID, + 0xff02, + "Incorrect message type, expected 0xff02, is {}", + MsgDgnssStatus::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgDgnssStatus(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + assert_eq!( + msg.latency, 50, + "incorrect value for latency, expected 50, is {}", + msg.latency + ); + assert_eq!( + msg.num_signals, 12, + "incorrect value for num_signals, expected 12, is {}", + msg.num_signals + ); + assert_eq!( + msg.source, + "Skylark".to_string(), + "incorrect value for msg.source, expected string '{}', is '{}'", + "Skylark".to_string(), + msg.source + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgDgnssStatus"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_system_36.rs b/rust/sbp/tests/auto_check_sbp_system_36.rs new file mode 100644 index 0000000000..e374f1c4f5 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_system_36.rs @@ -0,0 +1,72 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgHeartbeat.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_system_36() { + { + use sbp::messages::system::MsgHeartbeat; + let payload: Vec = vec![85, 255, 255, 246, 215, 4, 0, 50, 0, 0, 249, 216]; + + assert_eq!( + MsgHeartbeat::MSG_ID, + 0xffff, + "Incorrect message type, expected 0xffff, is {}", + MsgHeartbeat::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgHeartbeat(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert_eq!( + msg.flags, 12800, + "incorrect value for flags, expected 12800, is {}", + msg.flags + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgHeartbeat"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_system_37.rs b/rust/sbp/tests/auto_check_sbp_system_37.rs new file mode 100644 index 0000000000..a8bb5c8ace --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_system_37.rs @@ -0,0 +1,82 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgStartup.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_system_37() { + { + use sbp::messages::system::MsgStartup; + let payload: Vec = vec![85, 0, 255, 66, 0, 4, 0, 0, 0, 0, 70, 160]; + + assert_eq!( + MsgStartup::MSG_ID, + 0xff00, + "Incorrect message type, expected 0xff00, is {}", + MsgStartup::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgStartup(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.cause, 0, + "incorrect value for cause, expected 0, is {}", + msg.cause + ); + assert_eq!( + msg.reserved, 0, + "incorrect value for reserved, expected 0, is {}", + msg.reserved + ); + assert_eq!( + msg.startup_type, 0, + "incorrect value for startup_type, expected 0, is {}", + msg.startup_type + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgStartup"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_system_46.rs b/rust/sbp/tests/auto_check_sbp_system_46.rs new file mode 100644 index 0000000000..b436a60785 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_system_46.rs @@ -0,0 +1,105 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_system.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_system_46() { + { + use sbp::messages::system::MsgStartup; + let payload: Vec = vec![85, 0, 255, 195, 4, 4, 0, 0, 0, 0, 127, 181]; + + assert_eq!( + MsgStartup::MSG_ID, + 0xff00, + "Incorrect message type, expected 0xff00, is {}", + MsgStartup::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgStartup(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.reserved, 0, + "incorrect value for reserved, expected 0, is {}", + msg.reserved + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgStartup"), + }; + } + { + use sbp::messages::system::MsgHeartbeat; + let payload: Vec = vec![85, 255, 255, 195, 4, 4, 0, 0, 0, 0, 66, 57]; + + assert_eq!( + MsgHeartbeat::MSG_ID, + 0xffff, + "Incorrect message type, expected 0xffff, is {}", + MsgHeartbeat::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgHeartbeat(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert_eq!( + msg.flags, 0, + "incorrect value for flags, expected 0, is {}", + msg.flags + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgHeartbeat"), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_tracking_47.rs b/rust/sbp/tests/auto_check_sbp_tracking_47.rs new file mode 100644 index 0000000000..c7834d9230 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_tracking_47.rs @@ -0,0 +1,1233 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/test_tracking.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_tracking_47() { + { + use sbp::messages::tracking::MsgTrackingStateDepA; + let payload: Vec = vec![ + 85, 22, 0, 195, 4, 66, 1, 0, 204, 177, 51, 65, 1, 2, 198, 4, 39, 65, 1, 3, 219, 182, + 27, 65, 1, 7, 132, 120, 101, 65, 1, 10, 91, 91, 251, 64, 1, 13, 42, 37, 163, 64, 1, 22, + 130, 184, 215, 64, 1, 30, 115, 53, 75, 65, 1, 31, 16, 74, 126, 65, 1, 25, 132, 196, + 135, 64, 1, 6, 100, 59, 223, 64, 17, 225, + ]; + + assert_eq!( + MsgTrackingStateDepA::MSG_ID, + 0x16, + "Incorrect message type, expected 0x16, is {}", + MsgTrackingStateDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(1.12309074401855469e+01), + "incorrect value for states[0].cn0, expected 1.12309074401855469e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].prn, 0, + "incorrect value for states[0].prn, expected 0, is {}", + msg.states[0].prn + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(1.04386653900146484e+01), + "incorrect value for states[1].cn0, expected 1.04386653900146484e+01, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].prn, 2, + "incorrect value for states[1].prn, expected 2, is {}", + msg.states[1].prn + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(9.73214244842529297e+00), + "incorrect value for states[2].cn0, expected 9.73214244842529297e+00, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].prn, 3, + "incorrect value for states[2].prn, expected 3, is {}", + msg.states[2].prn + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(1.43419227600097656e+01), + "incorrect value for states[3].cn0, expected 1.43419227600097656e+01, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].prn, 7, + "incorrect value for states[3].prn, expected 7, is {}", + msg.states[3].prn + ); + assert_eq!( + msg.states[3].state, 1, + "incorrect value for states[3].state, expected 1, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(7.85490179061889648e+00), + "incorrect value for states[4].cn0, expected 7.85490179061889648e+00, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].prn, 10, + "incorrect value for states[4].prn, expected 10, is {}", + msg.states[4].prn + ); + assert_eq!( + msg.states[4].state, 1, + "incorrect value for states[4].state, expected 1, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(5.09828662872314453e+00), + "incorrect value for states[5].cn0, expected 5.09828662872314453e+00, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].prn, 13, + "incorrect value for states[5].prn, expected 13, is {}", + msg.states[5].prn + ); + assert_eq!( + msg.states[5].state, 1, + "incorrect value for states[5].state, expected 1, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(6.74127292633056641e+00), + "incorrect value for states[6].cn0, expected 6.74127292633056641e+00, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].prn, 22, + "incorrect value for states[6].prn, expected 22, is {}", + msg.states[6].prn + ); + assert_eq!( + msg.states[6].state, 1, + "incorrect value for states[6].state, expected 1, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(1.27005491256713867e+01), + "incorrect value for states[7].cn0, expected 1.27005491256713867e+01, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].prn, 30, + "incorrect value for states[7].prn, expected 30, is {}", + msg.states[7].prn + ); + assert_eq!( + msg.states[7].state, 1, + "incorrect value for states[7].state, expected 1, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(1.58930816650390625e+01), + "incorrect value for states[8].cn0, expected 1.58930816650390625e+01, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].prn, 31, + "incorrect value for states[8].prn, expected 31, is {}", + msg.states[8].prn + ); + assert_eq!( + msg.states[8].state, 1, + "incorrect value for states[8].state, expected 1, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(4.24273872375488281e+00), + "incorrect value for states[9].cn0, expected 4.24273872375488281e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].prn, 25, + "incorrect value for states[9].prn, expected 25, is {}", + msg.states[9].prn + ); + assert_eq!( + msg.states[9].state, 1, + "incorrect value for states[9].state, expected 1, is {}", + msg.states[9].state + ); + assert!( + msg.states[10].cn0.almost_eq(6.97599983215332031e+00), + "incorrect value for states[10].cn0, expected 6.97599983215332031e+00, is {:e}", + msg.states[10].cn0 + ); + assert_eq!( + msg.states[10].prn, 6, + "incorrect value for states[10].prn, expected 6, is {}", + msg.states[10].prn + ); + assert_eq!( + msg.states[10].state, 1, + "incorrect value for states[10].state, expected 1, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepA" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepA; + let payload: Vec = vec![ + 85, 22, 0, 195, 4, 66, 1, 0, 216, 57, 48, 65, 1, 2, 145, 41, 46, 65, 1, 3, 4, 26, 34, + 65, 1, 7, 177, 67, 109, 65, 1, 10, 61, 80, 249, 64, 1, 13, 250, 199, 155, 64, 1, 22, + 55, 19, 215, 64, 1, 30, 138, 138, 79, 65, 1, 31, 214, 179, 119, 65, 1, 25, 53, 138, + 120, 64, 1, 6, 183, 247, 129, 64, 168, 173, + ]; + + assert_eq!( + MsgTrackingStateDepA::MSG_ID, + 0x16, + "Incorrect message type, expected 0x16, is {}", + MsgTrackingStateDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(1.10141220092773438e+01), + "incorrect value for states[0].cn0, expected 1.10141220092773438e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].prn, 0, + "incorrect value for states[0].prn, expected 0, is {}", + msg.states[0].prn + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(1.08851480484008789e+01), + "incorrect value for states[1].cn0, expected 1.08851480484008789e+01, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].prn, 2, + "incorrect value for states[1].prn, expected 2, is {}", + msg.states[1].prn + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(1.01313514709472656e+01), + "incorrect value for states[2].cn0, expected 1.01313514709472656e+01, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].prn, 3, + "incorrect value for states[2].prn, expected 3, is {}", + msg.states[2].prn + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(1.48290262222290039e+01), + "incorrect value for states[3].cn0, expected 1.48290262222290039e+01, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].prn, 7, + "incorrect value for states[3].prn, expected 7, is {}", + msg.states[3].prn + ); + assert_eq!( + msg.states[3].state, 1, + "incorrect value for states[3].state, expected 1, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(7.79104471206665039e+00), + "incorrect value for states[4].cn0, expected 7.79104471206665039e+00, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].prn, 10, + "incorrect value for states[4].prn, expected 10, is {}", + msg.states[4].prn + ); + assert_eq!( + msg.states[4].state, 1, + "incorrect value for states[4].state, expected 1, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(4.86816120147705078e+00), + "incorrect value for states[5].cn0, expected 4.86816120147705078e+00, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].prn, 13, + "incorrect value for states[5].prn, expected 13, is {}", + msg.states[5].prn + ); + assert_eq!( + msg.states[5].state, 1, + "incorrect value for states[5].state, expected 1, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(6.72109556198120117e+00), + "incorrect value for states[6].cn0, expected 6.72109556198120117e+00, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].prn, 22, + "incorrect value for states[6].prn, expected 22, is {}", + msg.states[6].prn + ); + assert_eq!( + msg.states[6].state, 1, + "incorrect value for states[6].state, expected 1, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(1.29713230133056641e+01), + "incorrect value for states[7].cn0, expected 1.29713230133056641e+01, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].prn, 30, + "incorrect value for states[7].prn, expected 30, is {}", + msg.states[7].prn + ); + assert_eq!( + msg.states[7].state, 1, + "incorrect value for states[7].state, expected 1, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(1.54814052581787109e+01), + "incorrect value for states[8].cn0, expected 1.54814052581787109e+01, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].prn, 31, + "incorrect value for states[8].prn, expected 31, is {}", + msg.states[8].prn + ); + assert_eq!( + msg.states[8].state, 1, + "incorrect value for states[8].state, expected 1, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(3.88343548774719238e+00), + "incorrect value for states[9].cn0, expected 3.88343548774719238e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].prn, 25, + "incorrect value for states[9].prn, expected 25, is {}", + msg.states[9].prn + ); + assert_eq!( + msg.states[9].state, 1, + "incorrect value for states[9].state, expected 1, is {}", + msg.states[9].state + ); + assert!( + msg.states[10].cn0.almost_eq(4.06148862838745117e+00), + "incorrect value for states[10].cn0, expected 4.06148862838745117e+00, is {:e}", + msg.states[10].cn0 + ); + assert_eq!( + msg.states[10].prn, 6, + "incorrect value for states[10].prn, expected 6, is {}", + msg.states[10].prn + ); + assert_eq!( + msg.states[10].state, 1, + "incorrect value for states[10].state, expected 1, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepA" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepA; + let payload: Vec = vec![ + 85, 22, 0, 195, 4, 66, 1, 0, 141, 76, 60, 65, 1, 2, 69, 139, 46, 65, 1, 3, 146, 27, 30, + 65, 1, 7, 235, 56, 97, 65, 1, 10, 141, 213, 243, 64, 1, 13, 250, 170, 166, 64, 1, 22, + 17, 101, 201, 64, 1, 30, 172, 183, 83, 65, 1, 31, 238, 193, 120, 65, 1, 25, 220, 48, + 132, 64, 1, 6, 49, 214, 54, 64, 110, 179, + ]; + + assert_eq!( + MsgTrackingStateDepA::MSG_ID, + 0x16, + "Incorrect message type, expected 0x16, is {}", + MsgTrackingStateDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(1.17686891555786133e+01), + "incorrect value for states[0].cn0, expected 1.17686891555786133e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].prn, 0, + "incorrect value for states[0].prn, expected 0, is {}", + msg.states[0].prn + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(1.09090013504028320e+01), + "incorrect value for states[1].cn0, expected 1.09090013504028320e+01, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].prn, 2, + "incorrect value for states[1].prn, expected 2, is {}", + msg.states[1].prn + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(9.88173103332519531e+00), + "incorrect value for states[2].cn0, expected 9.88173103332519531e+00, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].prn, 3, + "incorrect value for states[2].prn, expected 3, is {}", + msg.states[2].prn + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(1.40763959884643555e+01), + "incorrect value for states[3].cn0, expected 1.40763959884643555e+01, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].prn, 7, + "incorrect value for states[3].prn, expected 7, is {}", + msg.states[3].prn + ); + assert_eq!( + msg.states[3].state, 1, + "incorrect value for states[3].state, expected 1, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(7.61981821060180664e+00), + "incorrect value for states[4].cn0, expected 7.61981821060180664e+00, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].prn, 10, + "incorrect value for states[4].prn, expected 10, is {}", + msg.states[4].prn + ); + assert_eq!( + msg.states[4].state, 1, + "incorrect value for states[4].state, expected 1, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(5.20837116241455078e+00), + "incorrect value for states[5].cn0, expected 5.20837116241455078e+00, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].prn, 13, + "incorrect value for states[5].prn, expected 13, is {}", + msg.states[5].prn + ); + assert_eq!( + msg.states[5].state, 1, + "incorrect value for states[5].state, expected 1, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(6.29358720779418945e+00), + "incorrect value for states[6].cn0, expected 6.29358720779418945e+00, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].prn, 22, + "incorrect value for states[6].prn, expected 22, is {}", + msg.states[6].prn + ); + assert_eq!( + msg.states[6].state, 1, + "incorrect value for states[6].state, expected 1, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(1.32323417663574219e+01), + "incorrect value for states[7].cn0, expected 1.32323417663574219e+01, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].prn, 30, + "incorrect value for states[7].prn, expected 30, is {}", + msg.states[7].prn + ); + assert_eq!( + msg.states[7].state, 1, + "incorrect value for states[7].state, expected 1, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(1.55473461151123047e+01), + "incorrect value for states[8].cn0, expected 1.55473461151123047e+01, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].prn, 31, + "incorrect value for states[8].prn, expected 31, is {}", + msg.states[8].prn + ); + assert_eq!( + msg.states[8].state, 1, + "incorrect value for states[8].state, expected 1, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(4.13096427917480469e+00), + "incorrect value for states[9].cn0, expected 4.13096427917480469e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].prn, 25, + "incorrect value for states[9].prn, expected 25, is {}", + msg.states[9].prn + ); + assert_eq!( + msg.states[9].state, 1, + "incorrect value for states[9].state, expected 1, is {}", + msg.states[9].state + ); + assert!( + msg.states[10].cn0.almost_eq(2.85682320594787598e+00), + "incorrect value for states[10].cn0, expected 2.85682320594787598e+00, is {:e}", + msg.states[10].cn0 + ); + assert_eq!( + msg.states[10].prn, 6, + "incorrect value for states[10].prn, expected 6, is {}", + msg.states[10].prn + ); + assert_eq!( + msg.states[10].state, 1, + "incorrect value for states[10].state, expected 1, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepA" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepA; + let payload: Vec = vec![ + 85, 22, 0, 195, 4, 66, 1, 0, 55, 143, 120, 66, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, + 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, + 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, + 191, 248, 89, + ]; + + assert_eq!( + MsgTrackingStateDepA::MSG_ID, + 0x16, + "Incorrect message type, expected 0x16, is {}", + MsgTrackingStateDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(6.21398582458496094e+01), + "incorrect value for states[0].cn0, expected 6.21398582458496094e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].prn, 0, + "incorrect value for states[0].prn, expected 0, is {}", + msg.states[0].prn + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[1].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].prn, 0, + "incorrect value for states[1].prn, expected 0, is {}", + msg.states[1].prn + ); + assert_eq!( + msg.states[1].state, 0, + "incorrect value for states[1].state, expected 0, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[2].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].prn, 0, + "incorrect value for states[2].prn, expected 0, is {}", + msg.states[2].prn + ); + assert_eq!( + msg.states[2].state, 0, + "incorrect value for states[2].state, expected 0, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[3].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].prn, 0, + "incorrect value for states[3].prn, expected 0, is {}", + msg.states[3].prn + ); + assert_eq!( + msg.states[3].state, 0, + "incorrect value for states[3].state, expected 0, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[4].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].prn, 0, + "incorrect value for states[4].prn, expected 0, is {}", + msg.states[4].prn + ); + assert_eq!( + msg.states[4].state, 0, + "incorrect value for states[4].state, expected 0, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[5].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].prn, 0, + "incorrect value for states[5].prn, expected 0, is {}", + msg.states[5].prn + ); + assert_eq!( + msg.states[5].state, 0, + "incorrect value for states[5].state, expected 0, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[6].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].prn, 0, + "incorrect value for states[6].prn, expected 0, is {}", + msg.states[6].prn + ); + assert_eq!( + msg.states[6].state, 0, + "incorrect value for states[6].state, expected 0, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[7].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].prn, 0, + "incorrect value for states[7].prn, expected 0, is {}", + msg.states[7].prn + ); + assert_eq!( + msg.states[7].state, 0, + "incorrect value for states[7].state, expected 0, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[8].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].prn, 0, + "incorrect value for states[8].prn, expected 0, is {}", + msg.states[8].prn + ); + assert_eq!( + msg.states[8].state, 0, + "incorrect value for states[8].state, expected 0, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[9].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].prn, 0, + "incorrect value for states[9].prn, expected 0, is {}", + msg.states[9].prn + ); + assert_eq!( + msg.states[9].state, 0, + "incorrect value for states[9].state, expected 0, is {}", + msg.states[9].state + ); + assert!(msg.states[10].cn0.almost_eq( -1.00000000000000000e+00 ), "incorrect value for states[10].cn0, expected -1.00000000000000000e+00, is {:e}", msg.states[10].cn0); + assert_eq!( + msg.states[10].prn, 0, + "incorrect value for states[10].prn, expected 0, is {}", + msg.states[10].prn + ); + assert_eq!( + msg.states[10].state, 0, + "incorrect value for states[10].state, expected 0, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepA" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepA; + let payload: Vec = vec![ + 85, 22, 0, 195, 4, 66, 1, 0, 218, 14, 19, 66, 1, 2, 210, 3, 21, 65, 1, 3, 234, 214, + 134, 65, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, + 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, + 128, 191, 84, 101, + ]; + + assert_eq!( + MsgTrackingStateDepA::MSG_ID, + 0x16, + "Incorrect message type, expected 0x16, is {}", + MsgTrackingStateDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(3.67645034790039062e+01), + "incorrect value for states[0].cn0, expected 3.67645034790039062e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].prn, 0, + "incorrect value for states[0].prn, expected 0, is {}", + msg.states[0].prn + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(9.31343269348144531e+00), + "incorrect value for states[1].cn0, expected 9.31343269348144531e+00, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].prn, 2, + "incorrect value for states[1].prn, expected 2, is {}", + msg.states[1].prn + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(1.68549385070800781e+01), + "incorrect value for states[2].cn0, expected 1.68549385070800781e+01, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].prn, 3, + "incorrect value for states[2].prn, expected 3, is {}", + msg.states[2].prn + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[3].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].prn, 0, + "incorrect value for states[3].prn, expected 0, is {}", + msg.states[3].prn + ); + assert_eq!( + msg.states[3].state, 0, + "incorrect value for states[3].state, expected 0, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[4].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].prn, 0, + "incorrect value for states[4].prn, expected 0, is {}", + msg.states[4].prn + ); + assert_eq!( + msg.states[4].state, 0, + "incorrect value for states[4].state, expected 0, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[5].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].prn, 0, + "incorrect value for states[5].prn, expected 0, is {}", + msg.states[5].prn + ); + assert_eq!( + msg.states[5].state, 0, + "incorrect value for states[5].state, expected 0, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[6].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].prn, 0, + "incorrect value for states[6].prn, expected 0, is {}", + msg.states[6].prn + ); + assert_eq!( + msg.states[6].state, 0, + "incorrect value for states[6].state, expected 0, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[7].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].prn, 0, + "incorrect value for states[7].prn, expected 0, is {}", + msg.states[7].prn + ); + assert_eq!( + msg.states[7].state, 0, + "incorrect value for states[7].state, expected 0, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[8].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].prn, 0, + "incorrect value for states[8].prn, expected 0, is {}", + msg.states[8].prn + ); + assert_eq!( + msg.states[8].state, 0, + "incorrect value for states[8].state, expected 0, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[9].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].prn, 0, + "incorrect value for states[9].prn, expected 0, is {}", + msg.states[9].prn + ); + assert_eq!( + msg.states[9].state, 0, + "incorrect value for states[9].state, expected 0, is {}", + msg.states[9].state + ); + assert!(msg.states[10].cn0.almost_eq( -1.00000000000000000e+00 ), "incorrect value for states[10].cn0, expected -1.00000000000000000e+00, is {:e}", msg.states[10].cn0); + assert_eq!( + msg.states[10].prn, 0, + "incorrect value for states[10].prn, expected 0, is {}", + msg.states[10].prn + ); + assert_eq!( + msg.states[10].state, 0, + "incorrect value for states[10].state, expected 0, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepA" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepA; + let payload: Vec = vec![ + 85, 22, 0, 195, 4, 66, 1, 0, 98, 39, 219, 65, 1, 2, 0, 0, 56, 64, 1, 3, 121, 123, 7, + 65, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, + 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 128, + 191, 37, 123, + ]; + + assert_eq!( + MsgTrackingStateDepA::MSG_ID, + 0x16, + "Incorrect message type, expected 0x16, is {}", + MsgTrackingStateDepA::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x4c3, + "incorrect sender id, expected 0x4c3, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(2.73942298889160156e+01), + "incorrect value for states[0].cn0, expected 2.73942298889160156e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].prn, 0, + "incorrect value for states[0].prn, expected 0, is {}", + msg.states[0].prn + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(2.87500000000000000e+00), + "incorrect value for states[1].cn0, expected 2.87500000000000000e+00, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].prn, 2, + "incorrect value for states[1].prn, expected 2, is {}", + msg.states[1].prn + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(8.46764469146728516e+00), + "incorrect value for states[2].cn0, expected 8.46764469146728516e+00, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].prn, 3, + "incorrect value for states[2].prn, expected 3, is {}", + msg.states[2].prn + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[3].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].prn, 0, + "incorrect value for states[3].prn, expected 0, is {}", + msg.states[3].prn + ); + assert_eq!( + msg.states[3].state, 0, + "incorrect value for states[3].state, expected 0, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[4].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].prn, 0, + "incorrect value for states[4].prn, expected 0, is {}", + msg.states[4].prn + ); + assert_eq!( + msg.states[4].state, 0, + "incorrect value for states[4].state, expected 0, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[5].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].prn, 0, + "incorrect value for states[5].prn, expected 0, is {}", + msg.states[5].prn + ); + assert_eq!( + msg.states[5].state, 0, + "incorrect value for states[5].state, expected 0, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[6].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].prn, 0, + "incorrect value for states[6].prn, expected 0, is {}", + msg.states[6].prn + ); + assert_eq!( + msg.states[6].state, 0, + "incorrect value for states[6].state, expected 0, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[7].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].prn, 0, + "incorrect value for states[7].prn, expected 0, is {}", + msg.states[7].prn + ); + assert_eq!( + msg.states[7].state, 0, + "incorrect value for states[7].state, expected 0, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[8].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].prn, 0, + "incorrect value for states[8].prn, expected 0, is {}", + msg.states[8].prn + ); + assert_eq!( + msg.states[8].state, 0, + "incorrect value for states[8].state, expected 0, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[9].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].prn, 0, + "incorrect value for states[9].prn, expected 0, is {}", + msg.states[9].prn + ); + assert_eq!( + msg.states[9].state, 0, + "incorrect value for states[9].state, expected 0, is {}", + msg.states[9].state + ); + assert!(msg.states[10].cn0.almost_eq( -1.00000000000000000e+00 ), "incorrect value for states[10].cn0, expected -1.00000000000000000e+00, is {:e}", msg.states[10].cn0); + assert_eq!( + msg.states[10].prn, 0, + "incorrect value for states[10].prn, expected 0, is {}", + msg.states[10].prn + ); + assert_eq!( + msg.states[10].state, 0, + "incorrect value for states[10].state, expected 0, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepA" + ), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_tracking_48.rs b/rust/sbp/tests/auto_check_sbp_tracking_48.rs new file mode 100644 index 0000000000..4f13286a63 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_tracking_48.rs @@ -0,0 +1,1579 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/tracking/test_MsgTrackingState.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_tracking_48() { + { + use sbp::messages::tracking::MsgTrackingStateDepB; + let payload: Vec = vec![ + 85, 19, 0, 246, 215, 99, 1, 202, 0, 0, 0, 197, 253, 28, 66, 1, 203, 0, 0, 0, 231, 99, + 16, 66, 1, 208, 0, 0, 0, 212, 129, 22, 66, 1, 212, 0, 0, 0, 58, 21, 28, 66, 1, 217, 0, + 0, 0, 178, 33, 40, 66, 1, 218, 0, 0, 0, 235, 189, 21, 66, 1, 220, 0, 0, 0, 29, 177, 25, + 66, 1, 222, 0, 0, 0, 43, 169, 27, 66, 1, 225, 0, 0, 0, 137, 125, 42, 66, 0, 0, 0, 0, 0, + 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 128, 191, 222, 97, + ]; + + assert_eq!( + MsgTrackingStateDepB::MSG_ID, + 0x13, + "Incorrect message type, expected 0x13, is {}", + MsgTrackingStateDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(3.92478218078613281e+01), + "incorrect value for states[0].cn0, expected 3.92478218078613281e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].sid.code, 0, + "incorrect value for states[0].sid.code, expected 0, is {}", + msg.states[0].sid.code + ); + assert_eq!( + msg.states[0].sid.reserved, 0, + "incorrect value for states[0].sid.reserved, expected 0, is {}", + msg.states[0].sid.reserved + ); + assert_eq!( + msg.states[0].sid.sat, 202, + "incorrect value for states[0].sid.sat, expected 202, is {}", + msg.states[0].sid.sat + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(3.60975608825683594e+01), + "incorrect value for states[1].cn0, expected 3.60975608825683594e+01, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].sid.code, 0, + "incorrect value for states[1].sid.code, expected 0, is {}", + msg.states[1].sid.code + ); + assert_eq!( + msg.states[1].sid.reserved, 0, + "incorrect value for states[1].sid.reserved, expected 0, is {}", + msg.states[1].sid.reserved + ); + assert_eq!( + msg.states[1].sid.sat, 203, + "incorrect value for states[1].sid.sat, expected 203, is {}", + msg.states[1].sid.sat + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(3.76267852783203125e+01), + "incorrect value for states[2].cn0, expected 3.76267852783203125e+01, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].sid.code, 0, + "incorrect value for states[2].sid.code, expected 0, is {}", + msg.states[2].sid.code + ); + assert_eq!( + msg.states[2].sid.reserved, 0, + "incorrect value for states[2].sid.reserved, expected 0, is {}", + msg.states[2].sid.reserved + ); + assert_eq!( + msg.states[2].sid.sat, 208, + "incorrect value for states[2].sid.sat, expected 208, is {}", + msg.states[2].sid.sat + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(3.90207290649414062e+01), + "incorrect value for states[3].cn0, expected 3.90207290649414062e+01, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].sid.code, 0, + "incorrect value for states[3].sid.code, expected 0, is {}", + msg.states[3].sid.code + ); + assert_eq!( + msg.states[3].sid.reserved, 0, + "incorrect value for states[3].sid.reserved, expected 0, is {}", + msg.states[3].sid.reserved + ); + assert_eq!( + msg.states[3].sid.sat, 212, + "incorrect value for states[3].sid.sat, expected 212, is {}", + msg.states[3].sid.sat + ); + assert_eq!( + msg.states[3].state, 1, + "incorrect value for states[3].state, expected 1, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(4.20329055786132812e+01), + "incorrect value for states[4].cn0, expected 4.20329055786132812e+01, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].sid.code, 0, + "incorrect value for states[4].sid.code, expected 0, is {}", + msg.states[4].sid.code + ); + assert_eq!( + msg.states[4].sid.reserved, 0, + "incorrect value for states[4].sid.reserved, expected 0, is {}", + msg.states[4].sid.reserved + ); + assert_eq!( + msg.states[4].sid.sat, 217, + "incorrect value for states[4].sid.sat, expected 217, is {}", + msg.states[4].sid.sat + ); + assert_eq!( + msg.states[4].state, 1, + "incorrect value for states[4].state, expected 1, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(3.74354667663574219e+01), + "incorrect value for states[5].cn0, expected 3.74354667663574219e+01, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].sid.code, 0, + "incorrect value for states[5].sid.code, expected 0, is {}", + msg.states[5].sid.code + ); + assert_eq!( + msg.states[5].sid.reserved, 0, + "incorrect value for states[5].sid.reserved, expected 0, is {}", + msg.states[5].sid.reserved + ); + assert_eq!( + msg.states[5].sid.sat, 218, + "incorrect value for states[5].sid.sat, expected 218, is {}", + msg.states[5].sid.sat + ); + assert_eq!( + msg.states[5].state, 1, + "incorrect value for states[5].state, expected 1, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(3.84229621887207031e+01), + "incorrect value for states[6].cn0, expected 3.84229621887207031e+01, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].sid.code, 0, + "incorrect value for states[6].sid.code, expected 0, is {}", + msg.states[6].sid.code + ); + assert_eq!( + msg.states[6].sid.reserved, 0, + "incorrect value for states[6].sid.reserved, expected 0, is {}", + msg.states[6].sid.reserved + ); + assert_eq!( + msg.states[6].sid.sat, 220, + "incorrect value for states[6].sid.sat, expected 220, is {}", + msg.states[6].sid.sat + ); + assert_eq!( + msg.states[6].state, 1, + "incorrect value for states[6].state, expected 1, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(3.89152030944824219e+01), + "incorrect value for states[7].cn0, expected 3.89152030944824219e+01, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].sid.code, 0, + "incorrect value for states[7].sid.code, expected 0, is {}", + msg.states[7].sid.code + ); + assert_eq!( + msg.states[7].sid.reserved, 0, + "incorrect value for states[7].sid.reserved, expected 0, is {}", + msg.states[7].sid.reserved + ); + assert_eq!( + msg.states[7].sid.sat, 222, + "incorrect value for states[7].sid.sat, expected 222, is {}", + msg.states[7].sid.sat + ); + assert_eq!( + msg.states[7].state, 1, + "incorrect value for states[7].state, expected 1, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(4.26225929260253906e+01), + "incorrect value for states[8].cn0, expected 4.26225929260253906e+01, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].sid.code, 0, + "incorrect value for states[8].sid.code, expected 0, is {}", + msg.states[8].sid.code + ); + assert_eq!( + msg.states[8].sid.reserved, 0, + "incorrect value for states[8].sid.reserved, expected 0, is {}", + msg.states[8].sid.reserved + ); + assert_eq!( + msg.states[8].sid.sat, 225, + "incorrect value for states[8].sid.sat, expected 225, is {}", + msg.states[8].sid.sat + ); + assert_eq!( + msg.states[8].state, 1, + "incorrect value for states[8].state, expected 1, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[9].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].sid.code, 0, + "incorrect value for states[9].sid.code, expected 0, is {}", + msg.states[9].sid.code + ); + assert_eq!( + msg.states[9].sid.reserved, 0, + "incorrect value for states[9].sid.reserved, expected 0, is {}", + msg.states[9].sid.reserved + ); + assert_eq!( + msg.states[9].sid.sat, 0, + "incorrect value for states[9].sid.sat, expected 0, is {}", + msg.states[9].sid.sat + ); + assert_eq!( + msg.states[9].state, 0, + "incorrect value for states[9].state, expected 0, is {}", + msg.states[9].state + ); + assert!(msg.states[10].cn0.almost_eq( -1.00000000000000000e+00 ), "incorrect value for states[10].cn0, expected -1.00000000000000000e+00, is {:e}", msg.states[10].cn0); + assert_eq!( + msg.states[10].sid.code, 0, + "incorrect value for states[10].sid.code, expected 0, is {}", + msg.states[10].sid.code + ); + assert_eq!( + msg.states[10].sid.reserved, 0, + "incorrect value for states[10].sid.reserved, expected 0, is {}", + msg.states[10].sid.reserved + ); + assert_eq!( + msg.states[10].sid.sat, 0, + "incorrect value for states[10].sid.sat, expected 0, is {}", + msg.states[10].sid.sat + ); + assert_eq!( + msg.states[10].state, 0, + "incorrect value for states[10].state, expected 0, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepB" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepB; + let payload: Vec = vec![ + 85, 19, 0, 246, 215, 99, 1, 202, 0, 0, 0, 250, 249, 27, 66, 1, 203, 0, 0, 0, 40, 143, + 11, 66, 1, 208, 0, 0, 0, 190, 200, 21, 66, 1, 212, 0, 0, 0, 251, 233, 26, 66, 1, 217, + 0, 0, 0, 209, 238, 39, 66, 1, 218, 0, 0, 0, 162, 219, 21, 66, 1, 220, 0, 0, 0, 162, + 197, 25, 66, 1, 222, 0, 0, 0, 14, 35, 28, 66, 1, 225, 0, 0, 0, 9, 153, 43, 66, 0, 0, 0, + 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 128, 191, 20, 31, + ]; + + assert_eq!( + MsgTrackingStateDepB::MSG_ID, + 0x13, + "Incorrect message type, expected 0x13, is {}", + MsgTrackingStateDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(3.89941177368164062e+01), + "incorrect value for states[0].cn0, expected 3.89941177368164062e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].sid.code, 0, + "incorrect value for states[0].sid.code, expected 0, is {}", + msg.states[0].sid.code + ); + assert_eq!( + msg.states[0].sid.reserved, 0, + "incorrect value for states[0].sid.reserved, expected 0, is {}", + msg.states[0].sid.reserved + ); + assert_eq!( + msg.states[0].sid.sat, 202, + "incorrect value for states[0].sid.sat, expected 202, is {}", + msg.states[0].sid.sat + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(3.48898010253906250e+01), + "incorrect value for states[1].cn0, expected 3.48898010253906250e+01, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].sid.code, 0, + "incorrect value for states[1].sid.code, expected 0, is {}", + msg.states[1].sid.code + ); + assert_eq!( + msg.states[1].sid.reserved, 0, + "incorrect value for states[1].sid.reserved, expected 0, is {}", + msg.states[1].sid.reserved + ); + assert_eq!( + msg.states[1].sid.sat, 203, + "incorrect value for states[1].sid.sat, expected 203, is {}", + msg.states[1].sid.sat + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(3.74460372924804688e+01), + "incorrect value for states[2].cn0, expected 3.74460372924804688e+01, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].sid.code, 0, + "incorrect value for states[2].sid.code, expected 0, is {}", + msg.states[2].sid.code + ); + assert_eq!( + msg.states[2].sid.reserved, 0, + "incorrect value for states[2].sid.reserved, expected 0, is {}", + msg.states[2].sid.reserved + ); + assert_eq!( + msg.states[2].sid.sat, 208, + "incorrect value for states[2].sid.sat, expected 208, is {}", + msg.states[2].sid.sat + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(3.87284965515136719e+01), + "incorrect value for states[3].cn0, expected 3.87284965515136719e+01, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].sid.code, 0, + "incorrect value for states[3].sid.code, expected 0, is {}", + msg.states[3].sid.code + ); + assert_eq!( + msg.states[3].sid.reserved, 0, + "incorrect value for states[3].sid.reserved, expected 0, is {}", + msg.states[3].sid.reserved + ); + assert_eq!( + msg.states[3].sid.sat, 212, + "incorrect value for states[3].sid.sat, expected 212, is {}", + msg.states[3].sid.sat + ); + assert_eq!( + msg.states[3].state, 1, + "incorrect value for states[3].state, expected 1, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(4.19832191467285156e+01), + "incorrect value for states[4].cn0, expected 4.19832191467285156e+01, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].sid.code, 0, + "incorrect value for states[4].sid.code, expected 0, is {}", + msg.states[4].sid.code + ); + assert_eq!( + msg.states[4].sid.reserved, 0, + "incorrect value for states[4].sid.reserved, expected 0, is {}", + msg.states[4].sid.reserved + ); + assert_eq!( + msg.states[4].sid.sat, 217, + "incorrect value for states[4].sid.sat, expected 217, is {}", + msg.states[4].sid.sat + ); + assert_eq!( + msg.states[4].state, 1, + "incorrect value for states[4].state, expected 1, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(3.74644851684570312e+01), + "incorrect value for states[5].cn0, expected 3.74644851684570312e+01, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].sid.code, 0, + "incorrect value for states[5].sid.code, expected 0, is {}", + msg.states[5].sid.code + ); + assert_eq!( + msg.states[5].sid.reserved, 0, + "incorrect value for states[5].sid.reserved, expected 0, is {}", + msg.states[5].sid.reserved + ); + assert_eq!( + msg.states[5].sid.sat, 218, + "incorrect value for states[5].sid.sat, expected 218, is {}", + msg.states[5].sid.sat + ); + assert_eq!( + msg.states[5].state, 1, + "incorrect value for states[5].state, expected 1, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(3.84430007934570312e+01), + "incorrect value for states[6].cn0, expected 3.84430007934570312e+01, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].sid.code, 0, + "incorrect value for states[6].sid.code, expected 0, is {}", + msg.states[6].sid.code + ); + assert_eq!( + msg.states[6].sid.reserved, 0, + "incorrect value for states[6].sid.reserved, expected 0, is {}", + msg.states[6].sid.reserved + ); + assert_eq!( + msg.states[6].sid.sat, 220, + "incorrect value for states[6].sid.sat, expected 220, is {}", + msg.states[6].sid.sat + ); + assert_eq!( + msg.states[6].state, 1, + "incorrect value for states[6].state, expected 1, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(3.90342330932617188e+01), + "incorrect value for states[7].cn0, expected 3.90342330932617188e+01, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].sid.code, 0, + "incorrect value for states[7].sid.code, expected 0, is {}", + msg.states[7].sid.code + ); + assert_eq!( + msg.states[7].sid.reserved, 0, + "incorrect value for states[7].sid.reserved, expected 0, is {}", + msg.states[7].sid.reserved + ); + assert_eq!( + msg.states[7].sid.sat, 222, + "incorrect value for states[7].sid.sat, expected 222, is {}", + msg.states[7].sid.sat + ); + assert_eq!( + msg.states[7].state, 1, + "incorrect value for states[7].state, expected 1, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(4.28994483947753906e+01), + "incorrect value for states[8].cn0, expected 4.28994483947753906e+01, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].sid.code, 0, + "incorrect value for states[8].sid.code, expected 0, is {}", + msg.states[8].sid.code + ); + assert_eq!( + msg.states[8].sid.reserved, 0, + "incorrect value for states[8].sid.reserved, expected 0, is {}", + msg.states[8].sid.reserved + ); + assert_eq!( + msg.states[8].sid.sat, 225, + "incorrect value for states[8].sid.sat, expected 225, is {}", + msg.states[8].sid.sat + ); + assert_eq!( + msg.states[8].state, 1, + "incorrect value for states[8].state, expected 1, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[9].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].sid.code, 0, + "incorrect value for states[9].sid.code, expected 0, is {}", + msg.states[9].sid.code + ); + assert_eq!( + msg.states[9].sid.reserved, 0, + "incorrect value for states[9].sid.reserved, expected 0, is {}", + msg.states[9].sid.reserved + ); + assert_eq!( + msg.states[9].sid.sat, 0, + "incorrect value for states[9].sid.sat, expected 0, is {}", + msg.states[9].sid.sat + ); + assert_eq!( + msg.states[9].state, 0, + "incorrect value for states[9].state, expected 0, is {}", + msg.states[9].state + ); + assert!(msg.states[10].cn0.almost_eq( -1.00000000000000000e+00 ), "incorrect value for states[10].cn0, expected -1.00000000000000000e+00, is {:e}", msg.states[10].cn0); + assert_eq!( + msg.states[10].sid.code, 0, + "incorrect value for states[10].sid.code, expected 0, is {}", + msg.states[10].sid.code + ); + assert_eq!( + msg.states[10].sid.reserved, 0, + "incorrect value for states[10].sid.reserved, expected 0, is {}", + msg.states[10].sid.reserved + ); + assert_eq!( + msg.states[10].sid.sat, 0, + "incorrect value for states[10].sid.sat, expected 0, is {}", + msg.states[10].sid.sat + ); + assert_eq!( + msg.states[10].state, 0, + "incorrect value for states[10].state, expected 0, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepB" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepB; + let payload: Vec = vec![ + 85, 19, 0, 246, 215, 99, 1, 202, 0, 0, 0, 123, 209, 27, 66, 1, 203, 0, 0, 0, 214, 64, + 15, 66, 1, 208, 0, 0, 0, 56, 55, 22, 66, 1, 212, 0, 0, 0, 91, 142, 27, 66, 1, 217, 0, + 0, 0, 253, 154, 41, 66, 1, 218, 0, 0, 0, 128, 142, 22, 66, 1, 220, 0, 0, 0, 17, 174, + 23, 66, 1, 222, 0, 0, 0, 155, 2, 29, 66, 1, 225, 0, 0, 0, 162, 100, 42, 66, 0, 0, 0, 0, + 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 128, 191, 233, 71, + ]; + + assert_eq!( + MsgTrackingStateDepB::MSG_ID, + 0x13, + "Incorrect message type, expected 0x13, is {}", + MsgTrackingStateDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(3.89545707702636719e+01), + "incorrect value for states[0].cn0, expected 3.89545707702636719e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].sid.code, 0, + "incorrect value for states[0].sid.code, expected 0, is {}", + msg.states[0].sid.code + ); + assert_eq!( + msg.states[0].sid.reserved, 0, + "incorrect value for states[0].sid.reserved, expected 0, is {}", + msg.states[0].sid.reserved + ); + assert_eq!( + msg.states[0].sid.sat, 202, + "incorrect value for states[0].sid.sat, expected 202, is {}", + msg.states[0].sid.sat + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(3.58133163452148438e+01), + "incorrect value for states[1].cn0, expected 3.58133163452148438e+01, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].sid.code, 0, + "incorrect value for states[1].sid.code, expected 0, is {}", + msg.states[1].sid.code + ); + assert_eq!( + msg.states[1].sid.reserved, 0, + "incorrect value for states[1].sid.reserved, expected 0, is {}", + msg.states[1].sid.reserved + ); + assert_eq!( + msg.states[1].sid.sat, 203, + "incorrect value for states[1].sid.sat, expected 203, is {}", + msg.states[1].sid.sat + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(3.75539245605468750e+01), + "incorrect value for states[2].cn0, expected 3.75539245605468750e+01, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].sid.code, 0, + "incorrect value for states[2].sid.code, expected 0, is {}", + msg.states[2].sid.code + ); + assert_eq!( + msg.states[2].sid.reserved, 0, + "incorrect value for states[2].sid.reserved, expected 0, is {}", + msg.states[2].sid.reserved + ); + assert_eq!( + msg.states[2].sid.sat, 208, + "incorrect value for states[2].sid.sat, expected 208, is {}", + msg.states[2].sid.sat + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(3.88890190124511719e+01), + "incorrect value for states[3].cn0, expected 3.88890190124511719e+01, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].sid.code, 0, + "incorrect value for states[3].sid.code, expected 0, is {}", + msg.states[3].sid.code + ); + assert_eq!( + msg.states[3].sid.reserved, 0, + "incorrect value for states[3].sid.reserved, expected 0, is {}", + msg.states[3].sid.reserved + ); + assert_eq!( + msg.states[3].sid.sat, 212, + "incorrect value for states[3].sid.sat, expected 212, is {}", + msg.states[3].sid.sat + ); + assert_eq!( + msg.states[3].state, 1, + "incorrect value for states[3].state, expected 1, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(4.24013557434082031e+01), + "incorrect value for states[4].cn0, expected 4.24013557434082031e+01, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].sid.code, 0, + "incorrect value for states[4].sid.code, expected 0, is {}", + msg.states[4].sid.code + ); + assert_eq!( + msg.states[4].sid.reserved, 0, + "incorrect value for states[4].sid.reserved, expected 0, is {}", + msg.states[4].sid.reserved + ); + assert_eq!( + msg.states[4].sid.sat, 217, + "incorrect value for states[4].sid.sat, expected 217, is {}", + msg.states[4].sid.sat + ); + assert_eq!( + msg.states[4].state, 1, + "incorrect value for states[4].state, expected 1, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(3.76391601562500000e+01), + "incorrect value for states[5].cn0, expected 3.76391601562500000e+01, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].sid.code, 0, + "incorrect value for states[5].sid.code, expected 0, is {}", + msg.states[5].sid.code + ); + assert_eq!( + msg.states[5].sid.reserved, 0, + "incorrect value for states[5].sid.reserved, expected 0, is {}", + msg.states[5].sid.reserved + ); + assert_eq!( + msg.states[5].sid.sat, 218, + "incorrect value for states[5].sid.sat, expected 218, is {}", + msg.states[5].sid.sat + ); + assert_eq!( + msg.states[5].state, 1, + "incorrect value for states[5].state, expected 1, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(3.79199867248535156e+01), + "incorrect value for states[6].cn0, expected 3.79199867248535156e+01, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].sid.code, 0, + "incorrect value for states[6].sid.code, expected 0, is {}", + msg.states[6].sid.code + ); + assert_eq!( + msg.states[6].sid.reserved, 0, + "incorrect value for states[6].sid.reserved, expected 0, is {}", + msg.states[6].sid.reserved + ); + assert_eq!( + msg.states[6].sid.sat, 220, + "incorrect value for states[6].sid.sat, expected 220, is {}", + msg.states[6].sid.sat + ); + assert_eq!( + msg.states[6].state, 1, + "incorrect value for states[6].state, expected 1, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(3.92525444030761719e+01), + "incorrect value for states[7].cn0, expected 3.92525444030761719e+01, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].sid.code, 0, + "incorrect value for states[7].sid.code, expected 0, is {}", + msg.states[7].sid.code + ); + assert_eq!( + msg.states[7].sid.reserved, 0, + "incorrect value for states[7].sid.reserved, expected 0, is {}", + msg.states[7].sid.reserved + ); + assert_eq!( + msg.states[7].sid.sat, 222, + "incorrect value for states[7].sid.sat, expected 222, is {}", + msg.states[7].sid.sat + ); + assert_eq!( + msg.states[7].state, 1, + "incorrect value for states[7].state, expected 1, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(4.25982742309570312e+01), + "incorrect value for states[8].cn0, expected 4.25982742309570312e+01, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].sid.code, 0, + "incorrect value for states[8].sid.code, expected 0, is {}", + msg.states[8].sid.code + ); + assert_eq!( + msg.states[8].sid.reserved, 0, + "incorrect value for states[8].sid.reserved, expected 0, is {}", + msg.states[8].sid.reserved + ); + assert_eq!( + msg.states[8].sid.sat, 225, + "incorrect value for states[8].sid.sat, expected 225, is {}", + msg.states[8].sid.sat + ); + assert_eq!( + msg.states[8].state, 1, + "incorrect value for states[8].state, expected 1, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[9].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].sid.code, 0, + "incorrect value for states[9].sid.code, expected 0, is {}", + msg.states[9].sid.code + ); + assert_eq!( + msg.states[9].sid.reserved, 0, + "incorrect value for states[9].sid.reserved, expected 0, is {}", + msg.states[9].sid.reserved + ); + assert_eq!( + msg.states[9].sid.sat, 0, + "incorrect value for states[9].sid.sat, expected 0, is {}", + msg.states[9].sid.sat + ); + assert_eq!( + msg.states[9].state, 0, + "incorrect value for states[9].state, expected 0, is {}", + msg.states[9].state + ); + assert!(msg.states[10].cn0.almost_eq( -1.00000000000000000e+00 ), "incorrect value for states[10].cn0, expected -1.00000000000000000e+00, is {:e}", msg.states[10].cn0); + assert_eq!( + msg.states[10].sid.code, 0, + "incorrect value for states[10].sid.code, expected 0, is {}", + msg.states[10].sid.code + ); + assert_eq!( + msg.states[10].sid.reserved, 0, + "incorrect value for states[10].sid.reserved, expected 0, is {}", + msg.states[10].sid.reserved + ); + assert_eq!( + msg.states[10].sid.sat, 0, + "incorrect value for states[10].sid.sat, expected 0, is {}", + msg.states[10].sid.sat + ); + assert_eq!( + msg.states[10].state, 0, + "incorrect value for states[10].state, expected 0, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepB" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepB; + let payload: Vec = vec![ + 85, 19, 0, 246, 215, 99, 1, 202, 0, 0, 0, 120, 122, 29, 66, 1, 203, 0, 0, 0, 66, 22, + 18, 66, 1, 208, 0, 0, 0, 153, 163, 24, 66, 1, 212, 0, 0, 0, 178, 204, 28, 66, 1, 217, + 0, 0, 0, 220, 59, 38, 66, 1, 218, 0, 0, 0, 161, 27, 20, 66, 1, 220, 0, 0, 0, 125, 107, + 24, 66, 1, 222, 0, 0, 0, 242, 46, 28, 66, 1, 225, 0, 0, 0, 231, 130, 41, 66, 0, 0, 0, + 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 128, 191, 73, 193, + ]; + + assert_eq!( + MsgTrackingStateDepB::MSG_ID, + 0x13, + "Incorrect message type, expected 0x13, is {}", + MsgTrackingStateDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(3.93695983886718750e+01), + "incorrect value for states[0].cn0, expected 3.93695983886718750e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].sid.code, 0, + "incorrect value for states[0].sid.code, expected 0, is {}", + msg.states[0].sid.code + ); + assert_eq!( + msg.states[0].sid.reserved, 0, + "incorrect value for states[0].sid.reserved, expected 0, is {}", + msg.states[0].sid.reserved + ); + assert_eq!( + msg.states[0].sid.sat, 202, + "incorrect value for states[0].sid.sat, expected 202, is {}", + msg.states[0].sid.sat + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(3.65217361450195312e+01), + "incorrect value for states[1].cn0, expected 3.65217361450195312e+01, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].sid.code, 0, + "incorrect value for states[1].sid.code, expected 0, is {}", + msg.states[1].sid.code + ); + assert_eq!( + msg.states[1].sid.reserved, 0, + "incorrect value for states[1].sid.reserved, expected 0, is {}", + msg.states[1].sid.reserved + ); + assert_eq!( + msg.states[1].sid.sat, 203, + "incorrect value for states[1].sid.sat, expected 203, is {}", + msg.states[1].sid.sat + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(3.81597633361816406e+01), + "incorrect value for states[2].cn0, expected 3.81597633361816406e+01, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].sid.code, 0, + "incorrect value for states[2].sid.code, expected 0, is {}", + msg.states[2].sid.code + ); + assert_eq!( + msg.states[2].sid.reserved, 0, + "incorrect value for states[2].sid.reserved, expected 0, is {}", + msg.states[2].sid.reserved + ); + assert_eq!( + msg.states[2].sid.sat, 208, + "incorrect value for states[2].sid.sat, expected 208, is {}", + msg.states[2].sid.sat + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(3.91998977661132812e+01), + "incorrect value for states[3].cn0, expected 3.91998977661132812e+01, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].sid.code, 0, + "incorrect value for states[3].sid.code, expected 0, is {}", + msg.states[3].sid.code + ); + assert_eq!( + msg.states[3].sid.reserved, 0, + "incorrect value for states[3].sid.reserved, expected 0, is {}", + msg.states[3].sid.reserved + ); + assert_eq!( + msg.states[3].sid.sat, 212, + "incorrect value for states[3].sid.sat, expected 212, is {}", + msg.states[3].sid.sat + ); + assert_eq!( + msg.states[3].state, 1, + "incorrect value for states[3].state, expected 1, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(4.15584564208984375e+01), + "incorrect value for states[4].cn0, expected 4.15584564208984375e+01, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].sid.code, 0, + "incorrect value for states[4].sid.code, expected 0, is {}", + msg.states[4].sid.code + ); + assert_eq!( + msg.states[4].sid.reserved, 0, + "incorrect value for states[4].sid.reserved, expected 0, is {}", + msg.states[4].sid.reserved + ); + assert_eq!( + msg.states[4].sid.sat, 217, + "incorrect value for states[4].sid.sat, expected 217, is {}", + msg.states[4].sid.sat + ); + assert_eq!( + msg.states[4].state, 1, + "incorrect value for states[4].state, expected 1, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(3.70269813537597656e+01), + "incorrect value for states[5].cn0, expected 3.70269813537597656e+01, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].sid.code, 0, + "incorrect value for states[5].sid.code, expected 0, is {}", + msg.states[5].sid.code + ); + assert_eq!( + msg.states[5].sid.reserved, 0, + "incorrect value for states[5].sid.reserved, expected 0, is {}", + msg.states[5].sid.reserved + ); + assert_eq!( + msg.states[5].sid.sat, 218, + "incorrect value for states[5].sid.sat, expected 218, is {}", + msg.states[5].sid.sat + ); + assert_eq!( + msg.states[5].state, 1, + "incorrect value for states[5].state, expected 1, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(3.81049690246582031e+01), + "incorrect value for states[6].cn0, expected 3.81049690246582031e+01, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].sid.code, 0, + "incorrect value for states[6].sid.code, expected 0, is {}", + msg.states[6].sid.code + ); + assert_eq!( + msg.states[6].sid.reserved, 0, + "incorrect value for states[6].sid.reserved, expected 0, is {}", + msg.states[6].sid.reserved + ); + assert_eq!( + msg.states[6].sid.sat, 220, + "incorrect value for states[6].sid.sat, expected 220, is {}", + msg.states[6].sid.sat + ); + assert_eq!( + msg.states[6].state, 1, + "incorrect value for states[6].state, expected 1, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(3.90458450317382812e+01), + "incorrect value for states[7].cn0, expected 3.90458450317382812e+01, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].sid.code, 0, + "incorrect value for states[7].sid.code, expected 0, is {}", + msg.states[7].sid.code + ); + assert_eq!( + msg.states[7].sid.reserved, 0, + "incorrect value for states[7].sid.reserved, expected 0, is {}", + msg.states[7].sid.reserved + ); + assert_eq!( + msg.states[7].sid.sat, 222, + "incorrect value for states[7].sid.sat, expected 222, is {}", + msg.states[7].sid.sat + ); + assert_eq!( + msg.states[7].state, 1, + "incorrect value for states[7].state, expected 1, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(4.23778343200683594e+01), + "incorrect value for states[8].cn0, expected 4.23778343200683594e+01, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].sid.code, 0, + "incorrect value for states[8].sid.code, expected 0, is {}", + msg.states[8].sid.code + ); + assert_eq!( + msg.states[8].sid.reserved, 0, + "incorrect value for states[8].sid.reserved, expected 0, is {}", + msg.states[8].sid.reserved + ); + assert_eq!( + msg.states[8].sid.sat, 225, + "incorrect value for states[8].sid.sat, expected 225, is {}", + msg.states[8].sid.sat + ); + assert_eq!( + msg.states[8].state, 1, + "incorrect value for states[8].state, expected 1, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[9].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].sid.code, 0, + "incorrect value for states[9].sid.code, expected 0, is {}", + msg.states[9].sid.code + ); + assert_eq!( + msg.states[9].sid.reserved, 0, + "incorrect value for states[9].sid.reserved, expected 0, is {}", + msg.states[9].sid.reserved + ); + assert_eq!( + msg.states[9].sid.sat, 0, + "incorrect value for states[9].sid.sat, expected 0, is {}", + msg.states[9].sid.sat + ); + assert_eq!( + msg.states[9].state, 0, + "incorrect value for states[9].state, expected 0, is {}", + msg.states[9].state + ); + assert!(msg.states[10].cn0.almost_eq( -1.00000000000000000e+00 ), "incorrect value for states[10].cn0, expected -1.00000000000000000e+00, is {:e}", msg.states[10].cn0); + assert_eq!( + msg.states[10].sid.code, 0, + "incorrect value for states[10].sid.code, expected 0, is {}", + msg.states[10].sid.code + ); + assert_eq!( + msg.states[10].sid.reserved, 0, + "incorrect value for states[10].sid.reserved, expected 0, is {}", + msg.states[10].sid.reserved + ); + assert_eq!( + msg.states[10].sid.sat, 0, + "incorrect value for states[10].sid.sat, expected 0, is {}", + msg.states[10].sid.sat + ); + assert_eq!( + msg.states[10].state, 0, + "incorrect value for states[10].state, expected 0, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepB" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDepB; + let payload: Vec = vec![ + 85, 19, 0, 246, 215, 99, 1, 202, 0, 0, 0, 103, 208, 30, 66, 1, 203, 0, 0, 0, 117, 24, + 18, 66, 1, 208, 0, 0, 0, 200, 173, 20, 66, 1, 212, 0, 0, 0, 137, 68, 27, 66, 1, 217, 0, + 0, 0, 243, 51, 40, 66, 1, 218, 0, 0, 0, 225, 58, 23, 66, 1, 220, 0, 0, 0, 132, 221, 22, + 66, 1, 222, 0, 0, 0, 157, 29, 26, 66, 1, 225, 0, 0, 0, 133, 21, 41, 66, 0, 0, 0, 0, 0, + 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 128, 191, 126, 47, + ]; + + assert_eq!( + MsgTrackingStateDepB::MSG_ID, + 0x13, + "Incorrect message type, expected 0x13, is {}", + MsgTrackingStateDepB::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0xd7f6, + "incorrect sender id, expected 0xd7f6, is {}", + sender_id + ); + assert!( + msg.states[0].cn0.almost_eq(3.97035179138183594e+01), + "incorrect value for states[0].cn0, expected 3.97035179138183594e+01, is {:e}", + msg.states[0].cn0 + ); + assert_eq!( + msg.states[0].sid.code, 0, + "incorrect value for states[0].sid.code, expected 0, is {}", + msg.states[0].sid.code + ); + assert_eq!( + msg.states[0].sid.reserved, 0, + "incorrect value for states[0].sid.reserved, expected 0, is {}", + msg.states[0].sid.reserved + ); + assert_eq!( + msg.states[0].sid.sat, 202, + "incorrect value for states[0].sid.sat, expected 202, is {}", + msg.states[0].sid.sat + ); + assert_eq!( + msg.states[0].state, 1, + "incorrect value for states[0].state, expected 1, is {}", + msg.states[0].state + ); + assert!( + msg.states[1].cn0.almost_eq(3.65238838195800781e+01), + "incorrect value for states[1].cn0, expected 3.65238838195800781e+01, is {:e}", + msg.states[1].cn0 + ); + assert_eq!( + msg.states[1].sid.code, 0, + "incorrect value for states[1].sid.code, expected 0, is {}", + msg.states[1].sid.code + ); + assert_eq!( + msg.states[1].sid.reserved, 0, + "incorrect value for states[1].sid.reserved, expected 0, is {}", + msg.states[1].sid.reserved + ); + assert_eq!( + msg.states[1].sid.sat, 203, + "incorrect value for states[1].sid.sat, expected 203, is {}", + msg.states[1].sid.sat + ); + assert_eq!( + msg.states[1].state, 1, + "incorrect value for states[1].state, expected 1, is {}", + msg.states[1].state + ); + assert!( + msg.states[2].cn0.almost_eq(3.71697082519531250e+01), + "incorrect value for states[2].cn0, expected 3.71697082519531250e+01, is {:e}", + msg.states[2].cn0 + ); + assert_eq!( + msg.states[2].sid.code, 0, + "incorrect value for states[2].sid.code, expected 0, is {}", + msg.states[2].sid.code + ); + assert_eq!( + msg.states[2].sid.reserved, 0, + "incorrect value for states[2].sid.reserved, expected 0, is {}", + msg.states[2].sid.reserved + ); + assert_eq!( + msg.states[2].sid.sat, 208, + "incorrect value for states[2].sid.sat, expected 208, is {}", + msg.states[2].sid.sat + ); + assert_eq!( + msg.states[2].state, 1, + "incorrect value for states[2].state, expected 1, is {}", + msg.states[2].state + ); + assert!( + msg.states[3].cn0.almost_eq(3.88169288635253906e+01), + "incorrect value for states[3].cn0, expected 3.88169288635253906e+01, is {:e}", + msg.states[3].cn0 + ); + assert_eq!( + msg.states[3].sid.code, 0, + "incorrect value for states[3].sid.code, expected 0, is {}", + msg.states[3].sid.code + ); + assert_eq!( + msg.states[3].sid.reserved, 0, + "incorrect value for states[3].sid.reserved, expected 0, is {}", + msg.states[3].sid.reserved + ); + assert_eq!( + msg.states[3].sid.sat, 212, + "incorrect value for states[3].sid.sat, expected 212, is {}", + msg.states[3].sid.sat + ); + assert_eq!( + msg.states[3].state, 1, + "incorrect value for states[3].state, expected 1, is {}", + msg.states[3].state + ); + assert!( + msg.states[4].cn0.almost_eq(4.20507316589355469e+01), + "incorrect value for states[4].cn0, expected 4.20507316589355469e+01, is {:e}", + msg.states[4].cn0 + ); + assert_eq!( + msg.states[4].sid.code, 0, + "incorrect value for states[4].sid.code, expected 0, is {}", + msg.states[4].sid.code + ); + assert_eq!( + msg.states[4].sid.reserved, 0, + "incorrect value for states[4].sid.reserved, expected 0, is {}", + msg.states[4].sid.reserved + ); + assert_eq!( + msg.states[4].sid.sat, 217, + "incorrect value for states[4].sid.sat, expected 217, is {}", + msg.states[4].sid.sat + ); + assert_eq!( + msg.states[4].state, 1, + "incorrect value for states[4].state, expected 1, is {}", + msg.states[4].state + ); + assert!( + msg.states[5].cn0.almost_eq(3.78074989318847656e+01), + "incorrect value for states[5].cn0, expected 3.78074989318847656e+01, is {:e}", + msg.states[5].cn0 + ); + assert_eq!( + msg.states[5].sid.code, 0, + "incorrect value for states[5].sid.code, expected 0, is {}", + msg.states[5].sid.code + ); + assert_eq!( + msg.states[5].sid.reserved, 0, + "incorrect value for states[5].sid.reserved, expected 0, is {}", + msg.states[5].sid.reserved + ); + assert_eq!( + msg.states[5].sid.sat, 218, + "incorrect value for states[5].sid.sat, expected 218, is {}", + msg.states[5].sid.sat + ); + assert_eq!( + msg.states[5].state, 1, + "incorrect value for states[5].state, expected 1, is {}", + msg.states[5].state + ); + assert!( + msg.states[6].cn0.almost_eq(3.77163238525390625e+01), + "incorrect value for states[6].cn0, expected 3.77163238525390625e+01, is {:e}", + msg.states[6].cn0 + ); + assert_eq!( + msg.states[6].sid.code, 0, + "incorrect value for states[6].sid.code, expected 0, is {}", + msg.states[6].sid.code + ); + assert_eq!( + msg.states[6].sid.reserved, 0, + "incorrect value for states[6].sid.reserved, expected 0, is {}", + msg.states[6].sid.reserved + ); + assert_eq!( + msg.states[6].sid.sat, 220, + "incorrect value for states[6].sid.sat, expected 220, is {}", + msg.states[6].sid.sat + ); + assert_eq!( + msg.states[6].state, 1, + "incorrect value for states[6].state, expected 1, is {}", + msg.states[6].state + ); + assert!( + msg.states[7].cn0.almost_eq(3.85289192199707031e+01), + "incorrect value for states[7].cn0, expected 3.85289192199707031e+01, is {:e}", + msg.states[7].cn0 + ); + assert_eq!( + msg.states[7].sid.code, 0, + "incorrect value for states[7].sid.code, expected 0, is {}", + msg.states[7].sid.code + ); + assert_eq!( + msg.states[7].sid.reserved, 0, + "incorrect value for states[7].sid.reserved, expected 0, is {}", + msg.states[7].sid.reserved + ); + assert_eq!( + msg.states[7].sid.sat, 222, + "incorrect value for states[7].sid.sat, expected 222, is {}", + msg.states[7].sid.sat + ); + assert_eq!( + msg.states[7].state, 1, + "incorrect value for states[7].state, expected 1, is {}", + msg.states[7].state + ); + assert!( + msg.states[8].cn0.almost_eq(4.22710151672363281e+01), + "incorrect value for states[8].cn0, expected 4.22710151672363281e+01, is {:e}", + msg.states[8].cn0 + ); + assert_eq!( + msg.states[8].sid.code, 0, + "incorrect value for states[8].sid.code, expected 0, is {}", + msg.states[8].sid.code + ); + assert_eq!( + msg.states[8].sid.reserved, 0, + "incorrect value for states[8].sid.reserved, expected 0, is {}", + msg.states[8].sid.reserved + ); + assert_eq!( + msg.states[8].sid.sat, 225, + "incorrect value for states[8].sid.sat, expected 225, is {}", + msg.states[8].sid.sat + ); + assert_eq!( + msg.states[8].state, 1, + "incorrect value for states[8].state, expected 1, is {}", + msg.states[8].state + ); + assert!( + msg.states[9].cn0.almost_eq(-1.00000000000000000e+00), + "incorrect value for states[9].cn0, expected -1.00000000000000000e+00, is {:e}", + msg.states[9].cn0 + ); + assert_eq!( + msg.states[9].sid.code, 0, + "incorrect value for states[9].sid.code, expected 0, is {}", + msg.states[9].sid.code + ); + assert_eq!( + msg.states[9].sid.reserved, 0, + "incorrect value for states[9].sid.reserved, expected 0, is {}", + msg.states[9].sid.reserved + ); + assert_eq!( + msg.states[9].sid.sat, 0, + "incorrect value for states[9].sid.sat, expected 0, is {}", + msg.states[9].sid.sat + ); + assert_eq!( + msg.states[9].state, 0, + "incorrect value for states[9].state, expected 0, is {}", + msg.states[9].state + ); + assert!(msg.states[10].cn0.almost_eq( -1.00000000000000000e+00 ), "incorrect value for states[10].cn0, expected -1.00000000000000000e+00, is {:e}", msg.states[10].cn0); + assert_eq!( + msg.states[10].sid.code, 0, + "incorrect value for states[10].sid.code, expected 0, is {}", + msg.states[10].sid.code + ); + assert_eq!( + msg.states[10].sid.reserved, 0, + "incorrect value for states[10].sid.reserved, expected 0, is {}", + msg.states[10].sid.reserved + ); + assert_eq!( + msg.states[10].sid.sat, 0, + "incorrect value for states[10].sid.sat, expected 0, is {}", + msg.states[10].sid.sat + ); + assert_eq!( + msg.states[10].state, 0, + "incorrect value for states[10].state, expected 0, is {}", + msg.states[10].state + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDepB" + ), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_tracking_49.rs b/rust/sbp/tests/auto_check_sbp_tracking_49.rs new file mode 100644 index 0000000000..ed78d3c820 --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_tracking_49.rs @@ -0,0 +1,819 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/tracking/test_MsgTrackingStateDetailedDep.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_tracking_49() { + { + use sbp::messages::tracking::MsgTrackingStateDetailedDep; + let payload: Vec = vec![ + 85, 17, 0, 59, 103, 55, 163, 151, 112, 215, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 39, 5, 0, 0, 169, 177, 208, 54, 15, 0, 0, 0, 85, 61, 0, 0, 39, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 40, 0, 108, 1, 0, 11, 0, 0, 9, 166, 214, + ]; + + assert_eq!( + MsgTrackingStateDetailedDep::MSG_ID, + 0x11, + "Incorrect message type, expected 0x11, is {}", + MsgTrackingStateDetailedDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x673b, + "incorrect sender id, expected 0x673b, is {}", + sender_id + ); + assert_eq!( + msg.L.f, 169, + "incorrect value for L.f, expected 169, is {}", + msg.L.f + ); + assert_eq!( + msg.L.i, 1319, + "incorrect value for L.i, expected 1319, is {}", + msg.L.i + ); + assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!( + msg.P_std, 0, + "incorrect value for P_std, expected 0, is {}", + msg.P_std + ); + assert_eq!( + msg.acceleration, 108, + "incorrect value for acceleration, expected 108, is {}", + msg.acceleration + ); + assert_eq!( + msg.clock_drift, 0, + "incorrect value for clock_drift, expected 0, is {}", + msg.clock_drift + ); + assert_eq!( + msg.clock_offset, 0, + "incorrect value for clock_offset, expected 0, is {}", + msg.clock_offset + ); + assert_eq!( + msg.cn0, 177, + "incorrect value for cn0, expected 177, is {}", + msg.cn0 + ); + assert_eq!( + msg.corr_spacing, 40, + "incorrect value for corr_spacing, expected 40, is {}", + msg.corr_spacing + ); + assert_eq!( + msg.doppler, 15701, + "incorrect value for doppler, expected 15701, is {}", + msg.doppler + ); + assert_eq!( + msg.doppler_std, 39, + "incorrect value for doppler_std, expected 39, is {}", + msg.doppler_std + ); + assert_eq!( + msg.lock, 14032, + "incorrect value for lock, expected 14032, is {}", + msg.lock + ); + assert_eq!( + msg.misc_flags, 9, + "incorrect value for misc_flags, expected 9, is {}", + msg.misc_flags + ); + assert_eq!( + msg.nav_flags, 0, + "incorrect value for nav_flags, expected 0, is {}", + msg.nav_flags + ); + assert_eq!( + msg.pset_flags, 0, + "incorrect value for pset_flags, expected 0, is {}", + msg.pset_flags + ); + assert_eq!( + msg.recv_time, 7909447587, + "incorrect value for recv_time, expected 7909447587, is {}", + msg.recv_time + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 15, + "incorrect value for sid.sat, expected 15, is {}", + msg.sid.sat + ); + assert_eq!( + msg.sync_flags, 1, + "incorrect value for sync_flags, expected 1, is {}", + msg.sync_flags + ); + assert_eq!( + msg.tot.tow, 0, + "incorrect value for tot.tow, expected 0, is {}", + msg.tot.tow + ); + assert_eq!( + msg.tot.wn, 0, + "incorrect value for tot.wn, expected 0, is {}", + msg.tot.wn + ); + assert_eq!( + msg.tow_flags, 0, + "incorrect value for tow_flags, expected 0, is {}", + msg.tow_flags + ); + assert_eq!( + msg.track_flags, 11, + "incorrect value for track_flags, expected 11, is {}", + msg.track_flags + ); + assert_eq!( + msg.uptime, 1, + "incorrect value for uptime, expected 1, is {}", + msg.uptime + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDetailedDep" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDetailedDep; + let payload: Vec = vec![ + 85, 17, 0, 59, 103, 55, 97, 251, 61, 245, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 7, 0, 0, 14, 175, 208, 54, 15, 0, 0, 0, 51, 61, 0, 0, 30, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 40, 0, 224, 1, 0, 11, 0, 0, 9, 136, 179, + ]; + + assert_eq!( + MsgTrackingStateDetailedDep::MSG_ID, + 0x11, + "Incorrect message type, expected 0x11, is {}", + MsgTrackingStateDetailedDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x673b, + "incorrect sender id, expected 0x673b, is {}", + sender_id + ); + assert_eq!( + msg.L.f, 14, + "incorrect value for L.f, expected 14, is {}", + msg.L.f + ); + assert_eq!( + msg.L.i, 1810, + "incorrect value for L.i, expected 1810, is {}", + msg.L.i + ); + assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!( + msg.P_std, 0, + "incorrect value for P_std, expected 0, is {}", + msg.P_std + ); + assert_eq!( + msg.acceleration, -32, + "incorrect value for acceleration, expected -32, is {}", + msg.acceleration + ); + assert_eq!( + msg.clock_drift, 0, + "incorrect value for clock_drift, expected 0, is {}", + msg.clock_drift + ); + assert_eq!( + msg.clock_offset, 0, + "incorrect value for clock_offset, expected 0, is {}", + msg.clock_offset + ); + assert_eq!( + msg.cn0, 175, + "incorrect value for cn0, expected 175, is {}", + msg.cn0 + ); + assert_eq!( + msg.corr_spacing, 40, + "incorrect value for corr_spacing, expected 40, is {}", + msg.corr_spacing + ); + assert_eq!( + msg.doppler, 15667, + "incorrect value for doppler, expected 15667, is {}", + msg.doppler + ); + assert_eq!( + msg.doppler_std, 30, + "incorrect value for doppler_std, expected 30, is {}", + msg.doppler_std + ); + assert_eq!( + msg.lock, 14032, + "incorrect value for lock, expected 14032, is {}", + msg.lock + ); + assert_eq!( + msg.misc_flags, 9, + "incorrect value for misc_flags, expected 9, is {}", + msg.misc_flags + ); + assert_eq!( + msg.nav_flags, 0, + "incorrect value for nav_flags, expected 0, is {}", + msg.nav_flags + ); + assert_eq!( + msg.pset_flags, 0, + "incorrect value for pset_flags, expected 0, is {}", + msg.pset_flags + ); + assert_eq!( + msg.recv_time, 8409447265, + "incorrect value for recv_time, expected 8409447265, is {}", + msg.recv_time + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 15, + "incorrect value for sid.sat, expected 15, is {}", + msg.sid.sat + ); + assert_eq!( + msg.sync_flags, 1, + "incorrect value for sync_flags, expected 1, is {}", + msg.sync_flags + ); + assert_eq!( + msg.tot.tow, 0, + "incorrect value for tot.tow, expected 0, is {}", + msg.tot.tow + ); + assert_eq!( + msg.tot.wn, 0, + "incorrect value for tot.wn, expected 0, is {}", + msg.tot.wn + ); + assert_eq!( + msg.tow_flags, 0, + "incorrect value for tow_flags, expected 0, is {}", + msg.tow_flags + ); + assert_eq!( + msg.track_flags, 11, + "incorrect value for track_flags, expected 11, is {}", + msg.track_flags + ); + assert_eq!( + msg.uptime, 1, + "incorrect value for uptime, expected 1, is {}", + msg.uptime + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDetailedDep" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDetailedDep; + let payload: Vec = vec![ + 85, 17, 0, 59, 103, 55, 139, 218, 236, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 250, 8, 0, 0, 8, 179, 208, 54, 15, 0, 0, 0, 67, 61, 0, 0, 22, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 40, 0, 27, 1, 0, 11, 0, 2, 9, 217, 159, + ]; + + assert_eq!( + MsgTrackingStateDetailedDep::MSG_ID, + 0x11, + "Incorrect message type, expected 0x11, is {}", + MsgTrackingStateDetailedDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x673b, + "incorrect sender id, expected 0x673b, is {}", + sender_id + ); + assert_eq!( + msg.L.f, 8, + "incorrect value for L.f, expected 8, is {}", + msg.L.f + ); + assert_eq!( + msg.L.i, 2298, + "incorrect value for L.i, expected 2298, is {}", + msg.L.i + ); + assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!( + msg.P_std, 0, + "incorrect value for P_std, expected 0, is {}", + msg.P_std + ); + assert_eq!( + msg.acceleration, 27, + "incorrect value for acceleration, expected 27, is {}", + msg.acceleration + ); + assert_eq!( + msg.clock_drift, 0, + "incorrect value for clock_drift, expected 0, is {}", + msg.clock_drift + ); + assert_eq!( + msg.clock_offset, 0, + "incorrect value for clock_offset, expected 0, is {}", + msg.clock_offset + ); + assert_eq!( + msg.cn0, 179, + "incorrect value for cn0, expected 179, is {}", + msg.cn0 + ); + assert_eq!( + msg.corr_spacing, 40, + "incorrect value for corr_spacing, expected 40, is {}", + msg.corr_spacing + ); + assert_eq!( + msg.doppler, 15683, + "incorrect value for doppler, expected 15683, is {}", + msg.doppler + ); + assert_eq!( + msg.doppler_std, 22, + "incorrect value for doppler_std, expected 22, is {}", + msg.doppler_std + ); + assert_eq!( + msg.lock, 14032, + "incorrect value for lock, expected 14032, is {}", + msg.lock + ); + assert_eq!( + msg.misc_flags, 9, + "incorrect value for misc_flags, expected 9, is {}", + msg.misc_flags + ); + assert_eq!( + msg.nav_flags, 0, + "incorrect value for nav_flags, expected 0, is {}", + msg.nav_flags + ); + assert_eq!( + msg.pset_flags, 2, + "incorrect value for pset_flags, expected 2, is {}", + msg.pset_flags + ); + assert_eq!( + msg.recv_time, 8907446923, + "incorrect value for recv_time, expected 8907446923, is {}", + msg.recv_time + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 15, + "incorrect value for sid.sat, expected 15, is {}", + msg.sid.sat + ); + assert_eq!( + msg.sync_flags, 1, + "incorrect value for sync_flags, expected 1, is {}", + msg.sync_flags + ); + assert_eq!( + msg.tot.tow, 0, + "incorrect value for tot.tow, expected 0, is {}", + msg.tot.tow + ); + assert_eq!( + msg.tot.wn, 0, + "incorrect value for tot.wn, expected 0, is {}", + msg.tot.wn + ); + assert_eq!( + msg.tow_flags, 0, + "incorrect value for tow_flags, expected 0, is {}", + msg.tow_flags + ); + assert_eq!( + msg.track_flags, 11, + "incorrect value for track_flags, expected 11, is {}", + msg.track_flags + ); + assert_eq!( + msg.uptime, 2, + "incorrect value for uptime, expected 2, is {}", + msg.uptime + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDetailedDep" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDetailedDep; + let payload: Vec = vec![ + 85, 17, 0, 59, 103, 55, 255, 251, 170, 48, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 226, 10, 0, 0, 125, 181, 208, 54, 15, 0, 0, 0, 29, 61, 0, 0, 10, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 40, 0, 220, 1, 0, 11, 0, 3, 9, 66, 95, + ]; + + assert_eq!( + MsgTrackingStateDetailedDep::MSG_ID, + 0x11, + "Incorrect message type, expected 0x11, is {}", + MsgTrackingStateDetailedDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x673b, + "incorrect sender id, expected 0x673b, is {}", + sender_id + ); + assert_eq!( + msg.L.f, 125, + "incorrect value for L.f, expected 125, is {}", + msg.L.f + ); + assert_eq!( + msg.L.i, 2786, + "incorrect value for L.i, expected 2786, is {}", + msg.L.i + ); + assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!( + msg.P_std, 0, + "incorrect value for P_std, expected 0, is {}", + msg.P_std + ); + assert_eq!( + msg.acceleration, -36, + "incorrect value for acceleration, expected -36, is {}", + msg.acceleration + ); + assert_eq!( + msg.clock_drift, 0, + "incorrect value for clock_drift, expected 0, is {}", + msg.clock_drift + ); + assert_eq!( + msg.clock_offset, 0, + "incorrect value for clock_offset, expected 0, is {}", + msg.clock_offset + ); + assert_eq!( + msg.cn0, 181, + "incorrect value for cn0, expected 181, is {}", + msg.cn0 + ); + assert_eq!( + msg.corr_spacing, 40, + "incorrect value for corr_spacing, expected 40, is {}", + msg.corr_spacing + ); + assert_eq!( + msg.doppler, 15645, + "incorrect value for doppler, expected 15645, is {}", + msg.doppler + ); + assert_eq!( + msg.doppler_std, 10, + "incorrect value for doppler_std, expected 10, is {}", + msg.doppler_std + ); + assert_eq!( + msg.lock, 14032, + "incorrect value for lock, expected 14032, is {}", + msg.lock + ); + assert_eq!( + msg.misc_flags, 9, + "incorrect value for misc_flags, expected 9, is {}", + msg.misc_flags + ); + assert_eq!( + msg.nav_flags, 0, + "incorrect value for nav_flags, expected 0, is {}", + msg.nav_flags + ); + assert_eq!( + msg.pset_flags, 3, + "incorrect value for pset_flags, expected 3, is {}", + msg.pset_flags + ); + assert_eq!( + msg.recv_time, 9406446591, + "incorrect value for recv_time, expected 9406446591, is {}", + msg.recv_time + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 15, + "incorrect value for sid.sat, expected 15, is {}", + msg.sid.sat + ); + assert_eq!( + msg.sync_flags, 1, + "incorrect value for sync_flags, expected 1, is {}", + msg.sync_flags + ); + assert_eq!( + msg.tot.tow, 0, + "incorrect value for tot.tow, expected 0, is {}", + msg.tot.tow + ); + assert_eq!( + msg.tot.wn, 0, + "incorrect value for tot.wn, expected 0, is {}", + msg.tot.wn + ); + assert_eq!( + msg.tow_flags, 0, + "incorrect value for tow_flags, expected 0, is {}", + msg.tow_flags + ); + assert_eq!( + msg.track_flags, 11, + "incorrect value for track_flags, expected 11, is {}", + msg.track_flags + ); + assert_eq!( + msg.uptime, 2, + "incorrect value for uptime, expected 2, is {}", + msg.uptime + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDetailedDep" + ), + }; + } + { + use sbp::messages::tracking::MsgTrackingStateDetailedDep; + let payload: Vec = vec![ + 85, 17, 0, 59, 103, 55, 189, 95, 120, 78, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 203, 12, 0, 0, 64, 184, 208, 54, 15, 0, 0, 0, 24, 61, 0, 0, 4, 0, 3, 0, 0, 0, 0, 0, + 0, 0, 40, 0, 2, 1, 0, 11, 0, 3, 9, 194, 206, + ]; + + assert_eq!( + MsgTrackingStateDetailedDep::MSG_ID, + 0x11, + "Incorrect message type, expected 0x11, is {}", + MsgTrackingStateDetailedDep::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x673b, + "incorrect sender id, expected 0x673b, is {}", + sender_id + ); + assert_eq!( + msg.L.f, 64, + "incorrect value for L.f, expected 64, is {}", + msg.L.f + ); + assert_eq!( + msg.L.i, 3275, + "incorrect value for L.i, expected 3275, is {}", + msg.L.i + ); + assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!( + msg.P_std, 0, + "incorrect value for P_std, expected 0, is {}", + msg.P_std + ); + assert_eq!( + msg.acceleration, 2, + "incorrect value for acceleration, expected 2, is {}", + msg.acceleration + ); + assert_eq!( + msg.clock_drift, 0, + "incorrect value for clock_drift, expected 0, is {}", + msg.clock_drift + ); + assert_eq!( + msg.clock_offset, 0, + "incorrect value for clock_offset, expected 0, is {}", + msg.clock_offset + ); + assert_eq!( + msg.cn0, 184, + "incorrect value for cn0, expected 184, is {}", + msg.cn0 + ); + assert_eq!( + msg.corr_spacing, 40, + "incorrect value for corr_spacing, expected 40, is {}", + msg.corr_spacing + ); + assert_eq!( + msg.doppler, 15640, + "incorrect value for doppler, expected 15640, is {}", + msg.doppler + ); + assert_eq!( + msg.doppler_std, 4, + "incorrect value for doppler_std, expected 4, is {}", + msg.doppler_std + ); + assert_eq!( + msg.lock, 14032, + "incorrect value for lock, expected 14032, is {}", + msg.lock + ); + assert_eq!( + msg.misc_flags, 9, + "incorrect value for misc_flags, expected 9, is {}", + msg.misc_flags + ); + assert_eq!( + msg.nav_flags, 0, + "incorrect value for nav_flags, expected 0, is {}", + msg.nav_flags + ); + assert_eq!( + msg.pset_flags, 3, + "incorrect value for pset_flags, expected 3, is {}", + msg.pset_flags + ); + assert_eq!( + msg.recv_time, 9906446269, + "incorrect value for recv_time, expected 9906446269, is {}", + msg.recv_time + ); + assert_eq!( + msg.sid.code, 0, + "incorrect value for sid.code, expected 0, is {}", + msg.sid.code + ); + assert_eq!( + msg.sid.reserved, 0, + "incorrect value for sid.reserved, expected 0, is {}", + msg.sid.reserved + ); + assert_eq!( + msg.sid.sat, 15, + "incorrect value for sid.sat, expected 15, is {}", + msg.sid.sat + ); + assert_eq!( + msg.sync_flags, 1, + "incorrect value for sync_flags, expected 1, is {}", + msg.sync_flags + ); + assert_eq!( + msg.tot.tow, 0, + "incorrect value for tot.tow, expected 0, is {}", + msg.tot.tow + ); + assert_eq!( + msg.tot.wn, 0, + "incorrect value for tot.wn, expected 0, is {}", + msg.tot.wn + ); + assert_eq!( + msg.tow_flags, 0, + "incorrect value for tow_flags, expected 0, is {}", + msg.tow_flags + ); + assert_eq!( + msg.track_flags, 11, + "incorrect value for track_flags, expected 11, is {}", + msg.track_flags + ); + assert_eq!( + msg.uptime, 3, + "incorrect value for uptime, expected 3, is {}", + msg.uptime + ); + } + _ => assert!( + false, + "Invalid message type! Expected a MsgTrackingStateDetailedDep" + ), + }; + } +} diff --git a/rust/sbp/tests/auto_check_sbp_vehicle_50.rs b/rust/sbp/tests/auto_check_sbp_vehicle_50.rs new file mode 100644 index 0000000000..52fb911b5c --- /dev/null +++ b/rust/sbp/tests/auto_check_sbp_vehicle_50.rs @@ -0,0 +1,82 @@ +// +// Copyright (C) 2015-2018 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated from spec/tests/yaml/swiftnav/sbp/vehicle/test_MsgOdometry.yaml by generate.py. Do not modify by hand! + +extern crate sbp; +use sbp::messages::SBPMessage; + +trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} + +#[test] +fn test_auto_check_sbp_vehicle_50() { + { + use sbp::messages::vehicle::MsgOdometry; + let payload: Vec = vec![85, 3, 9, 66, 0, 9, 8, 0, 0, 0, 7, 0, 0, 0, 1, 52, 99]; + + assert_eq!( + MsgOdometry::MSG_ID, + 0x903, + "Incorrect message type, expected 0x903, is {}", + MsgOdometry::MSG_ID + ); + + // Test the round trip payload parsing + let mut parser = sbp::parser::Parser::new(); + let msg_result = parser.parse(&mut &payload[..]); + assert!(msg_result.is_ok()); + let sbp_msg = msg_result.unwrap(); + match sbp_msg { + sbp::messages::SBP::MsgOdometry(msg) => { + let sender_id = msg.get_sender_id().unwrap(); + assert_eq!( + sender_id, 0x42, + "incorrect sender id, expected 0x42, is {}", + sender_id + ); + assert_eq!( + msg.flags, 1, + "incorrect value for flags, expected 1, is {}", + msg.flags + ); + assert_eq!( + msg.tow, 8, + "incorrect value for tow, expected 8, is {}", + msg.tow + ); + assert_eq!( + msg.velocity, 7, + "incorrect value for velocity, expected 7, is {}", + msg.velocity + ); + } + _ => assert!(false, "Invalid message type! Expected a MsgOdometry"), + }; + } +} From acda3befba0d98dc7557e4485d10eebd8754b0fb Mon Sep 17 00:00:00 2001 From: Joseph Angelo Date: Thu, 31 Oct 2019 20:51:09 -0700 Subject: [PATCH 5/6] PR feedback --- generator/sbpg/targets/common.py | 29 +++++++++ .../sbpg/targets/resources/sbp_c_test.c.j2 | 10 ++-- .../targets/resources/sbp_tests_template.rs | 35 ++++------- generator/sbpg/targets/test_c.py | 31 +++------- generator/sbpg/targets/test_rust.py | 60 +++++-------------- rust/sbp/tests/common.rs | 30 ++++++++++ 6 files changed, 96 insertions(+), 99 deletions(-) create mode 100755 generator/sbpg/targets/common.py create mode 100644 rust/sbp/tests/common.rs diff --git a/generator/sbpg/targets/common.py b/generator/sbpg/targets/common.py new file mode 100755 index 0000000000..92e7fc8195 --- /dev/null +++ b/generator/sbpg/targets/common.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# Copyright (C) 2019 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +def string_type(value): + return type(value) == str + +def array_type(value): + return type(value) == list + +def dict_type(value): + return type(value) == dict + +def float_type(value): + return type(value) == float + +def is_empty(value): + return len(value) == 0 + +def to_str(value): + return str(value) + diff --git a/generator/sbpg/targets/resources/sbp_c_test.c.j2 b/generator/sbpg/targets/resources/sbp_c_test.c.j2 index ed5867d7be..d498a28d11 100644 --- a/generator/sbpg/targets/resources/sbp_c_test.c.j2 +++ b/generator/sbpg/targets/resources/sbp_c_test.c.j2 @@ -88,13 +88,13 @@ START_TEST( test_(((s.suite_name))) ) // ((*- macro compare_value(prefix, value) *)) - ((*- if value is stringType *)) + ((*- if value is string_type *)) fail_unless(strstr(msg->(((prefix))), (((value|str_escape)))) != NULL, "incorrect value for msg->(((prefix))), expected string '%s', is '%s'", (((value|str_escape))), msg->(((prefix)))); - ((*- elif value is arrayType *)) - ((*- for ff in value *))((( compare_value( (((prefix))) + '[' + (((loop.index0|toStr))) + ']', (((ff))) ) )))((*- endfor *)) - ((*- elif value is dictType *)) + ((*- elif value is array_type *)) + ((*- for ff in value *))((( compare_value( (((prefix))) + '[' + (((loop.index0|to_str))) + ']', (((ff))) ) )))((*- endfor *)) + ((*- elif value is dict_type *)) ((*- for k in (((value|sorted))) *))((( compare_value( (((prefix))) + '.' + (((k))), (((value[k]))) ) )))((*- endfor *)) - ((*- elif value is floatType *))((= + ((*- elif value is float_type *))((= Note: the ("%.12g"|format(value)|float) filter is intended to keep float literal precision unchanged whether generated under Python 2.7 or 3.x. =)) fail_unless((msg->(((prefix)))*100 - ((("%.12g"|format(value)|float)))*100) < 0.05, "incorrect value for (((prefix))), expected ((("%.12g"|format(value)|float))), is %f", msg->(((prefix)))); diff --git a/generator/sbpg/targets/resources/sbp_tests_template.rs b/generator/sbpg/targets/resources/sbp_tests_template.rs index 787d5d5206..75050ffe53 100644 --- a/generator/sbpg/targets/resources/sbp_tests_template.rs +++ b/generator/sbpg/targets/resources/sbp_tests_template.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,32 +14,18 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; ((*- macro compare_value(prefix, value) *)) -((*- if value is stringType *)) +((*- if value is string_type *)) assert_eq!(msg.(((prefix))), (((value|str_escape))), "incorrect value for msg.(((prefix))), expected string '{}', is '{}'", (((value|str_escape))), msg.(((prefix)))); -((*- elif value is arrayType *)) -((*- for ff in value *))((( compare_value( (((prefix))) + '[' + (((loop.index0|toStr))) + ']', (((ff))) ) )))((*- endfor *)) -((*- elif value is dictType *)) +((*- elif value is array_type *)) +((*- for ff in value *))((( compare_value( (((prefix))) + '[' + (((loop.index0|to_str))) + ']', (((ff))) ) )))((*- endfor *)) +((*- elif value is dict_type *)) ((*- for k in (((value|sorted))) *))((( compare_value( (((prefix))) + '.' + (((k))), (((value[k]))) ) )))((*- endfor *)) -((*- elif value is floatType *))((= +((*- elif value is float_type *))((= Note: the ("%.17e"|format(value)) filter is intended to preserve float literal precision accross all value ranges. =)) assert!(msg.(((prefix))).almost_eq( ((("%.17e"|format(value)))) ), "incorrect value for (((prefix))), expected ((("%.17e"|format(value)))), is {:e}", msg.(((prefix)))); @@ -53,7 +39,7 @@ fn test_(((s.suite_name)))() { ((*- for t in s.tests *)) { - use sbp::messages::(((t.msg.module|modName)))::(((t.msg.name))); + use sbp::messages::(((t.msg.module|mod_name)))::(((t.msg.name))); let payload : Vec = vec![ ((*- for p in t.packet_as_byte_array *))(((p))),((*- endfor *)) ]; assert_eq!( (((t.msg.name)))::MSG_ID, (((t.msg_type))), "Incorrect message type, expected (((t.msg_type))), is {}", (((t.msg.name)))::MSG_ID); @@ -74,3 +60,4 @@ fn test_(((s.suite_name)))() } ((*- endfor *)) } + diff --git a/generator/sbpg/targets/test_c.py b/generator/sbpg/targets/test_c.py index 709b034cdc..578d6693d5 100644 --- a/generator/sbpg/targets/test_c.py +++ b/generator/sbpg/targets/test_c.py @@ -15,6 +15,7 @@ from sbpg.targets.templating import * from sbpg.targets.c import * +from sbpg.targets.common import * import base64 TEST_TEMPLATE_NAME = "sbp_c_test.c.j2" @@ -24,41 +25,23 @@ def b64_decode(field): return base64.standard_b64decode(field) -def stringType(value): - return type(value) == str - -def arrayType(value): - return type(value) == list - -def dictType(value): - return type(value) == dict - -def floatType(value): - return type(value) == float - -def isEmpty(value): - return len(value) == 0 - def strEscape(value): return "((char []){" + ",".join(["(char)" + str(ord(ch)) for ch in value]) + ",0})" -def toStr(value): - return str(value) - JENV.filters['commentify'] = commentify JENV.filters['mk_id'] = mk_id JENV.filters['mk_size'] = mk_size JENV.filters['convert'] = convert JENV.filters['type'] = type JENV.filters['str_escape'] = strEscape -JENV.filters['toStr'] = toStr +JENV.filters['to_str'] = to_str JENV.filters['sorted'] = sorted -JENV.tests['stringType'] = stringType -JENV.tests['arrayType'] = arrayType -JENV.tests['dictType'] = dictType -JENV.tests['floatType'] = floatType -JENV.tests['empty'] = isEmpty +JENV.tests['string_type'] = string_type +JENV.tests['array_type'] = array_type +JENV.tests['dict_type'] = dict_type +JENV.tests['float_type'] = float_type +JENV.tests['empty'] = is_empty def render_source(output_dir, package_spec): """ diff --git a/generator/sbpg/targets/test_rust.py b/generator/sbpg/targets/test_rust.py index ab76fd72c1..036b1add00 100644 --- a/generator/sbpg/targets/test_rust.py +++ b/generator/sbpg/targets/test_rust.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright (C) 2015 Swift Navigation Inc. -# Contact: Joshua Gross +# Copyright (C) 2019 Swift Navigation Inc. +# Contact: Swift NAvigation # # This source is subject to the license found in the file 'LICENSE' which must # be be distributed together with this source. All other rights reserved. @@ -10,57 +10,39 @@ # WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. """ -Generator for c tests target. +Generator for rust tests target. """ from sbpg.targets.templating import * from sbpg.targets.rust import * +from sbpg.targets.common import * import base64 TEST_TEMPLATE_NAME = "sbp_tests_template.rs" -#CHECK_SUITES_TEMPLATE_NAME = "sbp_c_suites.h.j2" -#CHECK_MAIN_TEMPLATE_NAME = "sbp_c_main.c.j2" def b64_decode(field): print("Decoding '{}'".format(field)) b = base64.standard_b64decode(field) return [ str(ord(ch)) for ch in b ] -def stringType(value): - return type(value) == str -def arrayType(value): - return type(value) == list - -def dictType(value): - return type(value) == dict - -def floatType(value): - return type(value) == float - -def isEmpty(value): - return len(value) == 0 - -def strEscape(value): +def str_escape(value): return "\"{}\".to_string()".format(value) -def toStr(value): - return str(value) - -def modName(value): +def mod_name(value): return value.split('.')[1] JENV.filters['b64_decode'] = b64_decode -JENV.filters['toStr'] = toStr -JENV.filters['str_escape'] = strEscape +JENV.filters['to_str'] = to_str +JENV.filters['str_escape'] = str_escape JENV.filters['sorted'] = sorted -JENV.filters['modName'] = modName +JENV.filters['mod_name'] = mod_name -JENV.tests['stringType'] = stringType -JENV.tests['arrayType'] = arrayType -JENV.tests['dictType'] = dictType -JENV.tests['floatType'] = floatType -JENV.tests['empty'] = isEmpty +JENV.tests['string_type'] = string_type +JENV.tests['array_type'] = array_type +JENV.tests['dict_type'] = dict_type +JENV.tests['float_type'] = float_type +JENV.tests['empty'] = is_empty def render_source(output_dir, package_spec): """ @@ -76,17 +58,3 @@ def render_source(output_dir, package_spec): include=package_spec.package.split('.')[1], filepath="/".join(package_spec.filepath) + ".yaml")) - -#def render_check_suites(output_dir, all_package_specs): -# destination_filename = "%s/%s.h" % (output_dir, "check_suites") -# py_template = JENV.get_template(CHECK_SUITES_TEMPLATE_NAME) -# with open(destination_filename, 'w') as f: -# f.write(py_template.render(package_suites=all_package_specs)) - - -#def render_check_main(output_dir, all_package_specs): -# destination_filename = "%s/%s.c" % (output_dir, "check_main") -# py_template = JENV.get_template(CHECK_MAIN_TEMPLATE_NAME) -# with open(destination_filename, 'w') as f: -# f.write(py_template.render(package_suites=all_package_specs)) - diff --git a/rust/sbp/tests/common.rs b/rust/sbp/tests/common.rs new file mode 100644 index 0000000000..7a6c679504 --- /dev/null +++ b/rust/sbp/tests/common.rs @@ -0,0 +1,30 @@ +// +// Copyright (C) 2019 Swift Navigation Inc. +// Contact: Swift Navigation +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +pub trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} From fd039664cddc4bcde60193e157f3f9e42468cfcb Mon Sep 17 00:00:00 2001 From: Joseph Angelo Date: Thu, 31 Oct 2019 20:51:38 -0700 Subject: [PATCH 6/6] Regenerated C and Rust files --- c/include/libsbp/cpp/message_traits.h | 14 +++++++++- c/test/auto_check_sbp_navigation_13.c | 18 ++++++------- c/test/auto_check_sbp_navigation_16.c | 18 ++++++------- c/test/auto_check_sbp_navigation_18.c | 12 ++++----- c/test/auto_check_sbp_navigation_20.c | 12 ++++----- c/test/auto_check_sbp_navigation_23.c | 12 ++++----- c/test/auto_check_sbp_orientation_28.c | 6 ++--- c/test/auto_check_sbp_orientation_29.c | 8 +++--- .../sbp/tests/auto_check_sbp_acquisition_1.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_acquisition_2.rs | 24 +++--------------- .../tests/auto_check_sbp_acquisition_38.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_bootload_39.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_ext_events_40.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_logging_41.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_logging_42.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_10.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_11.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_12.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_13.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_14.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_15.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_16.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_17.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_18.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_19.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_20.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_21.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_22.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_23.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_24.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_navigation_3.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_navigation_4.rs | 24 +++--------------- .../sbp/tests/auto_check_sbp_navigation_43.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_navigation_5.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_navigation_6.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_navigation_7.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_navigation_8.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_navigation_9.rs | 24 +++--------------- .../tests/auto_check_sbp_observation_25.rs | 24 +++--------------- .../tests/auto_check_sbp_observation_26.rs | 24 +++--------------- .../tests/auto_check_sbp_observation_44.rs | 24 +++--------------- .../tests/auto_check_sbp_orientation_27.rs | 24 +++--------------- .../tests/auto_check_sbp_orientation_28.rs | 24 +++--------------- .../tests/auto_check_sbp_orientation_29.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_piksi_30.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_piksi_31.rs | Bin 10187 -> 9703 bytes rust/sbp/tests/auto_check_sbp_piksi_32.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_piksi_45.rs | Bin 55358 -> 54874 bytes rust/sbp/tests/auto_check_sbp_settings_33.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_settings_34.rs | Bin 10629 -> 10145 bytes rust/sbp/tests/auto_check_sbp_system_35.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_system_36.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_system_37.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_system_46.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_tracking_47.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_tracking_48.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_tracking_49.rs | 24 +++--------------- rust/sbp/tests/auto_check_sbp_vehicle_50.rs | 24 +++--------------- 58 files changed, 244 insertions(+), 984 deletions(-) diff --git a/c/include/libsbp/cpp/message_traits.h b/c/include/libsbp/cpp/message_traits.h index 96e2c9cdfc..879f2d1eee 100644 --- a/c/include/libsbp/cpp/message_traits.h +++ b/c/include/libsbp/cpp/message_traits.h @@ -37,8 +37,14 @@ namespace sbp { +/** + * Type traits containing meta-information for each SBP message type. + * + * These are only meant to be used by the C++ library at compile time. + * These are automatically generated, DO NOT EDIT. + */ template -struct MessageTraits { }; +struct MessageTraits; template<> @@ -803,6 +809,12 @@ struct MessageTraits { }; +template<> +struct MessageTraits { + static constexpr u16 id = 534; +}; + + template<> struct MessageTraits { static constexpr u16 id = 544; diff --git a/c/test/auto_check_sbp_navigation_13.c b/c/test/auto_check_sbp_navigation_13.c index 26d22c8627..c32a28384e 100644 --- a/c/test/auto_check_sbp_navigation_13.c +++ b/c/test/auto_check_sbp_navigation_13.c @@ -125,18 +125,18 @@ START_TEST( test_auto_check_sbp_navigation_13 ) msg_pos_ecef_cov_t* msg = ( msg_pos_ecef_cov_t *)((void *)last_msg + 6); // Run tests against fields fail_unless(msg != 0, "stub to prevent warnings if msg isn't used"); - fail_unless(msg->cov_x_x == 8, "incorrect value for cov_x_x, expected 8, is %d", msg->cov_x_x); - fail_unless(msg->cov_x_y == 7, "incorrect value for cov_x_y, expected 7, is %d", msg->cov_x_y); - fail_unless(msg->cov_x_z == 2, "incorrect value for cov_x_z, expected 2, is %d", msg->cov_x_z); - fail_unless(msg->cov_y_y == 6, "incorrect value for cov_y_y, expected 6, is %d", msg->cov_y_y); - fail_unless(msg->cov_y_z == 8, "incorrect value for cov_y_z, expected 8, is %d", msg->cov_y_z); - fail_unless(msg->cov_z_z == 5, "incorrect value for cov_z_z, expected 5, is %d", msg->cov_z_z); + fail_unless((msg->cov_x_x*100 - 8.0*100) < 0.05, "incorrect value for cov_x_x, expected 8.0, is %f", msg->cov_x_x); + fail_unless((msg->cov_x_y*100 - 7.0*100) < 0.05, "incorrect value for cov_x_y, expected 7.0, is %f", msg->cov_x_y); + fail_unless((msg->cov_x_z*100 - 2.0*100) < 0.05, "incorrect value for cov_x_z, expected 2.0, is %f", msg->cov_x_z); + fail_unless((msg->cov_y_y*100 - 6.0*100) < 0.05, "incorrect value for cov_y_y, expected 6.0, is %f", msg->cov_y_y); + fail_unless((msg->cov_y_z*100 - 8.0*100) < 0.05, "incorrect value for cov_y_z, expected 8.0, is %f", msg->cov_y_z); + fail_unless((msg->cov_z_z*100 - 5.0*100) < 0.05, "incorrect value for cov_z_z, expected 5.0, is %f", msg->cov_z_z); fail_unless(msg->flags == 5, "incorrect value for flags, expected 5, is %d", msg->flags); fail_unless(msg->n_sats == 4, "incorrect value for n_sats, expected 4, is %d", msg->n_sats); fail_unless(msg->tow == 7, "incorrect value for tow, expected 7, is %d", msg->tow); - fail_unless(msg->x == 6, "incorrect value for x, expected 6, is %d", msg->x); - fail_unless(msg->y == 1, "incorrect value for y, expected 1, is %d", msg->y); - fail_unless(msg->z == 4, "incorrect value for z, expected 4, is %d", msg->z); + fail_unless((msg->x*100 - 6.0*100) < 0.05, "incorrect value for x, expected 6.0, is %f", msg->x); + fail_unless((msg->y*100 - 1.0*100) < 0.05, "incorrect value for y, expected 1.0, is %f", msg->y); + fail_unless((msg->z*100 - 4.0*100) < 0.05, "incorrect value for z, expected 4.0, is %f", msg->z); } } END_TEST diff --git a/c/test/auto_check_sbp_navigation_16.c b/c/test/auto_check_sbp_navigation_16.c index 034300d613..27496d6741 100644 --- a/c/test/auto_check_sbp_navigation_16.c +++ b/c/test/auto_check_sbp_navigation_16.c @@ -125,16 +125,16 @@ START_TEST( test_auto_check_sbp_navigation_16 ) msg_pos_llh_cov_t* msg = ( msg_pos_llh_cov_t *)((void *)last_msg + 6); // Run tests against fields fail_unless(msg != 0, "stub to prevent warnings if msg isn't used"); - fail_unless(msg->cov_d_d == 2, "incorrect value for cov_d_d, expected 2, is %d", msg->cov_d_d); - fail_unless(msg->cov_e_d == 1, "incorrect value for cov_e_d, expected 1, is %d", msg->cov_e_d); - fail_unless(msg->cov_e_e == 6, "incorrect value for cov_e_e, expected 6, is %d", msg->cov_e_e); - fail_unless(msg->cov_n_d == 8, "incorrect value for cov_n_d, expected 8, is %d", msg->cov_n_d); - fail_unless(msg->cov_n_e == 5, "incorrect value for cov_n_e, expected 5, is %d", msg->cov_n_e); - fail_unless(msg->cov_n_n == 7, "incorrect value for cov_n_n, expected 7, is %d", msg->cov_n_n); + fail_unless((msg->cov_d_d*100 - 2.0*100) < 0.05, "incorrect value for cov_d_d, expected 2.0, is %f", msg->cov_d_d); + fail_unless((msg->cov_e_d*100 - 1.0*100) < 0.05, "incorrect value for cov_e_d, expected 1.0, is %f", msg->cov_e_d); + fail_unless((msg->cov_e_e*100 - 6.0*100) < 0.05, "incorrect value for cov_e_e, expected 6.0, is %f", msg->cov_e_e); + fail_unless((msg->cov_n_d*100 - 8.0*100) < 0.05, "incorrect value for cov_n_d, expected 8.0, is %f", msg->cov_n_d); + fail_unless((msg->cov_n_e*100 - 5.0*100) < 0.05, "incorrect value for cov_n_e, expected 5.0, is %f", msg->cov_n_e); + fail_unless((msg->cov_n_n*100 - 7.0*100) < 0.05, "incorrect value for cov_n_n, expected 7.0, is %f", msg->cov_n_n); fail_unless(msg->flags == 5, "incorrect value for flags, expected 5, is %d", msg->flags); - fail_unless(msg->height == 0, "incorrect value for height, expected 0, is %d", msg->height); - fail_unless(msg->lat == 0, "incorrect value for lat, expected 0, is %d", msg->lat); - fail_unless(msg->lon == 7, "incorrect value for lon, expected 7, is %d", msg->lon); + fail_unless((msg->height*100 - 0.0*100) < 0.05, "incorrect value for height, expected 0.0, is %f", msg->height); + fail_unless((msg->lat*100 - 0.0*100) < 0.05, "incorrect value for lat, expected 0.0, is %f", msg->lat); + fail_unless((msg->lon*100 - 7.0*100) < 0.05, "incorrect value for lon, expected 7.0, is %f", msg->lon); fail_unless(msg->n_sats == 5, "incorrect value for n_sats, expected 5, is %d", msg->n_sats); fail_unless(msg->tow == 7, "incorrect value for tow, expected 7, is %d", msg->tow); } diff --git a/c/test/auto_check_sbp_navigation_18.c b/c/test/auto_check_sbp_navigation_18.c index e658b1f055..bf852e738c 100644 --- a/c/test/auto_check_sbp_navigation_18.c +++ b/c/test/auto_check_sbp_navigation_18.c @@ -125,12 +125,12 @@ START_TEST( test_auto_check_sbp_navigation_18 ) msg_vel_body_t* msg = ( msg_vel_body_t *)((void *)last_msg + 6); // Run tests against fields fail_unless(msg != 0, "stub to prevent warnings if msg isn't used"); - fail_unless(msg->cov_x_x == 0, "incorrect value for cov_x_x, expected 0, is %d", msg->cov_x_x); - fail_unless(msg->cov_x_y == 5, "incorrect value for cov_x_y, expected 5, is %d", msg->cov_x_y); - fail_unless(msg->cov_x_z == 7, "incorrect value for cov_x_z, expected 7, is %d", msg->cov_x_z); - fail_unless(msg->cov_y_y == 7, "incorrect value for cov_y_y, expected 7, is %d", msg->cov_y_y); - fail_unless(msg->cov_y_z == 3, "incorrect value for cov_y_z, expected 3, is %d", msg->cov_y_z); - fail_unless(msg->cov_z_z == 2, "incorrect value for cov_z_z, expected 2, is %d", msg->cov_z_z); + fail_unless((msg->cov_x_x*100 - 0.0*100) < 0.05, "incorrect value for cov_x_x, expected 0.0, is %f", msg->cov_x_x); + fail_unless((msg->cov_x_y*100 - 5.0*100) < 0.05, "incorrect value for cov_x_y, expected 5.0, is %f", msg->cov_x_y); + fail_unless((msg->cov_x_z*100 - 7.0*100) < 0.05, "incorrect value for cov_x_z, expected 7.0, is %f", msg->cov_x_z); + fail_unless((msg->cov_y_y*100 - 7.0*100) < 0.05, "incorrect value for cov_y_y, expected 7.0, is %f", msg->cov_y_y); + fail_unless((msg->cov_y_z*100 - 3.0*100) < 0.05, "incorrect value for cov_y_z, expected 3.0, is %f", msg->cov_y_z); + fail_unless((msg->cov_z_z*100 - 2.0*100) < 0.05, "incorrect value for cov_z_z, expected 2.0, is %f", msg->cov_z_z); fail_unless(msg->flags == 8, "incorrect value for flags, expected 8, is %d", msg->flags); fail_unless(msg->n_sats == 3, "incorrect value for n_sats, expected 3, is %d", msg->n_sats); fail_unless(msg->tow == 1, "incorrect value for tow, expected 1, is %d", msg->tow); diff --git a/c/test/auto_check_sbp_navigation_20.c b/c/test/auto_check_sbp_navigation_20.c index 97a6274bbf..b609dbd4e4 100644 --- a/c/test/auto_check_sbp_navigation_20.c +++ b/c/test/auto_check_sbp_navigation_20.c @@ -125,12 +125,12 @@ START_TEST( test_auto_check_sbp_navigation_20 ) msg_vel_ecef_cov_t* msg = ( msg_vel_ecef_cov_t *)((void *)last_msg + 6); // Run tests against fields fail_unless(msg != 0, "stub to prevent warnings if msg isn't used"); - fail_unless(msg->cov_x_x == 2, "incorrect value for cov_x_x, expected 2, is %d", msg->cov_x_x); - fail_unless(msg->cov_x_y == 2, "incorrect value for cov_x_y, expected 2, is %d", msg->cov_x_y); - fail_unless(msg->cov_x_z == 2, "incorrect value for cov_x_z, expected 2, is %d", msg->cov_x_z); - fail_unless(msg->cov_y_y == 2, "incorrect value for cov_y_y, expected 2, is %d", msg->cov_y_y); - fail_unless(msg->cov_y_z == 1, "incorrect value for cov_y_z, expected 1, is %d", msg->cov_y_z); - fail_unless(msg->cov_z_z == 3, "incorrect value for cov_z_z, expected 3, is %d", msg->cov_z_z); + fail_unless((msg->cov_x_x*100 - 2.0*100) < 0.05, "incorrect value for cov_x_x, expected 2.0, is %f", msg->cov_x_x); + fail_unless((msg->cov_x_y*100 - 2.0*100) < 0.05, "incorrect value for cov_x_y, expected 2.0, is %f", msg->cov_x_y); + fail_unless((msg->cov_x_z*100 - 2.0*100) < 0.05, "incorrect value for cov_x_z, expected 2.0, is %f", msg->cov_x_z); + fail_unless((msg->cov_y_y*100 - 2.0*100) < 0.05, "incorrect value for cov_y_y, expected 2.0, is %f", msg->cov_y_y); + fail_unless((msg->cov_y_z*100 - 1.0*100) < 0.05, "incorrect value for cov_y_z, expected 1.0, is %f", msg->cov_y_z); + fail_unless((msg->cov_z_z*100 - 3.0*100) < 0.05, "incorrect value for cov_z_z, expected 3.0, is %f", msg->cov_z_z); fail_unless(msg->flags == 4, "incorrect value for flags, expected 4, is %d", msg->flags); fail_unless(msg->n_sats == 3, "incorrect value for n_sats, expected 3, is %d", msg->n_sats); fail_unless(msg->tow == 2, "incorrect value for tow, expected 2, is %d", msg->tow); diff --git a/c/test/auto_check_sbp_navigation_23.c b/c/test/auto_check_sbp_navigation_23.c index b32b7c64b9..2ea9bbed7c 100644 --- a/c/test/auto_check_sbp_navigation_23.c +++ b/c/test/auto_check_sbp_navigation_23.c @@ -125,12 +125,12 @@ START_TEST( test_auto_check_sbp_navigation_23 ) msg_vel_ned_cov_t* msg = ( msg_vel_ned_cov_t *)((void *)last_msg + 6); // Run tests against fields fail_unless(msg != 0, "stub to prevent warnings if msg isn't used"); - fail_unless(msg->cov_d_d == 1, "incorrect value for cov_d_d, expected 1, is %d", msg->cov_d_d); - fail_unless(msg->cov_e_d == 1, "incorrect value for cov_e_d, expected 1, is %d", msg->cov_e_d); - fail_unless(msg->cov_e_e == 1, "incorrect value for cov_e_e, expected 1, is %d", msg->cov_e_e); - fail_unless(msg->cov_n_d == 1, "incorrect value for cov_n_d, expected 1, is %d", msg->cov_n_d); - fail_unless(msg->cov_n_e == 1, "incorrect value for cov_n_e, expected 1, is %d", msg->cov_n_e); - fail_unless(msg->cov_n_n == 1, "incorrect value for cov_n_n, expected 1, is %d", msg->cov_n_n); + fail_unless((msg->cov_d_d*100 - 1.0*100) < 0.05, "incorrect value for cov_d_d, expected 1.0, is %f", msg->cov_d_d); + fail_unless((msg->cov_e_d*100 - 1.0*100) < 0.05, "incorrect value for cov_e_d, expected 1.0, is %f", msg->cov_e_d); + fail_unless((msg->cov_e_e*100 - 1.0*100) < 0.05, "incorrect value for cov_e_e, expected 1.0, is %f", msg->cov_e_e); + fail_unless((msg->cov_n_d*100 - 1.0*100) < 0.05, "incorrect value for cov_n_d, expected 1.0, is %f", msg->cov_n_d); + fail_unless((msg->cov_n_e*100 - 1.0*100) < 0.05, "incorrect value for cov_n_e, expected 1.0, is %f", msg->cov_n_e); + fail_unless((msg->cov_n_n*100 - 1.0*100) < 0.05, "incorrect value for cov_n_n, expected 1.0, is %f", msg->cov_n_n); fail_unless(msg->e == 1, "incorrect value for e, expected 1, is %d", msg->e); fail_unless(msg->flags == 0, "incorrect value for flags, expected 0, is %d", msg->flags); fail_unless(msg->n == 1, "incorrect value for n, expected 1, is %d", msg->n); diff --git a/c/test/auto_check_sbp_orientation_28.c b/c/test/auto_check_sbp_orientation_28.c index 5a5f26dff1..5d15bc7d2b 100644 --- a/c/test/auto_check_sbp_orientation_28.c +++ b/c/test/auto_check_sbp_orientation_28.c @@ -127,12 +127,12 @@ START_TEST( test_auto_check_sbp_orientation_28 ) fail_unless(msg != 0, "stub to prevent warnings if msg isn't used"); fail_unless(msg->flags == 3, "incorrect value for flags, expected 3, is %d", msg->flags); fail_unless(msg->pitch == 2, "incorrect value for pitch, expected 2, is %d", msg->pitch); - fail_unless(msg->pitch_accuracy == 3, "incorrect value for pitch_accuracy, expected 3, is %d", msg->pitch_accuracy); + fail_unless((msg->pitch_accuracy*100 - 3.0*100) < 0.05, "incorrect value for pitch_accuracy, expected 3.0, is %f", msg->pitch_accuracy); fail_unless(msg->roll == 1, "incorrect value for roll, expected 1, is %d", msg->roll); - fail_unless(msg->roll_accuracy == 7, "incorrect value for roll_accuracy, expected 7, is %d", msg->roll_accuracy); + fail_unless((msg->roll_accuracy*100 - 7.0*100) < 0.05, "incorrect value for roll_accuracy, expected 7.0, is %f", msg->roll_accuracy); fail_unless(msg->tow == 1, "incorrect value for tow, expected 1, is %d", msg->tow); fail_unless(msg->yaw == 8, "incorrect value for yaw, expected 8, is %d", msg->yaw); - fail_unless(msg->yaw_accuracy == 7, "incorrect value for yaw_accuracy, expected 7, is %d", msg->yaw_accuracy); + fail_unless((msg->yaw_accuracy*100 - 7.0*100) < 0.05, "incorrect value for yaw_accuracy, expected 7.0, is %f", msg->yaw_accuracy); } } END_TEST diff --git a/c/test/auto_check_sbp_orientation_29.c b/c/test/auto_check_sbp_orientation_29.c index 88d300d286..5a7cd9883e 100644 --- a/c/test/auto_check_sbp_orientation_29.c +++ b/c/test/auto_check_sbp_orientation_29.c @@ -128,13 +128,13 @@ START_TEST( test_auto_check_sbp_orientation_29 ) fail_unless(msg->flags == 1, "incorrect value for flags, expected 1, is %d", msg->flags); fail_unless(msg->tow == 0, "incorrect value for tow, expected 0, is %d", msg->tow); fail_unless(msg->w == 3, "incorrect value for w, expected 3, is %d", msg->w); - fail_unless(msg->w_accuracy == 3, "incorrect value for w_accuracy, expected 3, is %d", msg->w_accuracy); + fail_unless((msg->w_accuracy*100 - 3.0*100) < 0.05, "incorrect value for w_accuracy, expected 3.0, is %f", msg->w_accuracy); fail_unless(msg->x == 7, "incorrect value for x, expected 7, is %d", msg->x); - fail_unless(msg->x_accuracy == 4, "incorrect value for x_accuracy, expected 4, is %d", msg->x_accuracy); + fail_unless((msg->x_accuracy*100 - 4.0*100) < 0.05, "incorrect value for x_accuracy, expected 4.0, is %f", msg->x_accuracy); fail_unless(msg->y == 8, "incorrect value for y, expected 8, is %d", msg->y); - fail_unless(msg->y_accuracy == 8, "incorrect value for y_accuracy, expected 8, is %d", msg->y_accuracy); + fail_unless((msg->y_accuracy*100 - 8.0*100) < 0.05, "incorrect value for y_accuracy, expected 8.0, is %f", msg->y_accuracy); fail_unless(msg->z == 4, "incorrect value for z, expected 4, is %d", msg->z); - fail_unless(msg->z_accuracy == 3, "incorrect value for z_accuracy, expected 3, is %d", msg->z_accuracy); + fail_unless((msg->z_accuracy*100 - 3.0*100) < 0.05, "incorrect value for z_accuracy, expected 3.0, is %f", msg->z_accuracy); } } END_TEST diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_1.rs b/rust/sbp/tests/auto_check_sbp_acquisition_1.rs index 1943174ebf..4598e68228 100644 --- a/rust/sbp/tests/auto_check_sbp_acquisition_1.rs +++ b/rust/sbp/tests/auto_check_sbp_acquisition_1.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_acquisition_1() { diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_2.rs b/rust/sbp/tests/auto_check_sbp_acquisition_2.rs index fdea28615b..661effde59 100644 --- a/rust/sbp/tests/auto_check_sbp_acquisition_2.rs +++ b/rust/sbp/tests/auto_check_sbp_acquisition_2.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_acquisition_2() { diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_38.rs b/rust/sbp/tests/auto_check_sbp_acquisition_38.rs index 92b8be33af..1ef7aba347 100644 --- a/rust/sbp/tests/auto_check_sbp_acquisition_38.rs +++ b/rust/sbp/tests/auto_check_sbp_acquisition_38.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_acquisition_38() { diff --git a/rust/sbp/tests/auto_check_sbp_bootload_39.rs b/rust/sbp/tests/auto_check_sbp_bootload_39.rs index d43b541675..f8e7c43a6c 100644 --- a/rust/sbp/tests/auto_check_sbp_bootload_39.rs +++ b/rust/sbp/tests/auto_check_sbp_bootload_39.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_bootload_39() { diff --git a/rust/sbp/tests/auto_check_sbp_ext_events_40.rs b/rust/sbp/tests/auto_check_sbp_ext_events_40.rs index 08ef2639de..ca3449c64e 100644 --- a/rust/sbp/tests/auto_check_sbp_ext_events_40.rs +++ b/rust/sbp/tests/auto_check_sbp_ext_events_40.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_ext_events_40() { diff --git a/rust/sbp/tests/auto_check_sbp_logging_41.rs b/rust/sbp/tests/auto_check_sbp_logging_41.rs index 4163e3ed76..a466571c96 100644 --- a/rust/sbp/tests/auto_check_sbp_logging_41.rs +++ b/rust/sbp/tests/auto_check_sbp_logging_41.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_logging_41() { diff --git a/rust/sbp/tests/auto_check_sbp_logging_42.rs b/rust/sbp/tests/auto_check_sbp_logging_42.rs index 4aaeedf819..c8dcaadb7a 100644 --- a/rust/sbp/tests/auto_check_sbp_logging_42.rs +++ b/rust/sbp/tests/auto_check_sbp_logging_42.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_logging_42() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_10.rs b/rust/sbp/tests/auto_check_sbp_navigation_10.rs index 96b15ce250..2a6a10db0f 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_10.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_10.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_10() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_11.rs b/rust/sbp/tests/auto_check_sbp_navigation_11.rs index da36325b67..17c4025ced 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_11.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_11.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_11() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_12.rs b/rust/sbp/tests/auto_check_sbp_navigation_12.rs index 2813afce09..ce20f924a3 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_12.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_12.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_12() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_13.rs b/rust/sbp/tests/auto_check_sbp_navigation_13.rs index 0537eb27ac..1994e8ce7b 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_13.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_13.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_13() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_14.rs b/rust/sbp/tests/auto_check_sbp_navigation_14.rs index e287e46b74..f324e4dfa3 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_14.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_14.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_14() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_15.rs b/rust/sbp/tests/auto_check_sbp_navigation_15.rs index 8b76145631..b3403e0634 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_15.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_15.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_15() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_16.rs b/rust/sbp/tests/auto_check_sbp_navigation_16.rs index a9421a050d..c429a20f8b 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_16.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_16.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_16() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_17.rs b/rust/sbp/tests/auto_check_sbp_navigation_17.rs index c03b52592b..42deff877e 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_17.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_17.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_17() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_18.rs b/rust/sbp/tests/auto_check_sbp_navigation_18.rs index acb897e9b9..5c3fcb1151 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_18.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_18.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_18() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_19.rs b/rust/sbp/tests/auto_check_sbp_navigation_19.rs index f520ad446e..3ccca615e7 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_19.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_19.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_19() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_20.rs b/rust/sbp/tests/auto_check_sbp_navigation_20.rs index 06c14b0acf..1238a11137 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_20.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_20.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_20() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_21.rs b/rust/sbp/tests/auto_check_sbp_navigation_21.rs index ea845efc5a..39bcfd44fa 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_21.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_21.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_21() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_22.rs b/rust/sbp/tests/auto_check_sbp_navigation_22.rs index 504ef3aa57..62fbd13809 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_22.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_22.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_22() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_23.rs b/rust/sbp/tests/auto_check_sbp_navigation_23.rs index 733fc7f5d2..429fcf0ecf 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_23.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_23.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_23() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_24.rs b/rust/sbp/tests/auto_check_sbp_navigation_24.rs index b8662f1363..bd399893ef 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_24.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_24.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_24() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_3.rs b/rust/sbp/tests/auto_check_sbp_navigation_3.rs index 372c6b15d5..8f592c5592 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_3.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_3.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_3() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_4.rs b/rust/sbp/tests/auto_check_sbp_navigation_4.rs index 7b9e41c1df..161f83c36d 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_4.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_4.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_4() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_43.rs b/rust/sbp/tests/auto_check_sbp_navigation_43.rs index 499ddc3239..23a6d7b0b0 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_43.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_43.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_43() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_5.rs b/rust/sbp/tests/auto_check_sbp_navigation_5.rs index 838ba61d07..f00b5832ab 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_5.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_5.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_5() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_6.rs b/rust/sbp/tests/auto_check_sbp_navigation_6.rs index f24d96d733..7b1f10be04 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_6.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_6.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_6() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_7.rs b/rust/sbp/tests/auto_check_sbp_navigation_7.rs index 2df895c577..7761c44c63 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_7.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_7.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_7() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_8.rs b/rust/sbp/tests/auto_check_sbp_navigation_8.rs index 806fbfd3d6..45dc7807b9 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_8.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_8.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_8() { diff --git a/rust/sbp/tests/auto_check_sbp_navigation_9.rs b/rust/sbp/tests/auto_check_sbp_navigation_9.rs index fcf5271950..06099b5b19 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_9.rs +++ b/rust/sbp/tests/auto_check_sbp_navigation_9.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_navigation_9() { diff --git a/rust/sbp/tests/auto_check_sbp_observation_25.rs b/rust/sbp/tests/auto_check_sbp_observation_25.rs index cdbd48a9e4..168fbfd983 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_25.rs +++ b/rust/sbp/tests/auto_check_sbp_observation_25.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_observation_25() { diff --git a/rust/sbp/tests/auto_check_sbp_observation_26.rs b/rust/sbp/tests/auto_check_sbp_observation_26.rs index 033058aaa6..d66b787238 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_26.rs +++ b/rust/sbp/tests/auto_check_sbp_observation_26.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_observation_26() { diff --git a/rust/sbp/tests/auto_check_sbp_observation_44.rs b/rust/sbp/tests/auto_check_sbp_observation_44.rs index bb4cf8a600..ee36e7716d 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_44.rs +++ b/rust/sbp/tests/auto_check_sbp_observation_44.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_observation_44() { diff --git a/rust/sbp/tests/auto_check_sbp_orientation_27.rs b/rust/sbp/tests/auto_check_sbp_orientation_27.rs index 4ed7c448d4..75cb4c0406 100644 --- a/rust/sbp/tests/auto_check_sbp_orientation_27.rs +++ b/rust/sbp/tests/auto_check_sbp_orientation_27.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_orientation_27() { diff --git a/rust/sbp/tests/auto_check_sbp_orientation_28.rs b/rust/sbp/tests/auto_check_sbp_orientation_28.rs index 96305c319f..7b3ba25048 100644 --- a/rust/sbp/tests/auto_check_sbp_orientation_28.rs +++ b/rust/sbp/tests/auto_check_sbp_orientation_28.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_orientation_28() { diff --git a/rust/sbp/tests/auto_check_sbp_orientation_29.rs b/rust/sbp/tests/auto_check_sbp_orientation_29.rs index 5f841e442d..62b9f4c155 100644 --- a/rust/sbp/tests/auto_check_sbp_orientation_29.rs +++ b/rust/sbp/tests/auto_check_sbp_orientation_29.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_orientation_29() { diff --git a/rust/sbp/tests/auto_check_sbp_piksi_30.rs b/rust/sbp/tests/auto_check_sbp_piksi_30.rs index 0f2e78eb56..b93747f1c2 100644 --- a/rust/sbp/tests/auto_check_sbp_piksi_30.rs +++ b/rust/sbp/tests/auto_check_sbp_piksi_30.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_piksi_30() { diff --git a/rust/sbp/tests/auto_check_sbp_piksi_31.rs b/rust/sbp/tests/auto_check_sbp_piksi_31.rs index 210a6b1ae48bfb54c91651e0285971e7a5a27dba..b7b62dd83bd4a7bba308620f017a6443339162de 100644 GIT binary patch delta 76 zcmX@@|J-|mIHTo8*)}Gt-24=U7cAXyEtOB8fLPSMm$Oe)sURIssC&?qiRv9bc%YGvgb5bWvW z@28*z6a>0dK^s}A7RX>tO}KF&BWr5vu^X#^Fx1!652C3ShkwmXNboPZck5yP1)4&V cf6YwD@-Mn~Wg)=`^)JX!WdCly!Nji&0M)pfrvLx| diff --git a/rust/sbp/tests/auto_check_sbp_piksi_32.rs b/rust/sbp/tests/auto_check_sbp_piksi_32.rs index 4894d1b1c8..8938b073c2 100644 --- a/rust/sbp/tests/auto_check_sbp_piksi_32.rs +++ b/rust/sbp/tests/auto_check_sbp_piksi_32.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_piksi_32() { diff --git a/rust/sbp/tests/auto_check_sbp_piksi_45.rs b/rust/sbp/tests/auto_check_sbp_piksi_45.rs index 61420731daa44f9a4a26be1c90617ff296173519..702030f30b488897cde858a14f4a1cab67da0821 100644 GIT binary patch delta 78 zcmdnDf%(=N<_Y4AmK$ZunXGd2QxuZ(b93|athtn<6LWI%%QZ^#N{drd;xls#@{3A} cHDkGeT&N-|E61GN{NfVVLhH?IStecv0Bi~!bN~PV delta 566 zcmcb$hI!ux<_Y3#rn*K3h87zo%9-j*iV`zR6dZGM^NUMd3l*xl6o4QtPazR35}#VA zQJk8SrlU}lQEa6U3}k95=-MeH<>%*EbJcQjW#$&-AatkY7b&C}8a~Q!g>8SVL36##TY2xFp5O3TUg9m1{t- zr;op%f)-E^=u!o3WTjdlgEckb#(|8isj0_qtOCMNUr#@Xrdk~SH8UZ>zv$krhxr$1 e3Q7JoGa<{r=-!ou1S8bHAVZP;yZI#3#LECVgq&#r diff --git a/rust/sbp/tests/auto_check_sbp_settings_33.rs b/rust/sbp/tests/auto_check_sbp_settings_33.rs index 8621c4c60a..260c4201c9 100644 --- a/rust/sbp/tests/auto_check_sbp_settings_33.rs +++ b/rust/sbp/tests/auto_check_sbp_settings_33.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_settings_33() { diff --git a/rust/sbp/tests/auto_check_sbp_settings_34.rs b/rust/sbp/tests/auto_check_sbp_settings_34.rs index 76ebf7f595de43069b2da479a99b8b15d94af191..ea573e8bd1bde913a20ebd1b4eb6737ffa3f5b76 100644 GIT binary patch delta 76 zcmZn-Ug$qToY8Wl>{KSJ-24=U7cAXyEtOB8fLPSMm$Oe)sURIssC&?qiRv9bc%YGvgb5bWvW z@28*z6a>0dK^s}A7RX>tO}KF&BWr5vu^X#^Fx1!652C3ShkwmXNboPZck5yP1)4&V cf6YwD@-Mn~Wg)=`^)JX!WdCk{&a_Jf0M!$k?EnA( diff --git a/rust/sbp/tests/auto_check_sbp_system_35.rs b/rust/sbp/tests/auto_check_sbp_system_35.rs index 800e253dfb..279e4b4a45 100644 --- a/rust/sbp/tests/auto_check_sbp_system_35.rs +++ b/rust/sbp/tests/auto_check_sbp_system_35.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_system_35() { diff --git a/rust/sbp/tests/auto_check_sbp_system_36.rs b/rust/sbp/tests/auto_check_sbp_system_36.rs index e374f1c4f5..b650ea6159 100644 --- a/rust/sbp/tests/auto_check_sbp_system_36.rs +++ b/rust/sbp/tests/auto_check_sbp_system_36.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_system_36() { diff --git a/rust/sbp/tests/auto_check_sbp_system_37.rs b/rust/sbp/tests/auto_check_sbp_system_37.rs index a8bb5c8ace..2675b5ece6 100644 --- a/rust/sbp/tests/auto_check_sbp_system_37.rs +++ b/rust/sbp/tests/auto_check_sbp_system_37.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_system_37() { diff --git a/rust/sbp/tests/auto_check_sbp_system_46.rs b/rust/sbp/tests/auto_check_sbp_system_46.rs index b436a60785..64468b578c 100644 --- a/rust/sbp/tests/auto_check_sbp_system_46.rs +++ b/rust/sbp/tests/auto_check_sbp_system_46.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_system_46() { diff --git a/rust/sbp/tests/auto_check_sbp_tracking_47.rs b/rust/sbp/tests/auto_check_sbp_tracking_47.rs index c7834d9230..63487f855b 100644 --- a/rust/sbp/tests/auto_check_sbp_tracking_47.rs +++ b/rust/sbp/tests/auto_check_sbp_tracking_47.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_tracking_47() { diff --git a/rust/sbp/tests/auto_check_sbp_tracking_48.rs b/rust/sbp/tests/auto_check_sbp_tracking_48.rs index 4f13286a63..d040ec38c8 100644 --- a/rust/sbp/tests/auto_check_sbp_tracking_48.rs +++ b/rust/sbp/tests/auto_check_sbp_tracking_48.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_tracking_48() { diff --git a/rust/sbp/tests/auto_check_sbp_tracking_49.rs b/rust/sbp/tests/auto_check_sbp_tracking_49.rs index ed78d3c820..46fbf51e6f 100644 --- a/rust/sbp/tests/auto_check_sbp_tracking_49.rs +++ b/rust/sbp/tests/auto_check_sbp_tracking_49.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_tracking_49() { diff --git a/rust/sbp/tests/auto_check_sbp_vehicle_50.rs b/rust/sbp/tests/auto_check_sbp_vehicle_50.rs index 52fb911b5c..95a974dc40 100644 --- a/rust/sbp/tests/auto_check_sbp_vehicle_50.rs +++ b/rust/sbp/tests/auto_check_sbp_vehicle_50.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2015-2018 Swift Navigation Inc. +// Copyright (C) 2019 Swift Navigation Inc. // Contact: Swift Navigation // // This source is subject to the license found in the file 'LICENSE' which must @@ -14,25 +14,9 @@ extern crate sbp; use sbp::messages::SBPMessage; -trait AlmostEq { - fn almost_eq(self, rhs: Self) -> bool; -} - -impl AlmostEq for f32 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f32 = 5.0; - ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f32::MIN) - } -} - -impl AlmostEq for f64 { - fn almost_eq(self, rhs: Self) -> bool { - const ULP: f64 = 5.0; - ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) - || ((self - rhs).abs() < std::f64::MIN) - } -} +mod common; +#[allow(unused_imports)] +use common::AlmostEq; #[test] fn test_auto_check_sbp_vehicle_50() {