device_configuration_test.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (Apache 2.0)
3  *
4  * Copyright (c) 2019, The MITRE Corporation.
5  * All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * https://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * Sections of this project contains content developed by The MITRE Corporation.
20  * If this code is used in a deployment or embedded within another project,
21  * it is requested that you send an email to opensource@mitre.org in order to
22  * let us know where this software is being used.
23  *********************************************************************/
24 
25 #include <gtest/gtest.h>
28 #include "init_vars.hpp"
29 
30 TEST(DeviceConfiguration, calcBaudRateZeroPacket){
32 }
33 
34 TEST(DeviceConfiguration, calcBaudRateSmall){
36 }
37 
38 TEST(DeviceConfiguration, calcBaudRateLarge){
40 }
41 
42 TEST(DeviceConfiguration, calcBaudRateLargeVarying){
44 }
45 
46 TEST(DeviceConfiguration, calcBaudRateMinFrequency){
48 }
49 
50 TEST(DeviceConfiguration, calcBaudRateMaxFrequency){
52 }
53 
54 // We should only allow up to 1000 Hz
55 TEST(DeviceConfiguration, calcBaudRateExceedingMaxFrequency){
57 }
58 
59 TEST(DeviceConfiguration, calcBaudRateUnsupported){
61 }
62 
63 TEST(DeviceConfiguration, calcBaudRateDuplicate){
65 }
66 
67 TEST(DeviceConfiguration, createPacketPeriodsZeroRequest)
68 {
69  packet_periods_packet_t periodsPacket;
70  memset(&periodsPacket, 0, sizeof(periodsPacket));
72  KvhPackReqEnv::zeroRequest, periodsPacket));
73  // No packets should have been added
74  EXPECT_EQ(0, periodsPacket.packet_periods[0].packet_id);
75 }
76 
77 TEST(DeviceConfiguration, createPacketPeriodsSmallRequest)
78 {
79  packet_periods_packet_t periodsPacket;
81  KvhPackReqEnv::smallRequest, periodsPacket));
82  // The periods below come from the formula in their tech document
83  // period = 1000 / frequency
84  // This is a simplified equations as you can technically change the 1000
85  EXPECT_EQ(packet_id_system_state, periodsPacket.packet_periods[0].packet_id);
86  EXPECT_EQ(20, periodsPacket.packet_periods[0].period);
87  EXPECT_EQ(packet_id_raw_sensors, periodsPacket.packet_periods[1].packet_id);
88  EXPECT_EQ(20, periodsPacket.packet_periods[1].period);
89 }
90 
91 TEST(DeviceConfiguration, createPacketPeriodsUnsupported)
92 {
93  packet_periods_packet_t periodsPacket;
95  KvhPackReqEnv::unsupportedRequest, periodsPacket));
96 }
97 
98 TEST(DeviceConfiguration, createPacketPeriodsDuplicated)
99 {
100  packet_periods_packet_t periodsPacket;
102  KvhPackReqEnv::duplicateRequest, periodsPacket));
103 }
104 
105 TEST(DeviceConfiguration, createPacketPeriodsUnsupportedandDuplicated)
106 {
107  packet_periods_packet_t periodsPacket;
110 }
111 
112 TEST(DeviceConfiguration, createPacketPeriodsExceedingMaxPeriods)
113 {
114  kvh::KvhPacketRequest maxPeriods;
115  for(int i = 0; i < 60; i++)
116  {
117  maxPeriods.push_back(KvhPackReqEnv::freqPair(packet_id_system_state, 20));
118  }
119  packet_periods_packet_t periodsPacket;
121  maxPeriods, periodsPacket));
122 }
123 
124 TEST(DeviceConfiguration, createFilterOptionsDefault)
125 {
126  filter_options_packet_t filterOptions;
128  filterOptions));
129 
130  EXPECT_EQ(true, filterOptions.permanent);
131  EXPECT_EQ(vehicle_type_car, filterOptions.vehicle_type);
132  EXPECT_EQ(true, filterOptions.internal_gnss_enabled);
133  EXPECT_EQ(true, filterOptions.atmospheric_altitude_enabled);
134  EXPECT_EQ(true, filterOptions.velocity_heading_enabled);
135  EXPECT_EQ(true, filterOptions.reversing_detection_enabled);
136  EXPECT_EQ(true, filterOptions.motion_analysis_enabled);
137 }
138 
139 TEST(DeviceConfiguration, createFilterOptionsVehicleOutOfRange)
140 {
141  filter_options_packet_t filterOptions;
143  filterOptions, true, 15));
144 }
145 
146 TEST(DeviceConfiguration, setBaudRate)
147 {
148  EXPECT_EQ(-1, kvh::KvhDeviceConfig::SetBaudRate("/dev/ttyUSB0", 115200, 230400));
149 }
static int SetBaudRate(std::string _port, int _curBaudRate, int _primaryBaudRate, int _gpioBaudRate=115200, int _auxBaudRate=115200)
This function can be used to set the buad rate independent of the other functions of the driver...
KVH Geo Fog 3D driver class header.
packet_period_t packet_periods[MAXIMUM_PACKET_PERIODS]
static kvh::KvhPacketRequest minFrequencyRequest
Definition: init_vars.hpp:41
static int CreateFilterOptionsPacket(filter_options_packet_t &, bool _permanent=true, uint8_t _vehicle_type=vehicle_type_car, bool _internal_gnss_enabled=true, bool _atmospheric_altitude_enabled=true, bool _velocity_heading_enabled=true, bool _reversing_detection_enabled=true, bool _motion_analysis_enabled=true)
static kvh::KvhPacketRequest unsupportedDuplicateRequest
Definition: init_vars.hpp:46
static int CalculateRequiredBaud(KvhPacketRequest &)
Helper functions for configuring the hardware.
static kvh::KvhPacketRequest largeVaryingRatesRequest
Definition: init_vars.hpp:40
static kvh::KvhPacketRequest zeroRequest
Definition: init_vars.hpp:37
static kvh::KvhPacketRequest duplicateRequest
Definition: init_vars.hpp:44
static kvh::KvhPacketRequest unsupportedRequest
Definition: init_vars.hpp:45
static kvh::KvhPacketRequest exceedingMaxFrequencyRequest
Definition: init_vars.hpp:43
static kvh::KvhPacketRequest largeRequest
Definition: init_vars.hpp:39
std::vector< std::pair< packet_id_e, uint16_t > > KvhPacketRequest
TEST(DeviceConfiguration, calcBaudRateZeroPacket)
static kvh::KvhPacketRequest smallRequest
Definition: init_vars.hpp:38
static int CreatePacketPeriodsPacket(KvhPacketRequest &_packetsRequested, packet_periods_packet_t &_packetPeriods)
static kvh::KvhPacketRequest maxFrequencyRequest
Definition: init_vars.hpp:42
std::pair< packet_id_e, uint16_t > freqPair
Definition: init_vars.hpp:35


kvh_geo_fog_3d_driver
Author(s): Trevor Bostic , Zach LaCelle
autogenerated on Fri Jan 24 2020 03:18:17