|
1 | 1 | #include <cmath> |
2 | 2 | #include <cstdio> |
3 | 3 | #include <cstdlib> |
| 4 | +#include <cstring> |
4 | 5 |
|
5 | 6 | #include <seatalk.hpp> |
6 | 7 |
|
@@ -60,7 +61,38 @@ int main() { |
60 | 61 | REQUIRE(model.steering.rudder.angle_deg.valid); |
61 | 62 | NEAR(model.steering.rudder.angle_deg.value, -2.0f, 0.001f); |
62 | 63 |
|
63 | | - REQUIRE(receiver.decoded_count() == 7); |
| 64 | + const uint8_t autopilot[] = {0x84, 0x16, 0x40, 0x00, 0x42, 0x00, 0xfe, 0x01, 0x08}; |
| 65 | + accept(receiver, model, autopilot, sizeof(autopilot), now_us); |
| 66 | + REQUIRE(model.autopilot.controller.enabled.value); |
| 67 | + REQUIRE(model.autopilot.controller.mode.value == ship_data_model::AutopilotMode::compass); |
| 68 | + REQUIRE(model.autopilot.controller.heading_deg.valid); |
| 69 | + REQUIRE(model.autopilot.controller.heading_command_deg.valid); |
| 70 | + NEAR(model.autopilot.controller.heading_deg.value, 90.0f, 0.001f); |
| 71 | + NEAR(model.autopilot.controller.heading_command_deg.value, 90.0f, 0.001f); |
| 72 | + NEAR(model.steering.rudder.angle_deg.value, -2.0f, 0.001f); |
| 73 | + |
| 74 | + const uint8_t nav_to_wp[] = {0x85, 0xb5, 0x07, 0x01, 0x00, 0x05, 0x07, 0x00}; |
| 75 | + accept(receiver, model, nav_to_wp, sizeof(nav_to_wp), now_us); |
| 76 | + REQUIRE(model.route.apb.xte_nmi.valid); |
| 77 | + REQUIRE(model.route.apb.heading_to_steer_deg.valid); |
| 78 | + REQUIRE(model.route.waypoint.distance_nmi.valid); |
| 79 | + REQUIRE(model.route.apb.mode_hint.value == ship_data_model::AutopilotMode::nav); |
| 80 | + NEAR(model.route.apb.xte_nmi.value, 1.23f, 0.001f); |
| 81 | + NEAR(model.route.apb.heading_to_steer_deg.value, 90.0f, 0.001f); |
| 82 | + NEAR(model.route.waypoint.distance_nmi.value, 8.0f, 0.001f); |
| 83 | + |
| 84 | + const uint8_t key[] = {0x86, 0x01, 0x41, 0xbe}; |
| 85 | + accept(receiver, model, key, sizeof(key), now_us); |
| 86 | + REQUIRE(std::strcmp(model.notifications.messages.event.event_id, "seatalk_ap_key") == 0); |
| 87 | + REQUIRE(model.notifications.messages.event.event_state == 'L'); |
| 88 | + REQUIRE(std::strcmp(model.notifications.messages.event.event_text, "auto") == 0); |
| 89 | + |
| 90 | + const uint8_t variation[] = {0x99, 0x00, 0xfe}; |
| 91 | + accept(receiver, model, variation, sizeof(variation), now_us); |
| 92 | + REQUIRE(model.ins.imu.magnetic_variation_deg.valid); |
| 93 | + NEAR(model.ins.imu.magnetic_variation_deg.value, -2.0f, 0.001f); |
| 94 | + |
| 95 | + REQUIRE(receiver.decoded_count() == 11); |
64 | 96 | REQUIRE(receiver.unsupported_count() == 0); |
65 | 97 | return 0; |
66 | 98 | } |
0 commit comments