64 std::set<packet_id_e> packetIdList;
69 for (
int i = 0; i < _packetsRequested.size(); i++)
71 std::pair<packet_id_e, int> packet = _packetsRequested[i];
79 if (packetIdList.count(packet.first) > 0)
87 period.
packet_id = _packetsRequested[i].first;
88 period.
period = 1000 / _packetsRequested[i].second;
92 packetIdList.insert(packet.first);
95 return unsupported + duplicated;
117 uint8_t _vehicle_type,
118 bool _internal_gnss_enabled,
119 bool _atmospheric_altitude_enabled,
120 bool _velocity_heading_enabled,
121 bool _reversing_detection_enabled,
122 bool _motion_analysis_enabled)
124 if (_vehicle_type > 13)
173 strncpy(portArr, _port.c_str(), 4096);
186 requestPacket =
nullptr;
204 std::vector<int> baudRates = {
205 1200, 1800, 2400, 4800, 9600,
206 19200, 57600, 115200, 230400,
207 460800, 500000, 576000, 921600, 1000000};
210 strncpy(portArr, _port.c_str(), 4096);
212 for (
int baudRate : baudRates)
215 if (baudRate < _startingBaud)
220 printf(
"Opening with port: %s, baudrate: %d...\n", portArr, baudRate);
231 for (
int i = 0; i < 20; i++)
243 printf(
"Found a packet\n");
246 printf(
"Found connection at %d baud\n", baudRate);
275 std::set<packet_id_e> packetIdList;
276 int dataThroughput = 0;
278 for (
int i = 0; i < _packetsRequested.size(); i++)
280 std::pair<packet_id_e, uint16_t> packet = _packetsRequested[i];
287 else if (packetIdList.count(packet.first) > 0)
293 if (packet.second > 1000)
299 dataThroughput += (
packetSize_[packet.first] + 5) * packet.second;
300 packetIdList.insert(packet.first);
303 return dataThroughput * 11;
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...
void an_decoder_initialise(an_decoder_t *an_decoder)
packet_period_t packet_periods[MAXIMUM_PACKET_PERIODS]
uint8_t motion_analysis_enabled
#define an_decoder_increment(an_decoder, bytes_received)
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)
int OpenComport(char *, int)
std::set< packet_id_e > supportedPackets_
Set of packets containing all packet_id's we support.
static int CalculateRequiredBaud(KvhPacketRequest &)
Helper functions for configuring the hardware.
an_packet_t * an_packet_decode(an_decoder_t *an_decoder)
uint8_t atmospheric_altitude_enabled
an_packet_t * encode_baud_rates_packet(baud_rates_packet_t *baud_rates_packet)
#define an_packet_size(packet)
#define MAXIMUM_PACKET_PERIODS
std::map< packet_id_e, int > packetSize_
Map relating packet id's to the associated struct size. Used for baudrate calculation.
static int FindCurrentBaudRate(std::string, int)
This function tries each possible setting of baudrates until it either finds one that is receiving pa...
int PollComport(unsigned char *, int)
uint32_t gpio_1_2_baud_rate
std::vector< std::pair< packet_id_e, uint16_t > > KvhPacketRequest
#define an_decoder_size(an_decoder)
uint8_t internal_gnss_enabled
uint8_t clear_existing_packets
uint32_t auxiliary_baud_rate
uint8_t reversing_detection_enabled
static int CreatePacketPeriodsPacket(KvhPacketRequest &_packetsRequested, packet_periods_packet_t &_packetPeriods)
void an_packet_encode(an_packet_t *an_packet)
#define an_packet_pointer(packet)
void an_packet_free(an_packet_t **an_packet)
int SendBuf(unsigned char *, int)
uint32_t primary_baud_rate
#define an_decoder_pointer(an_decoder)
uint8_t velocity_heading_enabled