diff --git a/advanced_navigation/anpp_packets/an_packet_181.py b/advanced_navigation/anpp_packets/an_packet_181.py index ff26c46..c3409d2 100644 --- a/advanced_navigation/anpp_packets/an_packet_181.py +++ b/advanced_navigation/anpp_packets/an_packet_181.py @@ -83,7 +83,7 @@ def decode(self, an_packet: ANPacket) -> int: ) self.permanent = an_packet.data[0] self.clear_existing_packets = an_packet.data[1] - self.packet_periods = [PacketPeriod()] * packet_periods_count + self.packet_periods = [PacketPeriod() for _ in range(packet_periods_count)] for i in range(packet_periods_count): index = self.MINIMUM_LENGTH + i * PacketPeriod.LENGTH self.packet_periods[i].unpack( diff --git a/advanced_navigation/anpp_packets/an_packet_202.py b/advanced_navigation/anpp_packets/an_packet_202.py index d45322c..8db9c31 100644 --- a/advanced_navigation/anpp_packets/an_packet_202.py +++ b/advanced_navigation/anpp_packets/an_packet_202.py @@ -70,7 +70,7 @@ class IPDataportConfigurationPacket: """Packet 202 - IP Dataport Configuration Packet""" ip_dataport_configuration: list[IPDataportConfiguration] = field( - default_factory=lambda: [IPDataportConfiguration()] * 4 + default_factory=lambda: [IPDataportConfiguration() for _ in range(4)] ) ID = PacketID.ip_dataports_configuration diff --git a/advanced_navigation/anpp_packets/an_packet_31.py b/advanced_navigation/anpp_packets/an_packet_31.py index dc77c0b..ce6619f 100644 --- a/advanced_navigation/anpp_packets/an_packet_31.py +++ b/advanced_navigation/anpp_packets/an_packet_31.py @@ -123,7 +123,7 @@ def decode(self, an_packet: ANPacket) -> int: (len(an_packet.data) % DetailedSatellite.LENGTH) == 0 ): number_of_satellites = int(len(an_packet.data) / DetailedSatellite.LENGTH) - self.satellites = [DetailedSatellite()] * number_of_satellites + self.satellites = [DetailedSatellite() for _ in range(number_of_satellites)] for i in range(number_of_satellites): index = i * DetailedSatellite.LENGTH self.satellites[i].unpack( diff --git a/advanced_navigation/anpp_packets/an_packet_60.py b/advanced_navigation/anpp_packets/an_packet_60.py index b6c82de..e467666 100644 --- a/advanced_navigation/anpp_packets/an_packet_60.py +++ b/advanced_navigation/anpp_packets/an_packet_60.py @@ -183,8 +183,8 @@ def unpack(self, data): self.satellite_system = SatelliteSystem(satellite_system_value) self.frequency_information = [ - FrequencyInformation() - ] * self.number_of_frequencies + FrequencyInformation() for _ in range(self.number_of_frequencies) + ] for i in range(self.number_of_frequencies): index = 6 + i * FrequencyInformation.LENGTH self.frequency_information[i].unpack( @@ -225,17 +225,19 @@ def decode(self, an_packet: ANPacket): self.number_of_satellites, ) = self._structure.unpack_from(an_packet.data) - self.satellite_data = [SatelliteData()] * self.number_of_satellites + self.satellite_data = [ + SatelliteData() for _ in range(self.number_of_satellites) + ] - number_of_previous_frequencies = 0 + total_previous_frequencies = 0 for i in range(self.number_of_satellites): index = ( self.HEAD_LENGTH + i * SatelliteData.MINIMUM_LENGTH - + number_of_previous_frequencies * FrequencyInformation.LENGTH + + total_previous_frequencies * FrequencyInformation.LENGTH ) self.satellite_data[i].unpack(an_packet.data[index:]) - number_of_previous_frequencies = self.satellite_data[ + total_previous_frequencies += self.satellite_data[ i ].number_of_frequencies return 0 diff --git a/advanced_navigation/anpp_packets/an_packet_84.py b/advanced_navigation/anpp_packets/an_packet_84.py index 130cc23..1430bd8 100644 --- a/advanced_navigation/anpp_packets/an_packet_84.py +++ b/advanced_navigation/anpp_packets/an_packet_84.py @@ -106,7 +106,9 @@ def decode(self, an_packet: ANPacket) -> int: ) self.total_number_of_packets = an_packet.data[0] self.packet_number = an_packet.data[1] - self.extended_satellites = [ExtendedSatellite()] * number_of_satellites + self.extended_satellites = [ + ExtendedSatellite() for _ in range(number_of_satellites) + ] for i in range(number_of_satellites): index = self.MINIMUM_LENGTH + i * ExtendedSatellite.LENGTH self.extended_satellites[i].unpack( diff --git a/tests/anpp_packets_tests/test_repeated_record_decoding.py b/tests/anpp_packets_tests/test_repeated_record_decoding.py new file mode 100644 index 0000000..5fcb6f8 --- /dev/null +++ b/tests/anpp_packets_tests/test_repeated_record_decoding.py @@ -0,0 +1,140 @@ +################################################################################ +## ## +## Advanced Navigation Python Language SDK ## +## test_repeated_record_decoding.py ## +## Copyright 2026, Advanced Navigation ## +## ## +################################################################################ +# # +# Copyright (C) 2026 Advanced Navigation # +# # +# Permission is hereby granted, free of charge, to any person obtaining # +# a copy of this software and associated documentation files (the "Software"), # +# to deal in the Software without restriction, including without limitation # +# the rights to use, copy, modify, merge, publish, distribute, sublicense, # +# and/or sell copies of the Software, and to permit persons to whom the # +# Software is furnished to do so, subject to the following conditions: # +# # +# The above copyright notice and this permission notice shall be included # +# in all copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # +# DEALINGS IN THE SOFTWARE. # +################################################################################ + +import struct + +import pytest + +from advanced_navigation.anpp_packets.an_packet_31 import DetailedSatellitesPacket +from advanced_navigation.anpp_packets.an_packet_60 import RawSatelliteDataPacket +from advanced_navigation.anpp_packets.an_packet_84 import ExtendedSatellitesPacket +from advanced_navigation.anpp_packets.an_packet_181 import PacketsPeriodPacket +from advanced_navigation.anpp_packets.an_packet_202 import ( + IPDataportConfigurationPacket, +) +from advanced_navigation.anpp_packets.an_packet_protocol import ANPacket + +DETAILED_SATELLITE = struct.Struct("